Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Custom Minimize Function

Posted on 2004-03-21
2
Medium Priority
?
547 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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