J
James Arnold
I currently have a borderless form, which I am subclassing to allow
dragging & dropping:
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case 132 'Click & Drag Form
m.Result = New IntPtr(2)
'Continue message
MyBase.WndProc(m)
End Select
End Sub
This works fine, but it also removes any processing of MouseEvents on
the form. A little background; Msg 132 is WM_NCHITTEST, which works
out which area of the window is being clicked. By settings the result
to 2 you are telling it you are clicking a caption, so it allows the
drag & drop. However, it overrides too much, making the following code
no longer executed:
Private Sub frmMain_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
MsgBox("Clicky!")
End Sub
I have tried without using subclassing, using the MouseDown and
MouseMove events and manually calculating the offset. This worked, but
I also am using subclassing to snap the form to the screen edges and
dragging will not work once the window is snapped.
My question is, how can I allow dragging & dropping of the borderless
form, without overriding the click events (to pop up a context menu
etc)? Thanks (again!)
James
dragging & dropping:
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case 132 'Click & Drag Form
m.Result = New IntPtr(2)
'Continue message
MyBase.WndProc(m)
End Select
End Sub
This works fine, but it also removes any processing of MouseEvents on
the form. A little background; Msg 132 is WM_NCHITTEST, which works
out which area of the window is being clicked. By settings the result
to 2 you are telling it you are clicking a caption, so it allows the
drag & drop. However, it overrides too much, making the following code
no longer executed:
Private Sub frmMain_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
MsgBox("Clicky!")
End Sub
I have tried without using subclassing, using the MouseDown and
MouseMove events and manually calculating the offset. This worked, but
I also am using subclassing to snap the form to the screen edges and
dragging will not work once the window is snapped.
My question is, how can I allow dragging & dropping of the borderless
form, without overriding the click events (to pop up a context menu
etc)? Thanks (again!)
James