I may be mistaken but I suspect that the difference is that
vb 2015
programs will be consistent with the
Windows 10
styling, including the larger title bar. Whereas
vb 2010
programs will be accessing older libraries and their styling is therefore consistent with Windows prior to
Win 10
.
You could therefore hide the title bar and replace it with a user control that has the height that you need. If you also nee the functionality of the title bar (Minimise, Maximise, Move the window, Exit etc. then you'd have to add that functionality back in with your own controls.
1. Remove the window title bar by setting the `FormBorderStyle` property of your form to `None`. This will remove the title bar along with the minimize, maximize, and close buttons.
2. Create custom buttons and use the appropriate methods to minimize, maximize, and close the form. To move the window, you can handle the `MouseDown`, `MouseMove`, and `MouseUp` events.
3. This is a very low quality example just to show how it works, you'd need to do it more seriously if you go down this route. For instance, you might want to add checks to ensure the form doesn't move off-screen. Also, consider the user experience when designing your custom title bar, as it will not behave exactly like a standard title bar. For example, double-clicking to maximize will not work unless you implement it yourself.
Public Class Form1
Dim drag As Boolean
Dim mousex As Integer
Dim mousey As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown
drag = True
mousex = Windows.Forms.Cursor.Position.X - Me.Left
mousey = Windows.Forms.Cursor.Position.Y - Me.Top
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles MyBase.MouseMove
If drag Then
Me.Top = Windows.Forms.Cursor.Position.Y - mousey
Me.Left = Windows.Forms.Cursor.Position.X - mousex
End If
End Sub
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles MyBase.MouseUp
drag = False
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Private Sub btnMaximize_Click(sender As Object, e As EventArgs) Handles btnMaximize.Click
If Me.WindowState = FormWindowState.Normal Then
Me.WindowState = FormWindowState.Maximized
Else
Me.WindowState = FormWindowState.Normal
End If
End Sub
Private Sub btnMinimize_Click(sender As Object, e As EventArgs) Handles btnMinimize.Click
Me.WindowState = FormWindowState.Minimized
End Sub
End Class
4. `btnClose`, `btnMaximize`, and `btnMinimize` are your custom buttons for closing, maximizing, and minimizing the form, respectively. You'll need to add these buttons to your form and wire up the `Click` events.
5. The `Form1_MouseDown`, `Form1_MouseMove`, and `Form1_MouseUp` methods handle moving the form when the user clicks and drags the form. The `drag` variable is used to track whether the form should be moving.