-3

I was just wondering how to make a 'Restore' button in my Form? But changes from Maximized to Restore on the button?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
GregRogers
  • 13
  • 1
  • 6

2 Answers2

1

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.

Community
  • 1
  • 1
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
1

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.