Results 1 to 5 of 5

Thread: [RESOLVED] can I catch the Maxbutton event?

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Location
    Germany
    Posts
    49

    Resolved [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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: can I catch the Maxbutton event?

    VB Code:
    1. Private Sub Form_Resize()
    2.     If Me.WindowState = vbMaximized Then
    3.         '
    4.     End If
    5. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2005
    Location
    Germany
    Posts
    49

    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...

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. Option Explicit
    2.  
    3. Private Sub Form_Resize()
    4.     If Me.WindowState = vbMaximized Then
    5.         Me.WindowState = vbNormal
    6.         Me.Height = 2000
    7.         Me.Width = 4000
    8.     End If
    9. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2005
    Location
    Germany
    Posts
    49

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width