0
votes

I am experimenting with VCL Styles. This might be a silly question, but is it possible to have forms with different backgrounds when using a style? It seems that the form background (client area) is specified in the VCL style designer and it overrides the form's Color property.

How can I achieve forms with different background color? For example, I want my modal dialogs have a different background color than the main form.

1
Also useful links are at stackoverflow.com/questions/9906312Arioch 'The
The link @Arioch'The provided contains the solution, you just need to adapt a few things: ` TFromStyleHookExt= class(TFormStyleHook)` change TWinControlClass(Control). to TForm(Control). adapt initialization TStyleManager.Engine.RegisterStyleHook(TForm_XY, TFromStyleHookExt); and change WndProc.bummi

1 Answers

6
votes

Yes it is possible : if you are using Delphi XE3,XE4,XE5 : you only need to remove seClient from the StyleElements property of your form :

 Form3.StyleElements := [seFont, seBorder];

if you are using delphi xe2: you should override the TFormStyleHook class ,and catch the WM_ERASEBKGND message , and return without processing the default message :

type
  TFormStyleHookEx = class(TFormStyleHook)
    procedure WMEraseBkgnd(var Message: TMessage); message WM_ERASEBKGND;
  end;
{ TFormStyleHookEx }

procedure TFormStyleHookEx.WMEraseBkgnd(var Message: TMessage);
begin
  Message.Result := 1;
end;

initialization

TStyleEngine.RegisterStyleHook(TForm3, TFormStyleHookEx);

enter image description here