VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,569 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello, I am trying to make a simple program that I made to test around with in Windows Forms. I am programming in Visual Basic and I am trying to resize the border of the program. Is this possible? Thanks!
Try adding this Sub to your form class:
Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_NCHITTEST = &H84
Const HTCAPTION = 2
Const HTLEFT = 10
Const HTRIGHT = 11
Const HTTOP = 12
Const HTBOTTOM = 15
Select Case m.Msg
Case WM_NCHITTEST
Dim p = New Point(m.LParam.ToInt32)
Dim r = Me.Bounds
Dim b = New Size(10, 10) ' or SystemInformation.FrameBorderSize '
If p.X <= r.Left + b.Width Then
m.Result = New IntPtr(HTLEFT)
ElseIf p.X >= r.Right - b.Width Then
m.Result = New IntPtr(HTRIGHT)
ElseIf p.Y <= r.Top + b.Height Then
m.Result = New IntPtr(HTTOP)
ElseIf p.Y >= r.Bottom - b.Height Then
m.Result = New IntPtr(HTBOTTOM)
Else
m.Result = New IntPtr(HTCAPTION)
End If
Case Else
MyBase.WndProc(m)
End Select
End Sub
You can improve it to allow diagonal resizing.