分层 Windows 的系统菜单?

发布于 2024-10-31 09:39:31 字数 456 浏览 11 评论 0原文

我们在 Delphi 2009 中的分层窗口和系统菜单方面遇到了问题。也就是说,我们的分层窗口(没有边框)没有系统菜单。当我说系统菜单时,我指的是单击应用程序的图标、右键单击其标题栏或(在 Windows 7 中,加上 Shift 键)右键单击任务栏中的应用程序时获得的菜单:

控制菜单

当您尝试访问系统菜单时,例如通过右键单击任务栏图标,此类分层窗口,而是升起分层窗口。这是为什么呢?是否需要设置某种样式,或者处理某种事件?

这是一个匆忙制作的演示,显示了该问题。不过,它确实可以用带有 bsNone borderstyle 的任何形式来重现。

http://ompldr.org/vODd5dw

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假装不在乎 2024-11-07 09:39:31

您需要重新添加使用 bsNone 边框样式删除的 WS_SYSMENU 样式。

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;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文