I was just wondering how to make a 'Restore' button in my Form? But changes from Maximized to Restore on the button?
-
Which version of VB? VB 6? VB.NET? VBScript? Office VBA? – Cody Gray - on strike Aug 20 '14 at 08:03
-
Possible duplicate of http://stackoverflow.com/questions/354445/restore-windowstate-from-minimized – MansoorShaikh Aug 20 '14 at 08:08
-
I am using Visual Studio 2013, is that VB 6? I am not sure because I am new to it all. – GregRogers Aug 20 '14 at 08:14
-
No, VB 6 was introduced in 1998. Visual Studio 2013 comes with VB.NET, version 13. There are a lot of versions of VB, though, so it's important to put these kinds of details in your question. – Cody Gray - on strike Aug 20 '14 at 08:25
2 Answers
In the standard Windows user interface, the maximize and restore button are one-in-the-same. They are both controlled by the center button in a group of three buttons
In a normal, non-maximized window, the center button is a "box" shape, and clicking on it causes the window to be maximized:
In a maximized window, the center button changes to display stacked tiles, and clicking on it restores the window to a non-maximized state:
In other words, the center "Maximize" button is a toggle. The only option with a maximized window is to restore it, and the only option with a normal window is to maximize it. You can never maximize a maximized window, and you can never restore a normal, non-maximized window. As such, having individual buttons for this would be a waste of real estate. They'd just sit there perpetually grayed out.
So setting the form's MaximizeBox
property to True is what you want to do. You can do this either in the Properties Window in the designer, or using code in the form class's New
method:
Me.MaximizeBox = True
If you really wanted to have a fourth button, you'd have to take over drawing the window's title bar yourself. Which is a really big job, probably not one that you're up for, since you indicate in a comment that you're new to VB.NET. And most of the work will have little to do with VB.NET and more to do with Win32 programming. Unless you're already an expert Win32 programmer migrating over to VB.NET as a new language, you will want to settle for the default behavior. And things got even worse for developers trying to customize the title bar starting with Windows Vista—the Aero Glass effect does not lend itself well to being customized. I don't know how things behave with Windows 8, but I doubt it's gotten any easier. If you're really interested in this, you can find plenty of information online, even in questions here on Stack Overflow (for example, here, here, and here).
And honestly, even if you were an expert Win32 programmer, I'd say you should settle for the default behavior anyway. Even if you don't think it's ideal, it is what your users are accustomed to. All of the other applications on their system behave this way.

- 1
- 1

- 239,200
- 50
- 490
- 574
Okay, i'm not an expert but try this (VB NET 2013). Create a button and insert the code bellow:
Private Sub btnMaximize_Click(sender As Object, e As EventArgs)
Handles btnMaximize.Click
btnMaximize.Image = Image.FromFile("C:\Resources\ResbtnRestore.png")
If Me.WindowState = FormWindowState.Maximized Then
Me.WindowState = FormWindowState.Normal
btnMaximize.Image = Image.FromFile("C:\Resources\ResbtnMaximize.png")
Else
Me.WindowState = FormWindowState.Maximized
End If
End Sub
btnMaximize is your current button caption.
to Make it Perfect, set your button properties to:
ButtonStyle = UltraFlat
[+] Image= C:\Resources\ResbtnMaximize.png (Import new file)
Image Location: MiddleCenter
Text = (Fill Blank/No Text)
[+] Behavior
AllowFocus = False
[+] Layout
Anchor = Top, Right
Then Resize your button to fit the image and move the button top right. Also you need to create transparent image first (.png) or download from inet at least.

- 31
- 2
-
-
Okay @G.Samaras. Also dont forget to make Winform Borderless : No Tittle Bar (Text), No Icon, No ControlBox. – Farid Rudiansyah May 20 '15 at 09:02