473,756 Members | 8,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(o bject sender, System.EventArg s e)
{
if(this.WindowS tate != System.Windows. Forms.FormWindo wState.Normal)
{
this.ShowInTask bar = false;
notifyIcon1.Vis ible = true;
}
}

private void menuItem1_Click (object sender, System.EventArg s e)
{
this.ShowInTask bar = true;
notifyIcon1.Vis ible = false;
this.WindowStat e = System.Windows. Forms.FormWindo wState.Normal;
}
Nov 15 '05 #1
1 1814
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.EventArg s e)
{
this.Show();
this.notifyIcon .Visible = false;
this.WindowStat e = FormWindowState .Normal;
}

private void Form1_Resize(ob ject sender, System.EventArg s e)
{
if (this.WindowSta te == FormWindowState .Minimized)
{
this.notifyIcon .Visible = true;
this.Hide();
}
}

Hope this helps!
Greetings,
timtos.

"Zanthor" <Za*****@hotmai l.com> wrote in message news:d2******** *************** **@posting.goog le.com...
Will Dobbins
http://www.ogcan.com

Appropriate code follows:

private void Form1_Resized(o bject sender, System.EventArg s e)
{
if(this.WindowS tate != System.Windows. Forms.FormWindo wState.Normal)
{
this.ShowInTask bar = false;
notifyIcon1.Vis ible = true;
}
}

private void menuItem1_Click (object sender, System.EventArg s e)
{
this.ShowInTask bar = true;
notifyIcon1.Vis ible = false;
this.WindowStat e = System.Windows. Forms.FormWindo wState.Normal;
}

Nov 15 '05 #2

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

Similar topics

5
7365
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 my mouse. If I don't hover over it to make it disappear and then open the program again, another one is added, resulting in a multiplicity of the icon in the tray. I've even tried setting its Visible property to false, followed by a call to the...
0
1593
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 reference not set to an instance of an object." and then
0
1126
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: ntfSystemInfo.Text = "blahblah" My problem is that it shows only on mouseover.
2
513
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 default. When the default MenuItem is clicked, there is code to no longer show the NotifyIcon. What I feel should happen is when I double-click the NotifyIcon in the system tray, it should perform the default menu item's Click event.
0
3332
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 want it to show the ContextMenu on a left click. This seems to be harder than it should be. I've assigned a click event to the NotifyIcon which it registers, but when I try to use: NotifyIcon1.ContextMenu.Show(Forms.Control control ,...
3
10991
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 like it to display based on the relative position of the tray icon or mouse pointer if possible (whichever method works). Any help would be much appreciated. - Glen
2
2926
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 the menu, it seems to disappear. This only breaks when the context menu is tied to a NotifyIcon - not to any other control. Below is a C# file for a form which should illustrate this (at least it does on my machine!). The same contextmenu is...
12
18338
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 need to display the menu, I would contextMenu.Show(buttonCtrl, new Point(0)). But I can't do this for a notifyIcon because notifyIcons aren't controls. How can I display a contextMenu where the cursor is by command only? -mdb
1
4305
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. From your codes, I think the logical is, every time the Timer's elapsed event fires, we call the Check_For_Version_Update() function. From the Check_For_Version_Update() function, we judge a condition statement, and determine whether to call...
0
9973
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9779
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9645
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8645
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6473
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5247
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.