Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: Mangix on October 06, 2005, 11:42 PM

Title: Minimizing Forms
Post by: Mangix on October 06, 2005, 11:42 PM
does a form have an Event that fires exactly when the form gets minimized? i've looked at each event and i dont think im finding what im looking for.
Title: Re: Minimizing Forms
Post by: MyndFyre on October 09, 2005, 12:04 AM
No.  You can intercept it, however, by overriding WndProc (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclasswndproctopic.asp) and handling WM_SYSCOMMAND (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardaccelerators/keyboardacceleratorreference/keyboardacceleratormessages/wm_syscommand.asp) -- specifically, the SC_MINIMIZE command contained in wParam.

Example code: .NETskinEx (http://www.jinxbot.net/netskinex/netskinex.zip)'s /Controls/NCForm implements this in the form of the protected virtual function OnMinimized (http://www.jinxbot.net/netskinex/NetSkinEx.Controls.NCForm.OnMinimized.html).
Title: Re: Minimizing Forms
Post by: Mangix on October 09, 2005, 01:05 AM
mmk

also your NetSkinEx program is very neat :)

edit:ok it doesnt work. it compiles fine but when i run it, it crashes on start. here's the message.

QuoteApplication has generated an exception that could not be handled.

Process id=0x938 (2360), Thread id=0xc94 (3220).

Click OK to terminate the application.
Click CANCEL to debug the application.

my code is this. protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 274:
if (m.Msg == 0xF020)
{
this.Visible = false;
}
break;
}
}
i took a look at WinUser.h and WM_SYSCOMMAND is 274