Solved

Custom Minimize Function

Posted on 2004-03-21
2
500 Views
Last Modified: 2008-02-26
Hi,

I'm added a System tray icon to my C# application and I'm wanting to change the minimize function so that when the minimize button in clicked, only the System Tray icon is left, and the usual tab shown in the task bar is not shown until the application is restored.  How do I do this?

Many Thanks
0
Comment
Question by:Memorix
2 Comments
 
LVL 10

Accepted Solution

by:
eternal_21 earned 125 total points
Comment Utility
Here is a simple way to do it (althought you could easily expand on this implementation, keeping track of the previous window state to avoid always calling the ShowInTaskbar setter method, for example).

In your form class place the following code:

  protected override void OnSizeChanged(System.EventArgs e)
  {
    if(this.WindowState==System.Windows.Forms.FormWindowState.Minimized)
      this.ShowInTaskbar = false;
    else
      this.ShowInTaskbar = true;
    base.OnSizeChanged(e);
  }

This will hide your form on the taskbar when it gets minimized.  To restore your form call the code, "this.WindowState = System.Windows.Forms.FormWindowState.Normal".  The taskbar tab will be visible again.
0
 
LVL 3

Author Comment

by:Memorix
Comment Utility
Simple is good for me... and it works a treat

Many thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now