Search code examples
vb.netsendmessagewndproc

Get Position from WM_LBUTTONDOWN SendMessage


I would like to get the x, y position from the Params when the WM_LBUTTONDOWN is sent in vb.net.

I got this to make the param but how do I get the position from it.

IntPtr lParam = (IntPtr)((y << 16) | x);

My function:

Protected Overrides Sub WndProc(ByRef m As Message)
  Select Case m.Msg
    Case WM_LBUTTONDOWN

      'Get the X, Y from m.lparam

    Case Else
      MyBase.WndProc(m)
  End Select
End Sub

Update: I just tried this and it works perfectly.

Dim pos As New System.Drawing.Point(CInt(m.LParam))

Solution

  • I just tried this and it works perfectly.

    Dim pos As New System.Drawing.Point(CInt(m.LParam))