Delphi 弹出菜单可见性

发布于 2024-07-06 21:57:38 字数 57 浏览 5 评论 0原文

Delphi 7 有没有办法确定弹出菜单是否可见(显示在屏幕上),因为它缺少 Visible 属性。

Is there a way in Delphi 7 to find out if a pop-up menu is visible (shown on the screen) or not, since it lacks a Visible property.

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

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

发布评论

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

评论(2

情感失落者 2024-07-13 21:57:38

您可以通过在 OnPopup 事件中设置它来制作自己的标志。 问题是知道弹出菜单何时关闭。 彼得·下面有一个解决方案。

但我问你为什么想要这个? 也许有更好的方法来解决根本问题。

You could make your own flag by setting it in the OnPopup event. The problem is knowing when the popupmenu is closed. Peter Below has a solution for that.

But my I ask why you would want this? Maybe there is a better way to solve the underlying problem.

想你的星星会说话 2024-07-13 21:57:38

这似乎更简单一些(我使用Delphi 2007):

在你的WM_CONTEXTMENU消息处理程序中,在调用继承的处理程序之前,弹出菜单即将显示,你可以设置你的标志。 调用inherited后,弹出菜单已经关闭,重置你的flag。

procedure TForm1.WMContextMenu(var Message: TWMContextMenu);
begin
  FPopupActive := True;
  try
    OutputDebugString(PChar(Format('popup opening', [])));
    inherited;
  finally
    FPopupActive := False;
    OutputDebugString(PChar(Format('popup closed', [])));
  end;
end;

This seems to be a bit simpler (I used Delphi 2007):

In your WM_CONTEXTMENU message handler, before calling the inherited handler, the popup menu is about to be shown, you can set your flag. After calling inherited, the popup menu has been closed, reset your flag.

procedure TForm1.WMContextMenu(var Message: TWMContextMenu);
begin
  FPopupActive := True;
  try
    OutputDebugString(PChar(Format('popup opening', [])));
    inherited;
  finally
    FPopupActive := False;
    OutputDebugString(PChar(Format('popup closed', [])));
  end;
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文