|
-
Aug 7th, 2007, 08:00 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Hide on minmize
Hi all
I'm finishing up a small personnel project and I'm having some trouble with the "showintaskbar= false" property of the form

as you can see when is the show in task bar to false it does indeed not show up in the task bar but i get a "mdi" ish minimized window right above the task bar.
to get around this i tried making a sub called "open_close"
c# Code:
private void open_close()
{
if (WindowState != FormWindowState.Normal)
{
Show();
WindowState = FormWindowState.Normal;
}
else
{
Hide();
WindowState = FormWindowState.Minimized;
}
}
The open_close is triggered by either a double click on the notifyicon1 or a form1 resize
The problem i am running into two problems as side effects
1) since there is no way i know of to capture the specific form minimize event i can only use form resize so if i resize the form manually (using the mouse) i still get the same event triggering as if i hit minimize
2) the form still blinks down at the bottom before it hides so its a little distracting.
so my questions is:
Is there a better way to intercept the minimize button on the for???
-
Aug 8th, 2007, 12:41 AM
#2
Re: Hide on minmize
Handle the SizeChanged event.
-
Aug 8th, 2007, 05:40 PM
#3
Thread Starter
Fanatic Member
Re: Hide on minmize
 Originally Posted by jmcilhinney
Handle the SizeChanged event.
this is what I have, the problem if i resize the form ( make it wider or smaller by grabbing the border) it triggers the same event as if i hit the minimize button.
private void Form1_SizeChanged(object sender, EventArgs e)
{
open_close();
}
-
Aug 8th, 2007, 06:02 PM
#4
Re: Hide on minmize
I didn't say that you weren't supposed to test the WindowState property. It's really very simple:
C# Code:
private void Form1_SizeChanged(object sender, EventArgs e)
{
this.Visible = (this.WindowState != FormWindowState.Minimized);
}
Now if the form is minimise it is not visible and if it's not minimised it is visible. If you want the form restored when the user double-clicks the tray icon then you simply set the WindowState to Normal in the DoubleClick event handler of the NotifyIcon. That will cause the SizeChanged event to be raised and that will cause the visiblity of the form to change.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|