?
Solved

Custom Minimize Function

Posted on 2004-03-21
2
Medium Priority
?
540 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
eternal_21 earned 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 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