win7上使用TrackPopupMenu的问题

发布于 2024-09-10 11:55:38 字数 1007 浏览 1 评论 0原文

我试图在我的应用程序中使用 TrackPopupMenu 函数创建上下文菜单,我在其中使用的代码如下所示:

CMenu menu;
        if (menu.LoadMenu(IDR_MENU_TRAY))
        {
            CMenu* pSubMenu = menu.GetSubMenu(0);
            if (pSubMenu != NULL)
            {
                pSubMenu->ModifyMenu(IDM_CLOSE,MF_BYCOMMAND,IDM_CLOSE ,g_cfg->GetLang(TEXT_MAIN_CLOSE,"Exit(&X)")); 
                pSubMenu->ModifyMenu(IDM_SHOW,MF_BYCOMMAND,IDM_SHOW ,g_cfg->GetLang(TEXT_MAIN_OPEN_SHUTTER,"Open(&O)"));
                CPoint point;
                GetCursorPos(&point);                                                                   
                SetForegroundWindow();  
                pSubMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, messageOnlyWnd); 
            }
        }

该代码在 WinXP 上运行完美,而在 win7 和 vista 上则不然。 win7和vista上的问题是弹出菜单需要相当长的时间,可能1分钟或更长时间。但是如果我在win7或vista上关闭Aero,它会像在winXP上一样顺利运行,所以我猜代码中肯定有什么东西与Aero冲突,但我只是不知道如何修复它。有人可以帮我吗?如果有人帮助我,我将非常感激。

I'm trying to create context menu using TrackPopupMenu function in my application, the code I use in it is like the following:

CMenu menu;
        if (menu.LoadMenu(IDR_MENU_TRAY))
        {
            CMenu* pSubMenu = menu.GetSubMenu(0);
            if (pSubMenu != NULL)
            {
                pSubMenu->ModifyMenu(IDM_CLOSE,MF_BYCOMMAND,IDM_CLOSE ,g_cfg->GetLang(TEXT_MAIN_CLOSE,"Exit(&X)")); 
                pSubMenu->ModifyMenu(IDM_SHOW,MF_BYCOMMAND,IDM_SHOW ,g_cfg->GetLang(TEXT_MAIN_OPEN_SHUTTER,"Open(&O)"));
                CPoint point;
                GetCursorPos(&point);                                                                   
                SetForegroundWindow();  
                pSubMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, messageOnlyWnd); 
            }
        }

The code runs perfect on WinXP, while on win7 and vista it doesn't. The Problem on win7 and vista is that it takes a fairly long time to pop up the menu, maybe 1 min or more. But if I turn off the Aero on win7 or vista, it runs smoothly just like on winXP, so I guess somethin must be conflicted with Aero in the code, but I just don't know how to fix it. Is there anyone can help me with that? I will appreciate it a lot if anybody helps me out.

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

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

发布评论

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

评论(1

再见回来 2024-09-17 11:55:38

我没有看到这段代码有什么问题。我在 Vista 上使用 TrackPopupMenu 没有任何问题。问题的根源可能在其他地方。尝试删除对 SetForegroundWindow 的调用。如果这不起作用,请尝试仅使用弹出菜单代码创建一个空项目。

I don't see anything wrong with this code. I've used TrackPopupMenu on Vista without any problems. The source of the problem might lie elsewhere. Try removing the call to SetForegroundWindow. If that doesn't work, try creating an empty project with just the popup menu code.

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