Menu Control Popup using TrackPopupMenuEx
-
Hello dudes, I am writing an application which places itself to systray when minmized. When user right clicks to icon, I pop-up a menu and my problem starts here. :doh: I want to close pop up window when it loses focus, I also wanna catch events from menu. :-O This is how I open menu:
POINT xy;
GetCursorPos(&xy);HMENU menu = LoadMenu(this->appInstance, MAKEINTRESOURCE(350));
BOOL b = TrackPopupMenuEx(GetSubMenu(menu, 0),
TPM_RIGHTALIGN|TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RETURNCMD,
xy.x, xy.y, this->getHWND(), NULL);So how I am supposed to MAP events from menu, i am using MFC? :confused: Thank you all... :)
-
Hello dudes, I am writing an application which places itself to systray when minmized. When user right clicks to icon, I pop-up a menu and my problem starts here. :doh: I want to close pop up window when it loses focus, I also wanna catch events from menu. :-O This is how I open menu:
POINT xy;
GetCursorPos(&xy);HMENU menu = LoadMenu(this->appInstance, MAKEINTRESOURCE(350));
BOOL b = TrackPopupMenuEx(GetSubMenu(menu, 0),
TPM_RIGHTALIGN|TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RETURNCMD,
xy.x, xy.y, this->getHWND(), NULL);So how I am supposed to MAP events from menu, i am using MFC? :confused: Thank you all... :)
for the first problem: just call setforegroundwindow() before trackpopupmenu(). secondly if u r usig mfc, u can have message map entry for every command and if not then u trap the command in the wndproc(). enjoy Pras
-
for the first problem: just call setforegroundwindow() before trackpopupmenu(). secondly if u r usig mfc, u can have message map entry for every command and if not then u trap the command in the wndproc(). enjoy Pras
Ok I know that but cannot find how to do it? I create my menu from a resource with id 350. And here is my message map:
BEGIN_MESSAGE_MAP(CMyWnd, CDialog)
ON_WM_CLOSE()
ON_WM_SIZE()
ON_WM_TIMER()
ON_BN_CLICKED(152, ...)
ON_BN_CLICKED(156, ...)
ON_BN_CLICKED(171, ...)
ON_BN_CLICKED(172, ...)
ON_BN_CLICKED(173, ...)
ON_BN_CLICKED(174, ...)
ON_BN_CLICKED(175, ...)
ON_BN_CLICKED(176, ...)
ON_BN_CLICKED(177, ...)
ON_MESSAGE(WM_USER_SHELLICON, ...)
//What should I write here to get menu messages? :confused:
END_MESSAGE_MAP()Thanks....
-
Ok I know that but cannot find how to do it? I create my menu from a resource with id 350. And here is my message map:
BEGIN_MESSAGE_MAP(CMyWnd, CDialog)
ON_WM_CLOSE()
ON_WM_SIZE()
ON_WM_TIMER()
ON_BN_CLICKED(152, ...)
ON_BN_CLICKED(156, ...)
ON_BN_CLICKED(171, ...)
ON_BN_CLICKED(172, ...)
ON_BN_CLICKED(173, ...)
ON_BN_CLICKED(174, ...)
ON_BN_CLICKED(175, ...)
ON_BN_CLICKED(176, ...)
ON_BN_CLICKED(177, ...)
ON_MESSAGE(WM_USER_SHELLICON, ...)
//What should I write here to get menu messages? :confused:
END_MESSAGE_MAP()Thanks....
dehseth wrote:
What should I write here to get menu messages?
Typically ON_COMMAND and ON_UPDATE_COMMAND_UI are used for menus. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
dehseth wrote:
What should I write here to get menu messages?
Typically ON_COMMAND and ON_UPDATE_COMMAND_UI are used for menus. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Yeah I have read a lil bit but I couldnt make it work... I have tried a map
ON_MESSAGE(WM_COMMAND, Menu_Message)
also
ON_MESSAGE(WM_MENUCOMMAND, Menu_Message)
but still didnt worked! :doh: This is my function which I hope to handle messages:
LRESULT CMemorizerWnd::Menu_Message(WPARAM wp, LPARAM lp)
well in debug mode it never enters to my function. So I am still looking for a solution for this... :~
-
Yeah I have read a lil bit but I couldnt make it work... I have tried a map
ON_MESSAGE(WM_COMMAND, Menu_Message)
also
ON_MESSAGE(WM_MENUCOMMAND, Menu_Message)
but still didnt worked! :doh: This is my function which I hope to handle messages:
LRESULT CMemorizerWnd::Menu_Message(WPARAM wp, LPARAM lp)
well in debug mode it never enters to my function. So I am still looking for a solution for this... :~
Maybe remove the TPM_RETURNCMD flag from the TrackPopupMenu() call and use ON_COMMAND instead of ON_MESSAGE in the message map. Also, you won't get the command message until TrackPopupMenu() returns. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: