You might try something like this:
Structure POINTS
Public x As Integer
Public y As Integer
End Structure
Const WM_NCMOUSEMOVE As Integer = &HA0
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = NCMOUSEMOVE Then
Dim xPos As Short = GetLoWord(m.LParam.ToInt32)
Dim yPos As Short = GetHiWord(m.LParam.ToInt32)
End If
MyBase.WndProc(m)
End Sub
Private Function GetLoWord(ByVal lngWord As Integer) As Short
If CBool(lngWord And &H8000) Then
Return CShort(&H8000 Or (lngWord And &H7FFF))
Else
Return CShort(lngWord And &HFFFF)
End If
End Function
Private Function GetHiWord(ByVal lngWord As Integer) As Short
If CBool(lngWord And &H80000000) Then
Return CShort((lngWord \ 65535) - 1)
Else
Return CShort(lngWord \ 65535)
End If
End Function
Stefan
"crafuse" <vo*********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hello,
I've overridden the WndProc function in my form to hand some special
behavior. Specifically, I look for the WM_NCMOUSEMOVE event to tell me
when the user is trying to move the window by draggin the title bar.
However, I am having trouble extracting the POINT structure that is
supposed to come with the message. For example:
Structure POINTS
Public x As Short
Public y As Short
End Structure
...
IF m.Msg = WM_NCMOUSEMOVE Then
Dim mousePos as New POINTS =
System.Runtime.Interopservices.Marshal.PtrToStruct ure(m.LParam,
GetType(POINTS))
...
End If
I continually receive a Null assignment exception. Is there a
diff/proper way to extact the POINTS struct that is supposed to come
with the System.Windows.Forms.Message structure?