Welcome to Dream.In.Code
Become a C# Expert!

Join 150,163 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,369 people online right now. Registration is fast and FREE... Join Now!




Minimize To Tray

 
Reply to this topicStart new topic

Minimize To Tray, Trouble Calling NotifyIcon from other forms.

CruorAvis
31 Aug, 2008 - 12:30 PM
Post #1

New D.I.C Head
*

Joined: 2 Aug, 2008
Posts: 17

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#.

CODE

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.


User is offlineProfile CardPM
+Quote Post

eclipsed4utoo
RE: Minimize To Tray
31 Aug, 2008 - 01:25 PM
Post #2

D.I.C Addict
Group Icon

Joined: 21 Mar, 2008
Posts: 544



Thanked: 29 times
Dream Kudos: 125
My Contributions
is the Notify Icon on the form that you are trying to minimize? if so, then just use...

CODE

this.ntiSystemTray

User is offlineProfile CardPM
+Quote Post

CruorAvis
RE: Minimize To Tray
31 Aug, 2008 - 01:28 PM
Post #3

New D.I.C Head
*

Joined: 2 Aug, 2008
Posts: 17

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.
User is offlineProfile CardPM
+Quote Post

eclipsed4utoo
RE: Minimize To Tray
31 Aug, 2008 - 01:29 PM
Post #4

D.I.C Addict
Group Icon

Joined: 21 Mar, 2008
Posts: 544



Thanked: 29 times
Dream Kudos: 125
My Contributions
I don't actually know if a Notify Icon from one form will work on another form.
User is offlineProfile CardPM
+Quote Post

CruorAvis
RE: Minimize To Tray
2 Sep, 2008 - 11:58 AM
Post #5

New D.I.C Head
*

Joined: 2 Aug, 2008
Posts: 17

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
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:49AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month