I've got a form where I've removed the title bar but kept the border (see this answer).
In the above answer it's stated that it's required to have the FormBorderStyle
set to Sizable
or SizableToolWindow
, and in order to stop the form from being sizable you'd trap the WM_NCHITTEST event. The only problem being that doing so will make it not raise the normal Form_MouseEnter
or Form_MouseLeave
events.
Is there any workaround to this?
My code:
Protected Overrides Sub WndProc(ByRef message As Message)
If message.Msg = &H84 Then 'WM_NCHITTEST
Me.Focus() 'Focus the form when it receives a click.
Return
End If
MyBase.WndProc(message)
End Sub
Private Sub PanelForm_MouseLeave(sender As Object, e As System.EventArgs) Handles PanelForm.MouseLeave
PlaceOnScreen(False) 'Placed a breakpoint here, it won't execute.
End Sub