Solved

Custom Minimize Function

Posted on 2004-03-21
2
534 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 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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