禁用'要求'上的MenuStrip点击时,双击一个聚焦窗口 [英] Disable the 'requirement' to double click an unfocused window when clicking on a menustrip

查看:145
本文介绍了禁用'要求'上的MenuStrip点击时,双击一个聚焦窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉的奇怪的标题,我目前正在玩弄WinForms和我想知道是否有什么办法可以让这个你不必为双击窗口中激活一个项目一个MenuStrip中当窗口聚焦?

Sorry about the weird title, I'm currently playing around with WinForms and I'm wondering if there is any way to make it so that you don't have to 'double-click' the window to activate an item in a menustrip when the window is unfocused?

目前如果窗口聚焦我首先要点击窗口给它对焦,然后再次点击的MenuStrip项目即使我的鼠标盘旋以上从一开始的MenuStrip项目。

Currently if the window is unfocused I first have to click on the window to give it focus and then click once again on the menustrip item even if my mouse was hovering above the menustrip item from the start.

在此先感谢!

推荐答案

尝试把这个功能在你的窗体类:

Try putting this function in your Form class:

protected override void WndProc(ref Message m) {
    int WM_PARENTNOTIFY = 0x0210;
    if (!this.Focused && m.Msg == WM_PARENTNOTIFY) {
        // Make this form auto-grab the focus when menu/controls are clicked
        this.Activate();
    }
    base.WndProc(ref m);
}

这篇关于禁用'要求'上的MenuStrip点击时,双击一个聚焦窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆