4
votes

We're having an issue with layered windows and system menus in Delphi 2009. That is, our layered windows (which have no border) have no system menu. When I say system menu, I am referring to the menu you get when clicking an application's icon, right clicking it's title-bar or (in Windows 7, with the addition of the shift key,) right clicking an application in the task-bar:

Control Menus

When you attempt to access the system menu, e.g. by right-clicking on the task-bar icon, of such a layered window, instead the layered window is risen. Why is this? Is there some sort of style to set, or some sort of event to handle?

Here's a hastily made demo showing the issue. It can really be reproduced with any form with a bsNone borderstyle, though.

http://ompldr.org/vODd5dw

1

1 Answers

13
votes

You need to add back the WS_SYSMENU style which is removed with bsNone border style.

type
  TLayeredForm = class(TForm)
    procedure FormCreate(Sender: TObject);
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

...

procedure TLayeredForm.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := Params.Style or WS_SYSMENU;
end;