1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| afx_msg LRESULT CCamSetupDlg::OnTrayNotify(WPARAM wParam, LPARAM lParam)
{
if ((UINT)wParam != 1)
return 0 ;
POINT pt;
CMenu myMenu;
int nCmd;
switch (lParam)
{
case WM_RBUTTONDOWN:
case WM_CONTEXTMENU:
//ici
SetForegroundWindow();
GetCursorPos(&pt);
// myMenu.LoadMenuA(IDR_MENU1);
myMenu.CreatePopupMenu();
myMenu.InsertMenuA(0,MF_BYPOSITION|MF_STRING,1,_T("Exit"));
nCmd = myMenu.TrackPopupMenu(TPM_RETURNCMD|TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RIGHTALIGN,
pt.x, pt.y, this);
//et la
PostMessage(WM_NULL, 0, 0);
if (nCmd >0)
{
CString str;
myMenu.GetMenuStringA(nCmd, str, MF_BYCOMMAND);
if (str == _T("Exit"))
AfxGetMainWnd()->PostMessage(WM_SYSCOMMAND,SC_CLOSE,0);
}
break;
case WM_LBUTTONDBLCLK:
this->ShowWindow(SW_RESTORE);
break;
/*case WM_DISPLAYCHANGE:
myMenu.*/
}
return 0;
} |
Partager