|
-
Jan 16th, 2002, 07:53 PM
#1
Thread Starter
Member
xy-coordinates to lParam
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 .
VB Code:
PostMessage hwnd, WM_LBUTTONDOWN, 1, lParam
thanks,
Quix
-
Jan 16th, 2002, 09:59 PM
#2
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)...............
-
Jan 17th, 2002, 05:53 AM
#3
Thread Starter
Member
Thanks for your reply, but it doesn't work
I was using this code:
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
But then the coordiantes are sent as follows:
xPos:-2804, yPos:18 (see MS-Spy++)
Btw does anybody know what is the wParam for?
-
Jan 17th, 2002, 06:23 AM
#4
Thread Starter
Member
-
Jan 21st, 2002, 09:11 AM
#5
Fanatic Member
-
Jan 22nd, 2002, 09:20 AM
#6
Thread Starter
Member
Resolved
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&)
-
Jan 22nd, 2002, 09:22 AM
#7
Fanatic Member
-
Jan 23rd, 2002, 10:15 AM
#8
Thread Starter
Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|