|
|
Title | Let the user resize a form that has no title bar or borders in Visual Basic .NET |
Description | This example shows how to let the user resize a form that has no title bar or borders in Visual Basic .NET. |
Keywords | resize form, title bar, WM_NCLBUTTONDOWN, HTCAPTION, SendMessage, DefWndProc, VB.NET |
Categories | API, VB.NET |
|
|
When the user presses the left mouse button down on the lblResize control, the MouseDown event handler executes. It sets the control's Capture property to False to release the mouse capture that was started by pressing the mouse button down.
Next the program makes a Message with message WM_NCLBUTTONDOWN and wParam set to HTBOTTOMRIGHT, and calls the form's DefWndProc method to process the message. This is the same message Windows sends to the form when the user presses the mouse down over the lower right corner of the form's border so it starts a form resize.
|
|
' On left button, let the user resize the form.
Private Sub lblResize_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles _
lblResize.MouseDown
If e.Button = MouseButtons.Left Then
lblResize.Capture = False
' Create and send a WM_NCLBUTTONDOWN message.
Const WM_NCLBUTTONDOWN As Integer = &HA1S
Const HTBOTTOMRIGHT As Integer = 17
Dim msg As Message = _
Message.Create(Me.Handle, WM_NCLBUTTONDOWN, _
New IntPtr(HTBOTTOMRIGHT), IntPtr.Zero)
Me.DefWndProc(msg)
End If
End Sub
|
|
|
|
|
|