I try to use the following technique in order to enable/disable the shadow effect for a window: (The CreateParams is of course overriden. The TToolWindow descends from TForm).
procedure TToolWindow.CreateParams(var Params: TCreateParams);
var
LShadow: boolean;
begin
inherited;
if (Win32Platform = VER_PLATFORM_WIN32_NT)
and ((Win32MajorVersion > 5)
or ((Win32MajorVersion = 5) and (Win32MinorVersion >= 1))) then //Win XP or higher
if SystemParametersInfo(SPI_GETDROPSHADOW, 0, @LShadow, 0) then
begin
if LShadow and HasShadow then
Params.WindowClass.Style := Params.WindowClass.Style or CS_DROPSHADOW;
end;
end;
While this works ok for the first instance of the TToolWindow class, the following instances keep the setting from the first instance, regardless of the value of HasShadow (which is a published property of the TToolWindow class).
How can I have different shadow settings on different instances of TToolWindow?
TIA
The VCL registers the necessary window classes for form classes on the fly, once each time the first instance of a given class is created. That explains why all secondary instances of your
TToolWindowhave the same shadow as the first instance, regardless of theHasShadowvalue. You are creating windows of the same window class, so they all have the same class style.What you could do is registering two classes, one with the drop shadow, the other without it. The VCL will register a new window class if the class name is different from the previously registered class.
Something like this: