[RESOLVED] can I catch the Maxbutton event?
Hi there! First of all, this what I'm trying to do:
- I take the main form of my application, there's a command button to minimize/resize the form so there are only a toolbar-style form left.
- After switching to this toolbar mode, the user can switch back to maximized mode by clicking again on the button.
- o.k., this works so far. I've handled lots of the max/min/etc stuff by setting and removing maxbutton properties, so that there are no control box buttons in toolbar-mode.
- Now the Problem is: Application opens maximized, before i first click the toolbar button i can change between maximized size and - well - medium size (like half-sized). The user may not resize the form except by using maxbutton to switch between the two sizes. Now, if i change the form to toolbar and back, the new stored sizes on maxbutton are maximized and the size of the toolbar.
How can I catch the click event on the maxbutton, so I can set the form sizes myself? Or can I change these sizes anywhere?
Thanks for your time & help!
eugen
Re: can I catch the Maxbutton event?
VB Code:
Private Sub Form_Resize()
If Me.WindowState = vbMaximized Then
'
End If
End Sub
:)
Re: can I catch the Maxbutton event?
Thx for the quick reply! This line only defines what happens when the window maximizes, does it? I'd like to change the size when the form is changed to medium size...
Re: can I catch the Maxbutton event?
You need to restore the window to the normal window state so you can resize it.
VB Code:
Option Explicit
Private Sub Form_Resize()
If Me.WindowState = vbMaximized Then
Me.WindowState = vbNormal
Me.Height = 2000
Me.Width = 4000
End If
End Sub
Re: can I catch the Maxbutton event?
Thanks again, found my error now. I used the wrong vbwindowstate cause I understood that one wrong. I was using the state I was leaving instead of the state I'm going to. Thanks for posting the code, thought it was exactly may stuff till I realized I messed up the windowstates. Further, I had to add a boolean that tells the application if it's in toolbar-mode, cause the i change the form to vbNormal when I turn it into a toolbar. Thx for quickly handling this!