- This topic explains about, how to resize form when form has no borders to drag in VB programming.
Resize form when form has no border in VB – Working
- When you press the left mouse button down on the form, 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.
Control.MouseDown Event – Resize form when form has no border in VB
- Control.MouseDown Event occurs when the mouse pointer is over the control and a mouse button is pressed.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
WM_NCLBUTTONDOWN message (Windows) – Resize form when form has no border in VB
- Message posted when the user presses the left mouse button while the cursor is within the non client area of a window.
- This message is posted to the window that contains the cursor.
- If a window has captured the mouse, this message is not posted.
- If an application processes this message, it will return zero.
- The hit-test value returned by the DefWindowProc function as a result of processing the WM_NCHITTEST message. For a list of hit-test values, see WM_NCHITTEST.
- A POINTS structure that contains the x- and y-coordinates of the cursor. The coordinates are relative to the upper-left corner of the screen.
- More refer: Microsoft
Resize form when form has no border in VB – Complete Code
- Write below code inside Mouse Down event of a form.
Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Left Then
Me.Capture = False
' Create and send a WM_NCLBUTTONDOWN message.
Const Button_down As Integer = &HA1S
Const frame_bottom As Integer = 17
Dim msg As Message = _
Message.Create(Me.Handle, Button_down, _
New IntPtr(frame_bottom), IntPtr.Zero)
Resize form when form has no border in VB
If you have any suggestions or doubts regarding this topic, please contact us…