Hi,
how can I convert xy-coordinates to the lParam-value used in PostMessage?
It must be something like lParam = y*&HFFFF+x, but this doesn't work:confused:.thanks,VB Code:
PostMessage hwnd, WM_LBUTTONDOWN, 1, lParam
Quix
Printable View
Hi,
how can I convert xy-coordinates to the lParam-value used in PostMessage?
It must be something like lParam = y*&HFFFF+x, but this doesn't work:confused:.thanks,VB Code:
PostMessage hwnd, WM_LBUTTONDOWN, 1, lParam
Quix
Pass the lParam as a PointAPI UDT.
Code:' code fragment WILL NOT WORK....
Public Type POINTAPI
x As Long
y As Long
End Type
.........................
Dim MyThing as PointAPI
SendMessage hWnd, WM_WHATEVER, VarPtr(MyThing)...............
Thanks for your reply, but it doesn't work :(
I was using this code:But then the coordiantes are sent as follows:Code:Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_Click()
Dim lpPoint As POINTAPI
lpPoint.x = 100
lpPoint.y = 40
PostMessage Me.hwnd, WM_LBUTTONDOWN, 1, VarPtr(lpPoint)
PostMessage Me.hwnd, WM_LBUTTONUP, 0, VarPtr(lpPoint)
End Sub
xPos:-2804, yPos:18 (see MS-Spy++)
Btw does anybody know what is the wParam for?
It works! :DBut why do I have to add the y-value both to the LOWORD and HIWORD of lParam? :confused::confused:Code:Private Sub Command1_Click()
Dim lParam As Long, _
x As Long, y As Long
x = 10
y = 80
lParam = y * 65535 + x + y
PostMessage Me.hwnd, WM_LBUTTONDOWN, 1, lParam
PostMessage Me.hwnd, WM_LBUTTONUP, 0, lParam
End Sub
Whats this 65535?
65535 is the hex-value &HFFFF.
It's to create a DWORD of the LOWORD and HIWORD-values.
Finally I'm using this code:Code:lParam = (y * &H10000) Or (x And &HFFFF&)
by the way it's not working for me!!!!!
What is not working?
Try this:
VB Code:
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Const WM_LBUTTONDOWN = &H201, _ WM_LBUTTONUP = &H202 Sub MouseClick(hwnd as Long, x as Long, y as Long) lParam = (y * &H10000) Or (x And &HFFFF&) PostMessage hwnd, WM_LBUTTONDOWN, 1, lParam PostMessage hwnd, WM_LBUTTONUP, 0, lParam End Sub
This code simulates a mouseclick on the window with the handle hwnd at the position x,y.