ش | ی | د | س | چ | پ | ج |
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 |
برای 32 بیت :
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim a As POINTAPI
از رویداد OnTimer استفاده میشود تا در هر لحظه تغییر مختصات ماوس در Screen گرفته شود.
GetCursorPos a
Label1.Caption="X:" & a.x & ";Y:" & a.y
When running in 64-bit versions of Office, Declare statements must include the PtrSafe keyword. The PtrSafe keyword asserts that a Declare statement is safe to run in 64-bit development environments. Adding the PtrSafe keyword to a Declare statement only signifies that the Declare statement explicitly targets 64-bits.
وقتی در نسخه 64 بیت اجرا می شود.عبارات اظهارشده می بایست شامل کلیدواژه ی PtrSafe باشد.در عبارات زیر مشاهده می کنید که PtrSafe در کجا بکاربرده شده و در ضمن بجای تایپ داده Long از LongLong یا LongPtr استفاده شود.
[ Public | Private ] Declare PtrSafe Function name Lib "libname" [ Alias "aliasname" ] [ ( [ arglist ] ) ] [ As type ]
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);![]()