Home > Software engineering >  Close the window when close the menu
Close the window when close the menu

Time:12-17

Have two Windows, the login window and the main window, after login according to the main window; In the main window right-click pop-up menu, and then the main window for other reasons to return to the login window, but the menu is still exist; The DestroyMenu there is no effect;
The popup menu is TrackPopupMenu ;

CodePudding user response:

Try call before TrackPopupMenu SetForegroundWindow

CodePudding user response:

reference 1st floor zgl7903 response:
try call before TrackPopupMenu SetForegroundWindow

Is not this, this is the mouse to click the window menu will disappear, this is normal,
In the MFC simulation:
Window 1 is landing window, the window 2 is the main window.
Login window 1, hide yourself, show window 2 (non-modal);
Window 2 time log out, then the pop-up menu, waiting for cancellation; Log out hidden himself and displayed his father;
Results: the menu will normally disappear;
Before I was with the duilib do, is also the login window hide themselves after login, non-modal shows the main window, but the main window is kicked, hide yourself, go back to the login window, but before the menu is showing,

CodePudding user response:

Then try blocking type menu
 
Void CTdgDlg: : OnContextMenu (CWnd * pWnd, CPoint point)
{
CMenu menu;
Menu. LoadMenu (IDR_MENU1);
CMenu * pMenu=menu. GetSubMenu (0);

If (pMenu!=NULL)
{
BOOL bCmd=pMenu - & gt; The TrackPopupMenu (
TPM_NONOTIFY | TPM_RETURNCMD, point x, point. J y, this);

TRACE (_T (" MenuSel=% u \ n "), (UINT) bCmd);
If (bCmd!=0)
{
PostMessage (WM_COMMAND, bCmd, 0);
}
}
}


  • Related