ش | ی | د | س | چ | پ | ج |
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 |
WM_INITMENUPOPUP=&H117
WM_RBUTTONDOWN=&H204
TPM_LEFTBUTTON = 0
TPM_RIGHTBUTTON = 2
TPM_LEFTALIGN = 0
TPM_CENTERALIGN = 4
TPM_RIGHTALIGN = 8
TPM_TOPALIGN = 0
TPM_VCENTERALIGN = 16
TPM_BOTTOMALIGN = 32
TPM_HORIZONTAL = 0
TPM_VERTICAL = 64
MF_BYCOMMAND = 0
MF_BYPOSITION = 1024
MF_SEPARATOR = 2048
MF_ENABLED = 0
MF_GRAYED = 1
MF_DISABLED = 2
MF_STRING = 0
MF_BITMAP = 4
MF_POPUP = 16
MF_UNHILITE = 0
MF_HILITE = 128
MF_SYSMENU = 8192
MF_HELP = 16384
MF_RIGHTJUSTIFY = 16384
Public Function WndProc
Case WM_RBUTTONDOWN
hMenuPopUp = CreatePopupMenu
"AppendMenuA hMenuPopUp, MF_STRING, IDM_CONTEXT_LINE, "Line
"AppendMenuA hMenuPopUp, MF_STRING, IDM_CONTEXT_RECTAN, "Rectangle
" AppendMenuA hMenuPopUp, MF_STRING, IDM_CONTEXT_CIRCLE, "Circle
AppendMenuA hMenuPopUp, MF_SEPARATOR, 0, vbNullString
"AppendMenuA hMenuPopUp, MF_STRING, IDM_CONTEXT_HELP, "Help
&EnableMenuItem hMenuPopUp, 1000, 1
TrackPopupMenu hMenuPopUp, TPM_RIGHTALIGN + TPM_RIGHTBUTTON, pt.x, pt.y, 0, lhwnd, rc
برای تغییر LayOut پاپ آپ منو باید از مسیج WM_INITMENUPOPUP و کلاس آن که 32768# است و با تابع FindWindowA میتوان هندل آن را بدست آورد استفاده کرد ، برای اینکه درجایی که کرسر هست بازشود باید از تابع GetCursorPos بهره برد و x و y آنرا در Track گذاشت .
case WM_RBUTTONDOWN:
HMENU hPopupMenu = CreatePopupMenu();InsertMenu(hPopupMenu, 0, MF_BYPOSITION + MF_STRING, ID_CLOSE, L"Exit");InsertMenu(hPopupMenu, 0, MF_BYPOSITION + MF_STRING, ID_EXIT, L"Play");SetForegroundWindow(hWnd);TrackPopupMenu(hPopupMenu, TPM_BOTTOMALIGN + TPM_LEFTALIGN, 0, 0, 0, hWnd, NULL);![]()