Minimize To Tray

Trouble Calling NotifyIcon from other forms.

Page 1 of 1

4 Replies - 12506 Views - Last Post: 02 September 2008 - 12:58 PM Rate Topic: -----

#1 CruorAvis   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 22
  • Joined: 02-August 08

Minimize To Tray

Posted 31 August 2008 - 01:30 PM

Ello',

I'm currently working on a program which will provide a quick easy interface to all databases for a small company. Logically i decided to start at the Menu Strip.
The first item in the menu strip under File is Minimize to Tray. So i created a form named frmSystemTray and placed a Notify Icon (ntiSystemTray) in it, declared both as Public. When i go back to the main form frmMain and access the code snippet for the Minimize to Tray menu item and attempt frmSystemTray. i do not get ntiSystemTray in the intellisense menu. I'm receiving an error that reference is required to a non static object though honestly I'm just a beginner and not too sure how to fix this. I actually spent two hours on the phone with my boss today attempting different things but he is more fluent in VB then C#.

 private void frmManagementTracker_Resize(object sender, EventArgs e)
		{
			  if (FormWindowState.Minimized == this.WindowState)
			{
				frmSystemTray.ntiSystemTray.Visible = true;
				frmSystemTray.ntiSystemTray.ShowBalloonTip(500);
				this.Hide();
			}
			else if (FormWindowState.Normal == this.WindowState)
			{
				frmSystemTray.ntiSystemTray.Visible = false;
				}
		}



Any and all help appreciated, Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Minimize To Tray

#2 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1535
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: Minimize To Tray

Posted 31 August 2008 - 02:25 PM

is the Notify Icon on the form that you are trying to minimize? if so, then just use...

this.ntiSystemTray


Was This Post Helpful? 0
  • +
  • -

#3 CruorAvis   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 22
  • Joined: 02-August 08

Re: Minimize To Tray

Posted 31 August 2008 - 02:28 PM

No, its on another form. I'm trying to call it from any form in the project. Though I am starting to wonder if it would be easier to attempt just adding it to every form and using a method defined in a class to call it... Though honestly beyond concept I'm not sure how to go about that.
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1535
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: Minimize To Tray

Posted 31 August 2008 - 02:29 PM

I don't actually know if a Notify Icon from one form will work on another form.
Was This Post Helpful? 0
  • +
  • -

#5 CruorAvis   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 22
  • Joined: 02-August 08

Re: Minimize To Tray

Posted 02 September 2008 - 12:58 PM

We actually managed to solve the problem while working on how the NotifyIcon was going to work (When to send things to a system tray) he suggested we have the parent form be an MDI Parent and just load all forms within that MDI parent.

This way we can simply call the notify icon from the MDI parent which houses everything else. This also can help if your tempted to use Inherited forms to keep the same menustrip and such.

Hope this helps someone else!

Thanks again,
Cru
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1