473,378 Members | 1,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

notifyIcon question...

Ok, I've got a small App I'm trying to make minimize to the system
tray...

The behavior I'm after is that while the forms FormWindowState is
Normal I want the form visible in the taskbar, when it's not normal
(I've disabled maximize, so the only other state is minimized) I want
it to be not visible on the taskbar but visible in the system tray.

My notifyIcon has a menu setup to restore the window, and the whole
thing works just peachy as long as I do NOT toggle the forms visible
in taskbar property.

Once I start modifying the visible in taskbar, the form appears off
screen when you restore it. Right now I'm working off two events for
hiding and showing the form... the resized event and the context menu
being clicked...

Am I doing something to cause the bloody form to slide offscreen, and
if this is as it's supposed to behave, how would you go about
detecting where the window was before it was moved, and putting it
back there on the restore?

Thanks...

Will Dobbins
http://www.ogcan.com

Appropriate code follows:

private void Form1_Resized(object sender, System.EventArgs e)
{
if(this.WindowState != System.Windows.Forms.FormWindowState.Normal)
{
this.ShowInTaskbar = false;
notifyIcon1.Visible = true;
}
}

private void menuItem1_Click(object sender, System.EventArgs e)
{
this.ShowInTaskbar = true;
notifyIcon1.Visible = false;
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
}
Nov 15 '05 #1
1 1801
You have to do it in the right order to let it work properly.
But I think it is the best to just donīt use the ShownInTaskbar property.
Just turn the window invisible - then it is also invisible in the taskbar ;-)

Something like this:

private void menuItem1_Click(object sender, System.EventArgs e)
{
this.Show();
this.notifyIcon.Visible = false;
this.WindowState = FormWindowState.Normal;
}

private void Form1_Resize(object sender, System.EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.notifyIcon.Visible = true;
this.Hide();
}
}

Hope this helps!
Greetings,
timtos.

"Zanthor" <Za*****@hotmail.com> wrote in message news:d2*************************@posting.google.co m...
Will Dobbins
http://www.ogcan.com

Appropriate code follows:

private void Form1_Resized(object sender, System.EventArgs e)
{
if(this.WindowState != System.Windows.Forms.FormWindowState.Normal)
{
this.ShowInTaskbar = false;
notifyIcon1.Visible = true;
}
}

private void menuItem1_Click(object sender, System.EventArgs e)
{
this.ShowInTaskbar = true;
notifyIcon1.Visible = false;
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
}

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Phil Galey | last post by:
VB.NET 2002 on Windows 2000 SP 3 When I start my program, the NotifyIcon appears in the tray, as it should. However, when I close the program, the NotifyIcon remains until I hover over it with...
0
by: petterl | last post by:
I have tried to find the error in the code below but I always get " An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. Additional information: Object...
0
by: martin.lanny | last post by:
Hi all, I've got notifyicon (ntfSystemInfo) component on my form. It's basically a system tray icon. Whenever user puts his mouse over this icon it shows a textspecified with this command: ...
2
by: Rob Mayo | last post by:
OK, maybe this is my opinion, maybe these are bugs. Given the folowing: I have a NotifyIcon on my Form, a Context menu associated with the NotifyIcon, and a MenuItem on the ContextMenu set as...
0
by: Mike Allen | last post by:
Hi Everyone, My problem concerns ContextMenus. It's easy enough to create one and apply it to a NotifyIcon. When it's compiled and run, it works beautifully. Right click and there you are. But I...
3
by: Glen | last post by:
Can anyone tell me if there is a workable method to get the mouse cursor position on the screen or the NotifyIcon position? I need to display a context menu for the NotifyIcon when clicked and I'd...
2
by: Derrick | last post by:
I've been working on an application which has a NotifyIcon (system tray icon), and a corresponding ContextMenu. I want to be able to update this menu dynamically. However, when I make changes to...
12
by: mdb | last post by:
My app has a notify icon in the systray. I want the left mouse click to initiate a menu, and a right-mouse click to do something else. Normally, for a button, I would listen to MouseDown and if I...
1
by: \Ji Zhou [MSFT]\ | last post by:
Hello Jason, Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou and I will be working on this issue with you. I have tried to but cannot reproduce your issue on my side....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.