Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21238

SubClassing mouse coordinates

$
0
0
I just started playing a bit with SubClassing form/control.

I was wondering which way is the best to get the mouse X and Y coordinates?

I currently use this for code
Code:

'This code is in a Module
'After I SubClass a Form/Control...

Public Function GET_Y_LPARAM(ByVal lParam As Long) As Long
  Dim HexStr As String
  HexStr = Right("00000000" & Hex(lParam), 8)
  GET_Y_LPARAM = CLng("&H" & Left(HexStr, 4))
End Function

Public Function GET_X_LPARAM(ByVal lParam As Long) As Long
  Dim HexStr As String
  HexStr = Right("00000000" & Hex(lParam), 8)
  GET_X_LPARAM = CLng("&H" & Right(HexStr, 4))
End Function

Public Function MyWindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  If uMsg = WM_MOUSEMOVE Then Debug.Print "X: " & GET_X_LPARAM(lParam) & " - Y: " & GET_Y_LPARAM(lParam)
  MyWindowProc = CallWindowProc(PrevWndProc, hw, uMsg, wParam, lParam)
End Function

This is working great, however would this be a good way to get the X/Y?
Would you suggest something else?

I can have a look around and find information i know but i like to know what people think about it.

Viewing all articles
Browse latest Browse all 21238

Trending Articles