The below code to detect MouseDown and MouseUp events works great for regular forms, but I would like to have it work for forms created programmatically at runtime. Could someone tweak it? :)
Code:
Const WM_NCMOUSEMOVE As Long = &HA0
Const WM_NCLBUTTONDOWN As Long = &HA1
Const WM_NCLBUTTONUP As Long = &HA2
Private IsMouseDown As Boolean
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_NCLBUTTONDOWN
Debug.WriteLine("Down")
IsMouseDown = True
Case WM_NCLBUTTONUP
Debug.WriteLine("Up")
Case WM_NCMOUSEMOVE
If IsMouseDown Then
Debug.WriteLine("Fake Up")
IsMouseDown = False
End If
End Select
MyBase.WndProc(m)
End Sub