Results 1 to 20 of 20

Thread: capture the minimize event?

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    capture the minimize event?

    Is there a way to capture the minimize event and do something before it minimizes?

    (I want to fade out the form...which I have code for)
    Last edited by Static; Sep 22nd, 2005 at 12:05 PM.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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

    Re: capture the minimize event?

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Resize()
    4.     If Me.WindowState = vbMinimized Then
    5.         'do domething
    6.     End If
    7. 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
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: capture the minimize event?

    That would be after the fact, Rob, and what he wants is "before"...
    As the easiest solution you might want to create your own titlebar (search through my posts for a sample project) so you can fully control what happends.

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

    Re: capture the minimize event?

    Then he will have to subclass the form and catch the WM_WINDOWPOSCHANGING or WM_SYSCOMMAND.
    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

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

    Re: capture the minimize event?

    I double checked and the SW is a Show Window constant and not a Window Message Then WM designates the window messages.
    There is no WM_MINIMIZE message so it should be either capturing the click of the minimize button/menu item or capture the WM_POSITIONCHANGING and parse out the parameters for the type or direction of the change?
    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

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

    Re: capture the minimize event?

    Ok, I did a quick test and it is the WM_SYSCOMMAND message that gets the initial call when the user clicks on any button on the system menu or title bar buttons. The wParam contains the SC_MINIMIZE or &HF020& value. This is when to trap and handle your fading for optimum effeciency.

    Note, the lParam contains the x and y form location values.
    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

  8. #8

  9. #9

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: capture the minimize event?

    wow! a missed a ton just during lunch! lol

    hmm.. Im thinking the easiest thing would be to create my own titlebar.. I already have enoungh subclassing going on I dont want to add even more

    Thanks for the suggestions!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] capture the minimize event?

    I'd like to revisit what RobDog888 initialially posted. While RhinoBull is correct that the resize event would be "after the fact", I think that because of the reason you want to capture it, it might actually be a kind of cool affect and it wouldn't involve subclassing. Try this and see what you think
    VB Code:
    1. Private Sub Form_Resize()
    2. If Me.WindowState = vbMinimized Then
    3.    Me.WindowState = vbNormal
    4.    'call fade out routine
    5. End If
    6. End Sub

  11. #11

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: capture the minimize event?

    oops.. I jumped the gun. I cant use my own titlebar.. I need the menus and the form needs to be resized.. so its back to subclassing. (of which I suck at)

    so, i will be needing some direction.
    What API's to use... etc... Thanks all!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  12. #12

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: capture the minimize event?

    thanks hack.. will try
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  13. #13

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: capture the minimize event?

    well...
    VB Code:
    1. Static Faded As Boolean
    2. If Me.WindowState = vbMinimized Then
    3.     If Not Faded Then
    4.         Me.WindowState = vbNormal
    5.         Dim iX As Long
    6.         For iX = 255 To 0 Step -5
    7.             SetWindowTrans Me.hWnd, iX
    8.         Next
    9.         Faded = True
    10.         Me.WindowState = vbMinimized
    11.     End If
    12.     Faded = False
    13.     If mnuMinToTray.Checked = True Then Call GoSystemTray
    14.     Exit Sub
    15. End If

    works.. but the window flashes noticably when it re-sets to vbNormal..
    tried Lockwindowupdate but to no avail....
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: capture the minimize event?

    Quote Originally Posted by [A51g]Static
    well...
    VB Code:
    1. Static Faded As Boolean
    2. If Me.WindowState = vbMinimized Then
    3.     If Not Faded Then
    4.         Me.WindowState = vbNormal
    5.         Dim iX As Long
    6.         For iX = 255 To 0 Step -5
    7.             SetWindowTrans Me.hWnd, iX
    8.         Next
    9.         Faded = True
    10.         Me.WindowState = vbMinimized
    11.     End If
    12.     Faded = False
    13.     If mnuMinToTray.Checked = True Then Call GoSystemTray
    14.     Exit Sub
    15. End If

    works.. but the window flashes noticably when it re-sets to vbNormal..
    tried Lockwindowupdate but to no avail....
    Well, it doesn't flash it goes to the systray and pops back up. That is what I thought would be a kind of cool effect to precede your fadout routine. If you don't like it, then you can toss the whole idea. *shrugs*

  15. #15

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: capture the minimize event?

    I have the app fade in on start up, fade in on return from systray.. and fade out on close.

    I just want to fade out on min to the systray
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  16. #16
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: capture the minimize event?

    Quote Originally Posted by [A51g]Static
    oops.. I jumped the gun. I cant use my own titlebar.. I need the menus and the form needs to be resized.. ...
    You can have menus with your very own titlebar: the trick is to set form's Caption to empty string and ControlBox to False. And BTW form could still be resiable too.

    Have a fun!

  17. #17

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: capture the minimize event?

    well arent you the smart one! lol

    now how do I put a "titlebar" of my own above the menu?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  18. #18

  19. #19

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: capture the minimize event?

    Cool rhino.. will check that out!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  20. #20

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