Results 1 to 8 of 8

Thread: xy-coordinates to lParam

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    51

    Question 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:
    1. PostMessage hwnd, WM_LBUTTONDOWN, 1, lParam
    thanks,
    Quix

  2. #2
    jim mcnamara
    Guest
    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)...............

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    51
    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?

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    51

    resolved

    It works!
    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
    But why do I have to add the y-value both to the LOWORD and HIWORD of lParam?

  5. #5
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752
    Whats this 65535?
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  6. #6

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    51

    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&)

  7. #7
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752
    by the way it's not working for me!!!!!
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  8. #8

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    51
    What is not working?
    Try this:

    VB Code:
    1. 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
    2.  
    3. Public Const WM_LBUTTONDOWN = &H201, _
    4. WM_LBUTTONUP = &H202
    5.  
    6. Sub MouseClick(hwnd as Long, x as Long, y as Long)
    7.   lParam = (y * &H10000) Or (x And &HFFFF&)
    8.   PostMessage hwnd, WM_LBUTTONDOWN, 1, lParam
    9.   PostMessage hwnd, WM_LBUTTONUP, 0, lParam
    10. 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
  •  



Click Here to Expand Forum to Full Width