WinForms - 如何调用窗口文档上下文菜单

发布于 2024-12-14 19:46:27 字数 410 浏览 5 评论 0原文

在每个 Windows 应用程序上都有一个上下文菜单,您可以使用 CTRL+空格键访问:

我相信这个菜单称为“窗口控制菜单”,但我不确定。

它有以下选项:

  • 恢复

  • 移动

  • 尺寸

  • 最小化

  • 最大化

  • 关闭 Alt+F4

这是一张图片:

在此处输入图像描述

如何使用 win 表单调用它?我的目标是通过按 alt+空格键提供此菜单的键盘快捷键,

谢谢。

On every windows app there is that context menu that you can access with CTRL+Space bar:

I believe this menu is called the "Window Control Menu", but I am not sure.

It has the following options:

  • Restore

  • Move

  • Size

  • Minimize

  • Maximize

  • Close Alt+F4

Here is a pic:

enter image description here

How can I call this using win forms? My goal is to provide a keyboard shortcut to this menu by hitting alt+spacebar

Thanks.

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

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

发布评论

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

评论(1

赠意 2024-12-21 19:46:27

向您自己的窗口发送消息,以便出现系统菜单。

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, int lParam);

    private void callSysMenu()
    {
        int point = ((this.Location.Y << 16) | ((this.Location.X) & 0xffff));
        SendMessage(this.Handle, 0x313, IntPtr.Zero, point);
    }

Send a message to your own window so that the system menu appears.

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, int lParam);

    private void callSysMenu()
    {
        int point = ((this.Location.Y << 16) | ((this.Location.X) & 0xffff));
        SendMessage(this.Handle, 0x313, IntPtr.Zero, point);
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文