mike_marquet
asked on
Popup menu hidding problem !
when I right click on my tray icon, a popup menu appears.
The problem is that when I click outside the menu, the menu is not killed.
How can I make the menu to be killed when I click outiside the menu ?
Here's the code :
LRESULT CWindowHandlePickerDlg::On NotifyTask BarIcon(WP ARAM wParam, LPARAM lParam)
{
UINT uID = (UINT)wParam;
UINT uMouseMsg = (UINT)lParam;
if (uID != ID_TRAYICON) return 0L;
switch(uMouseMsg)
{
case WM_LBUTTONDBLCLK :
OnTrayMenu_ShowInterface() ;
break;
case WM_RBUTTONDOWN :
{
CMenu cTaskBarDummyMenu;
if (!cTaskBarDummyMenu.LoadMe nu(IDM_TAS KBARICON)) return 0L;
CMenu *pcTaskBarMenu = cTaskBarDummyMenu.GetSubMe nu(0);
CPoint point;
GetCursorPos(&point);
if (pcTaskBarMenu) pcTaskBarMenu->TrackPopupM enu(TPM_LE FTALIGN | TPM_LEFTBUTTON, point.x, point.y, this);
cTaskBarDummyMenu.DestroyM enu();
}
break;
}
return 0L;
}
The problem is that when I click outside the menu, the menu is not killed.
How can I make the menu to be killed when I click outiside the menu ?
Here's the code :
LRESULT CWindowHandlePickerDlg::On
{
UINT uID = (UINT)wParam;
UINT uMouseMsg = (UINT)lParam;
if (uID != ID_TRAYICON) return 0L;
switch(uMouseMsg)
{
case WM_LBUTTONDBLCLK :
OnTrayMenu_ShowInterface()
break;
case WM_RBUTTONDOWN :
{
CMenu cTaskBarDummyMenu;
if (!cTaskBarDummyMenu.LoadMe
CMenu *pcTaskBarMenu = cTaskBarDummyMenu.GetSubMe
CPoint point;
GetCursorPos(&point);
if (pcTaskBarMenu) pcTaskBarMenu->TrackPopupM
cTaskBarDummyMenu.DestroyM
}
break;
}
return 0L;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
Yes, it works fine. Thanks MichaelS. It is a good trick.
mike, u have to change ur code as
......
.......
CPoint point;
GetCursorPos(&point);
this->SetForegroundWindow( );
if (pcTaskBarMenu) pcTaskBarMenu->TrackPopupM enu(TPM_LE FTALIGN | TPM_LEFTBUTTON, point.x, point.y, this);
this->PostMessage(NULL,0,0 );
cTaskBarDummyMenu.DestroyM enu();
Thats it. Once again thanks MichaelS.
VinExpert
Yes, it works fine. Thanks MichaelS. It is a good trick.
mike, u have to change ur code as
......
.......
CPoint point;
GetCursorPos(&point);
this->SetForegroundWindow(
if (pcTaskBarMenu) pcTaskBarMenu->TrackPopupM
this->PostMessage(NULL,0,0
cTaskBarDummyMenu.DestroyM
Thats it. Once again thanks MichaelS.
VinExpert
You wellcome.
ASKER
Thanks to you MichaelS
VinExpert