CMFCPopupMenu 在 Win7 中保持在后台
我正在尝试一些新的 MFC 功能,并且我想要与 Visual Studio 2010 的 Visual C++ 语言示例中的 TrayMenu 项目相同的功能,但在我的计算机中(不知道是否仅在我的计算机中我尝试找到在网上有同样的问题,但没有找到任何类似的报告!!!)菜单出现在新的win7的traynotifywwnd的背景中,我似乎无法让它正常工作:
代码很简单:
void CTrayMenuDlg::OnTrayContextMenu ()
{
CPoint point;
::GetCursorPos (&point);
CMenu menu;
menu.LoadMenu (IDR_MENU1);
CMFCPopupMenu::SetForceShadow (TRUE);
HMENU hMenu = menu.GetSubMenu (0)->Detach ();
CMFCPopupMenu* pMenu = theApp.GetContextMenuManager()->ShowPopupMenu(hMenu, point.x, point.y, this, TRUE);
pMenu->SetForegroundWindow ();
}
我认为SetForegroundWindow 是解决此问题的一些方法,但它不起作用,它仍然显示在窗口后面,当我们单击小箭头时,所有托盘图标都被隐藏和显示(请注意,如果图标显示在 ToolbarWindow32 -不隐藏 - 我们调用托盘上下文菜单,然后一切正常,只有当图标被隐藏并使用 ToolbarWindow32 中的小箭头显示并且显示带有隐藏图标的窗口时,才会出现此问题 - 该窗口是否保留在...前面我的上下文菜单...)
有人发现这个问题吗?这个问题有什么解决办法吗?
谢谢
I'm trying some of the new MFC functionality and i want the same thing that the TrayMenu project from Visual C++ Language Samples for Visual Studio 2010 does but in my machine (don't know if is only in my machine i try to find the same problem in the web but didn't find any similar report!!!) the menu appears in the background of the new win7 traynotifywwnd, and i can't seem to put it work right:
The code is simple:
void CTrayMenuDlg::OnTrayContextMenu ()
{
CPoint point;
::GetCursorPos (&point);
CMenu menu;
menu.LoadMenu (IDR_MENU1);
CMFCPopupMenu::SetForceShadow (TRUE);
HMENU hMenu = menu.GetSubMenu (0)->Detach ();
CMFCPopupMenu* pMenu = theApp.GetContextMenuManager()->ShowPopupMenu(hMenu, point.x, point.y, this, TRUE);
pMenu->SetForegroundWindow ();
}
I think that SetForegroundWindow is some how a fix for this problem, but it does not work, it stills show bewind the window where all the tray icon are hidden and displayed when we click in the little arrow (note that if the icon is displayed in the ToolbarWindow32 -not hidden - and we call the tray context menu then it all works fine, this problem only appear if the icon is hidden and is show using the little arrow in the ToolbarWindow32 and a window is displayed with the hidden icons - is this window that stays in front of my context menu...)
Has anyone find this problem? and there is any solution for this problem?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对此不太确定,但您可以尝试添加:
而不是 pMenu->SetForegroundWindow ();
I am not sure about this one but you can try adding:
instead of pMenu->SetForegroundWindow ();
来自 MSDN:
对我来说这有效!
From MSDN:
For me this worked!