Solved

Custom Minimize Function

Posted on 2004-03-21
2
528 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
ID: 10646739
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
ID: 10648806
Simple is good for me... and it works a treat

Many thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 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