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)
Printable View
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)
:DVB Code:
Option Explicit Private Sub Form_Resize() If Me.WindowState = vbMinimized Then 'do domething End If End Sub
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.
Then he will have to subclass the form and catch the WM_WINDOWPOSCHANGING or WM_SYSCOMMAND.
Subclassing/Hooking could be another way (and perhaps better) but I'm not sure what message would that be - it could be SW_SHOWMINIMIZED but as I said "not sure"...
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?
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.
There is also WM_COMMAND (= &H111) message as well so you need to try either.
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!
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 thinkVB Code:
Private Sub Form_Resize() If Me.WindowState = vbMinimized Then Me.WindowState = vbNormal 'call fade out routine End If End Sub
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!
thanks hack.. will try
well...
VB Code:
Static Faded As Boolean If Me.WindowState = vbMinimized Then If Not Faded Then Me.WindowState = vbNormal Dim iX As Long For iX = 255 To 0 Step -5 SetWindowTrans Me.hWnd, iX Next Faded = True Me.WindowState = vbMinimized End If Faded = False If mnuMinToTray.Checked = True Then Call GoSystemTray Exit Sub 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*Quote:
Originally Posted by [A51g]Static
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
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.Quote:
Originally Posted by [A51g]Static
Have a fun! :wave:
well arent you the smart one! lol
now how do I put a "titlebar" of my own above the menu? ;)
Check this article from vbAccelerator.
Cool rhino.. will check that out!
:wave: :thumb: