Search code examples
delphiformsmdi

Delphi MDI Application and the titlebar of the MDI Children


I've got an MDI application written in Delphi 2006 which runs XP with the default theme.

Is there a way of controlling the appearance of the MDI Children to avoid the large XP-style title bar on each window?

I've tried setting the BorderStyle of the MDIChildren to bsSizeToolWin but they are still rendered as normal Forms.


Solution

  • All your need - overload procedure CreateWindowHandle, like this:

    unit CHILDWIN;
    interface
    uses Windows, Classes, Graphics, Forms, Controls, StdCtrls;
    
    type
      TMDIChild = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
        procedure CreateWindowHandle(const Params: TCreateParams); override;
      end;
    
    implementation
    
    {$R *.dfm}
    procedure TMDIChild.CreateWindowHandle(const Params: TCreateParams);
    begin
      inherited CreateWindowHandle(Params);
      SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
    end;
    end.