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
|
case IconMessage:
MyTree.Load("MenuFile.txt");
if (lParam == WM_RBUTTONDOWN)
{
std::cout<<"It's a right click."<<std::endl;
}
else if (lParam == WM_LBUTTONDOWN)
{
HMENU myMenu = CreatePopupMenu();
HMENU nextLevel = CreatePopupMenu();
AppendMenu(myMenu, MF_STRING, 3, TEXT("I'm a menu item"));
AppendMenu(myMenu, MF_STRING, (UINT_PTR)nextLevel, TEXT("NextLevel"));
AppendMenu(nextLevel, MF_STRING, 4, TEXT("More menu items"));
AppendMenu(nextLevel, MF_STRING, 5, TEXT("Even more menu items"));
}
break;
case WM_COMMAND:
switch (LOWORD(wParam) )
{
case 3:
//break;
case 4:
//break;
case 5:
std::cout<<"got a menu click"<<std::endl;
break;
default:
RECT uselessArg = {0};
POINT cursorPos;
GetCursorPos(&cursorPos);
TrackPopupMenu(((HMENU) LOWORD(wParam)), TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON|TPM_RECURSE, cursorPos.x, cursorPos.y, 0, hwnd, &uselessArg);
}
|