Tray Icon Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zeljko

    #1

    Tray Icon Problem

    Hi,

    I have a form with a tray icon. However, when I minimize the form, it
    stays visible - not in the task bar (I have showintaskbar property set
    to false), but in a form of a rectangle sitting above the task bar.
    Can't figure out why that happens - it looks very ugly...

    Any ideas ?

    Zeljko
  • Brian W

    #2
    Re: Tray Icon Problem

    When you minimize the form you must also set the Visible property to false

    this.Visible = false;


    HTH
    Brian W


    "Zeljko" <trashbox4@yaho o.com> wrote in message
    news:0dgkrvcv7l 1l5vtoa8c3rtlad kjsgg4kg4@4ax.c om...[color=blue]
    > Hi,
    >
    > I have a form with a tray icon. However, when I minimize the form, it
    > stays visible - not in the task bar (I have showintaskbar property set
    > to false), but in a form of a rectangle sitting above the task bar.
    > Can't figure out why that happens - it looks very ugly...
    >
    > Any ideas ?
    >
    > Zeljko[/color]


    Comment

    • Zeljko

      #3
      Re: Tray Icon Problem

      But If I do that, I don't see tray icon anymore and can't maximize the
      form again ?

      Zeljko
      On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
      <brianw@gold_de ath_2_spam_rush .com> wrote:
      [color=blue]
      >When you minimize the form you must also set the Visible property to false
      >
      > this.Visible = false;
      >
      >
      >HTH
      >Brian W
      >
      >
      >"Zeljko" <trashbox4@yaho o.com> wrote in message
      >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...[color=green]
      >> Hi,
      >>
      >> I have a form with a tray icon. However, when I minimize the form, it
      >> stays visible - not in the task bar (I have showintaskbar property set
      >> to false), but in a form of a rectangle sitting above the task bar.
      >> Can't figure out why that happens - it looks very ugly...
      >>
      >> Any ideas ?
      >>
      >> Zeljko[/color]
      >[/color]

      Comment

      • Brian W

        #4
        Re: Tray Icon Problem

        No, it won't, the tray icon remains visible. Have you tried?

        You restore the form in response to a click on the icon.



        "Zeljko" <trashbox4@yaho o.com> wrote in message
        news:nhjkrv4vhg q3ss3nm5lag8c78 kbjtqq4d8@4ax.c om...[color=blue]
        > But If I do that, I don't see tray icon anymore and can't maximize the
        > form again ?
        >
        > Zeljko
        > On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
        > <brianw@gold_de ath_2_spam_rush .com> wrote:
        >[color=green]
        > >When you minimize the form you must also set the Visible property to[/color][/color]
        false[color=blue][color=green]
        > >
        > > this.Visible = false;
        > >
        > >
        > >HTH
        > >Brian W
        > >
        > >
        > >"Zeljko" <trashbox4@yaho o.com> wrote in message
        > >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...[color=darkred]
        > >> Hi,
        > >>
        > >> I have a form with a tray icon. However, when I minimize the form, it
        > >> stays visible - not in the task bar (I have showintaskbar property set
        > >> to false), but in a form of a rectangle sitting above the task bar.
        > >> Can't figure out why that happens - it looks very ugly...
        > >>
        > >> Any ideas ?
        > >>
        > >> Zeljko[/color]
        > >[/color]
        >[/color]


        Comment

        • Zeljko

          #5
          Re: Tray Icon Problem

          Yes, I have tried. tray icon becomes invisible, and there is nothing I
          can click on to make it visible again.

          Zeljko
          On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
          <brianw@gold_de ath_2_spam_rush .com> wrote:
          [color=blue]
          >No, it won't, the tray icon remains visible. Have you tried?
          >
          >You restore the form in response to a click on the icon.
          >
          >
          >
          >"Zeljko" <trashbox4@yaho o.com> wrote in message
          >news:nhjkrv4vh gq3ss3nm5lag8c7 8kbjtqq4d8@4ax. com...[color=green]
          >> But If I do that, I don't see tray icon anymore and can't maximize the
          >> form again ?
          >>
          >> Zeljko
          >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
          >> <brianw@gold_de ath_2_spam_rush .com> wrote:
          >>[color=darkred]
          >> >When you minimize the form you must also set the Visible property to[/color][/color]
          >false[color=green][color=darkred]
          >> >
          >> > this.Visible = false;
          >> >
          >> >
          >> >HTH
          >> >Brian W
          >> >
          >> >
          >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
          >> >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...
          >> >> Hi,
          >> >>
          >> >> I have a form with a tray icon. However, when I minimize the form, it
          >> >> stays visible - not in the task bar (I have showintaskbar property set
          >> >> to false), but in a form of a rectangle sitting above the task bar.
          >> >> Can't figure out why that happens - it looks very ugly...
          >> >>
          >> >> Any ideas ?
          >> >>
          >> >> Zeljko
          >> >[/color]
          >>[/color]
          >[/color]

          Comment

          • Brian W

            #6
            Re: Tray Icon Problem

            This technique has always worked for me, and is working here now. Have you
            assigned an Icon to the icon property of your notifyicon object.

            Can you post a small, complete example that reproduces this behavior?


            Regards
            Brian W



            "Zeljko" <trashbox4@yaho o.com> wrote in message
            news:46lkrvc03u bmmlpl7vdh54uuh 6l0tkkl3m@4ax.c om...[color=blue]
            > Yes, I have tried. tray icon becomes invisible, and there is nothing I
            > can click on to make it visible again.
            >
            > Zeljko
            > On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
            > <brianw@gold_de ath_2_spam_rush .com> wrote:
            >[color=green]
            > >No, it won't, the tray icon remains visible. Have you tried?
            > >
            > >You restore the form in response to a click on the icon.
            > >
            > >
            > >
            > >"Zeljko" <trashbox4@yaho o.com> wrote in message
            > >news:nhjkrv4vh gq3ss3nm5lag8c7 8kbjtqq4d8@4ax. com...[color=darkred]
            > >> But If I do that, I don't see tray icon anymore and can't maximize the
            > >> form again ?
            > >>
            > >> Zeljko
            > >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
            > >> <brianw@gold_de ath_2_spam_rush .com> wrote:
            > >>
            > >> >When you minimize the form you must also set the Visible property to[/color]
            > >false[color=darkred]
            > >> >
            > >> > this.Visible = false;
            > >> >
            > >> >
            > >> >HTH
            > >> >Brian W
            > >> >
            > >> >
            > >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
            > >> >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...
            > >> >> Hi,
            > >> >>
            > >> >> I have a form with a tray icon. However, when I minimize the form,[/color][/color][/color]
            it[color=blue][color=green][color=darkred]
            > >> >> stays visible - not in the task bar (I have showintaskbar property[/color][/color][/color]
            set[color=blue][color=green][color=darkred]
            > >> >> to false), but in a form of a rectangle sitting above the task bar.
            > >> >> Can't figure out why that happens - it looks very ugly...
            > >> >>
            > >> >> Any ideas ?
            > >> >>
            > >> >> Zeljko
            > >> >
            > >>[/color]
            > >[/color]
            >[/color]


            Comment

            • Zeljko

              #7
              Re: Tray Icon Problem

              Sure - here it is:

              public Form1()
              {
              //
              // Required for Windows Form Designer support
              //
              InitializeCompo nent();
              //PENDING_ICON etc are string constants - I added 3 icons to
              the app, changing current notify icon based on the status of a windows
              service
              micoPending = new Icon(typeof(For m1), PENDING_ICON);
              micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
              micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);

              }

              protected override void OnLayout(Layout EventArgs levent)
              {

              switch (WindowState){
              case FormWindowState .Minimized:
              this.WindowStat e = FormWindowState .Minimized;
              this.Hide();
              break;
              case FormWindowState .Maximized:
              this.WindowStat e = FormWindowState .Normal;
              this.Show();
              this.Activate() ;
              break;
              }
              base.OnLayout (levent);
              }






              On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
              <brianw@gold_de ath_2_spam_rush .com> wrote:
              [color=blue]
              >This technique has always worked for me, and is working here now. Have you
              >assigned an Icon to the icon property of your notifyicon object.
              >
              >Can you post a small, complete example that reproduces this behavior?
              >
              >
              >Regards
              >Brian W
              >
              >
              >
              >"Zeljko" <trashbox4@yaho o.com> wrote in message
              >news:46lkrvc03 ubmmlpl7vdh54uu h6l0tkkl3m@4ax. com...[color=green]
              >> Yes, I have tried. tray icon becomes invisible, and there is nothing I
              >> can click on to make it visible again.
              >>
              >> Zeljko
              >> On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
              >> <brianw@gold_de ath_2_spam_rush .com> wrote:
              >>[color=darkred]
              >> >No, it won't, the tray icon remains visible. Have you tried?
              >> >
              >> >You restore the form in response to a click on the icon.
              >> >
              >> >
              >> >
              >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
              >> >news:nhjkrv4vh gq3ss3nm5lag8c7 8kbjtqq4d8@4ax. com...
              >> >> But If I do that, I don't see tray icon anymore and can't maximize the
              >> >> form again ?
              >> >>
              >> >> Zeljko
              >> >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
              >> >> <brianw@gold_de ath_2_spam_rush .com> wrote:
              >> >>
              >> >> >When you minimize the form you must also set the Visible property to
              >> >false
              >> >> >
              >> >> > this.Visible = false;
              >> >> >
              >> >> >
              >> >> >HTH
              >> >> >Brian W
              >> >> >
              >> >> >
              >> >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
              >> >> >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...
              >> >> >> Hi,
              >> >> >>
              >> >> >> I have a form with a tray icon. However, when I minimize the form,[/color][/color]
              >it[color=green][color=darkred]
              >> >> >> stays visible - not in the task bar (I have showintaskbar property[/color][/color]
              >set[color=green][color=darkred]
              >> >> >> to false), but in a form of a rectangle sitting above the task bar.
              >> >> >> Can't figure out why that happens - it looks very ugly...
              >> >> >>
              >> >> >> Any ideas ?
              >> >> >>
              >> >> >> Zeljko
              >> >> >
              >> >>
              >> >[/color]
              >>[/color]
              >[/color]

              Comment

              • Brian W

                #8
                Re: Tray Icon Problem

                Sorry, this is not complete, for example it does not show me what is going
                on in InitializeCompo nent(), and does not show me what you are doing with
                micoPending, micoRunning & micoStopped. The example also does not show me
                how you are responding to either the Click or DoubleClick events of the
                NotifyIcon object. For that matter it doesn't show that you even have a
                TrayIcon object.

                With all that said, if I add your code to mine the window minimizes and
                hides with the tray icon still visible. So I'm sorry to say it still works
                for me here.

                Paste the following code as your form make sure you assign an icon to the
                NotifyIcon object, then tell me if this works for you.


                Regards
                Brian W

                public class Form1 : System.Windows. Forms.Form

                {

                private System.Windows. Forms.NotifyIco n notifyIcon1;

                private System.Componen tModel.IContain er components;

                public Form1()

                {

                //

                // Required for Windows Form Designer support

                //

                InitializeCompo nent();

                // TODO: Add any constructor code after InitializeCompo nent call

                //

                }

                /// <summary>

                /// Clean up any resources being used.

                /// </summary>

                protected override void Dispose( bool disposing )

                {

                if( disposing )

                {

                if (components != null)

                {

                components.Disp ose();

                }

                }

                base.Dispose( disposing );

                }

                #region Windows Form Designer generated code

                /// <summary>

                /// Required method for Designer support - do not modify

                /// the contents of this method with the code editor.

                /// </summary>

                private void InitializeCompo nent()

                {

                this.components = new System.Componen tModel.Containe r();

                System.Resource s.ResourceManag er resources = new
                System.Resource s.ResourceManag er(typeof(Form1 ));

                this.notifyIcon 1 = new System.Windows. Forms.NotifyIco n(this.componen ts);

                //

                // notifyIcon1

                //

                this.notifyIcon 1.Icon =
                ((System.Drawin g.Icon)(resourc es.GetObject("n otifyIcon1.Icon ")));

                this.notifyIcon 1.Text = "notifyIcon 1";

                this.notifyIcon 1.Visible = true;

                this.notifyIcon 1.DoubleClick += new
                System.EventHan dler(this.notif yIcon1_DoubleCl ick);

                //

                // Form1

                //

                this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);

                this.ClientSize = new System.Drawing. Size(292, 266);

                this.Name = "Form1";

                this.Text = "Form1";

                this.SizeChange d += new System.EventHan dler(this.Form1 _SizeChanged);

                }

                #endregion

                /// <summary>

                /// The main entry point for the application.

                /// </summary>

                [STAThread]

                static void Main()

                {

                Application.Run (new Form1());

                }

                private void Form1_SizeChang ed(object sender, System.EventArg s e)

                {

                if ( this.WindowStat e == FormWindowState .Minimized )

                this.Hide();

                else

                this.Show();

                }

                private void notifyIcon1_Dou bleClick(object sender, System.EventArg s e)

                {

                this.Show();

                }

                }





                "Zeljko" <trashbox4@yaho o.com> wrote in message
                news:pufmrv86hq 4ps3i3niodr5a0u r36sjvkpd@4ax.c om...[color=blue]
                > Sure - here it is:
                >
                > public Form1()
                > {
                > //
                > // Required for Windows Form Designer support
                > //
                > InitializeCompo nent();
                > //PENDING_ICON etc are string constants - I added 3 icons to
                > the app, changing current notify icon based on the status of a windows
                > service
                > micoPending = new Icon(typeof(For m1), PENDING_ICON);
                > micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
                > micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);
                >
                > }
                >
                > protected override void OnLayout(Layout EventArgs levent)
                > {
                >
                > switch (WindowState){
                > case FormWindowState .Minimized:
                > this.WindowStat e = FormWindowState .Minimized;
                > this.Hide();
                > break;
                > case FormWindowState .Maximized:
                > this.WindowStat e = FormWindowState .Normal;
                > this.Show();
                > this.Activate() ;
                > break;
                > }
                > base.OnLayout (levent);
                > }
                >
                >
                >
                >
                >
                >
                > On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
                > <brianw@gold_de ath_2_spam_rush .com> wrote:
                >[color=green]
                > >This technique has always worked for me, and is working here now. Have[/color][/color]
                you[color=blue][color=green]
                > >assigned an Icon to the icon property of your notifyicon object.
                > >
                > >Can you post a small, complete example that reproduces this behavior?
                > >
                > >
                > >Regards
                > >Brian W
                > >
                > >
                > >
                > >"Zeljko" <trashbox4@yaho o.com> wrote in message
                > >news:46lkrvc03 ubmmlpl7vdh54uu h6l0tkkl3m@4ax. com...[color=darkred]
                > >> Yes, I have tried. tray icon becomes invisible, and there is nothing I
                > >> can click on to make it visible again.
                > >>
                > >> Zeljko
                > >> On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
                > >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                > >>
                > >> >No, it won't, the tray icon remains visible. Have you tried?
                > >> >
                > >> >You restore the form in response to a click on the icon.
                > >> >
                > >> >
                > >> >
                > >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                > >> >news:nhjkrv4vh gq3ss3nm5lag8c7 8kbjtqq4d8@4ax. com...
                > >> >> But If I do that, I don't see tray icon anymore and can't maximize[/color][/color][/color]
                the[color=blue][color=green][color=darkred]
                > >> >> form again ?
                > >> >>
                > >> >> Zeljko
                > >> >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
                > >> >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                > >> >>
                > >> >> >When you minimize the form you must also set the Visible property[/color][/color][/color]
                to[color=blue][color=green][color=darkred]
                > >> >false
                > >> >> >
                > >> >> > this.Visible = false;
                > >> >> >
                > >> >> >
                > >> >> >HTH
                > >> >> >Brian W
                > >> >> >
                > >> >> >
                > >> >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                > >> >> >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...
                > >> >> >> Hi,
                > >> >> >>
                > >> >> >> I have a form with a tray icon. However, when I minimize the[/color][/color][/color]
                form,[color=blue][color=green]
                > >it[color=darkred]
                > >> >> >> stays visible - not in the task bar (I have showintaskbar[/color][/color][/color]
                property[color=blue][color=green]
                > >set[color=darkred]
                > >> >> >> to false), but in a form of a rectangle sitting above the task[/color][/color][/color]
                bar.[color=blue][color=green][color=darkred]
                > >> >> >> Can't figure out why that happens - it looks very ugly...
                > >> >> >>
                > >> >> >> Any ideas ?
                > >> >> >>
                > >> >> >> Zeljko
                > >> >> >
                > >> >>
                > >> >
                > >>[/color]
                > >[/color]
                >[/color]


                Comment

                • Zeljko

                  #9
                  Re: Tray Icon Problem

                  Hi,

                  Sorry if this code was incomplete - I left out only the obvious things
                  - setting icon property of notify icon to one of the 3 icons,
                  generated code in Initializecompo nent etc.

                  Anyhow - in the meantime, I solved the problem by moving my hide /
                  minimize code from Layout to Resize event. For some reason it works
                  that way :)

                  I'm not sure why it didn't work before - if u have any ideas, I'd be
                  interested in hearing them :)

                  Zeljko

                  On Wed, 19 Nov 2003 10:23:41 -0800, "Brian W"
                  <brianw@gold_de ath_2_spam_rush .com> wrote:
                  [color=blue]
                  >Sorry, this is not complete, for example it does not show me what is going
                  >on in InitializeCompo nent(), and does not show me what you are doing with
                  >micoPending, micoRunning & micoStopped. The example also does not show me
                  >how you are responding to either the Click or DoubleClick events of the
                  >NotifyIcon object. For that matter it doesn't show that you even have a
                  >TrayIcon object.
                  >
                  >With all that said, if I add your code to mine the window minimizes and
                  >hides with the tray icon still visible. So I'm sorry to say it still works
                  >for me here.
                  >
                  >Paste the following code as your form make sure you assign an icon to the
                  >NotifyIcon object, then tell me if this works for you.
                  >
                  >
                  >Regards
                  >Brian W
                  >
                  >public class Form1 : System.Windows. Forms.Form
                  >
                  >{
                  >
                  >private System.Windows. Forms.NotifyIco n notifyIcon1;
                  >
                  >private System.Componen tModel.IContain er components;
                  >
                  >public Form1()
                  >
                  >{
                  >
                  >//
                  >
                  >// Required for Windows Form Designer support
                  >
                  >//
                  >
                  >InitializeComp onent();
                  >
                  >// TODO: Add any constructor code after InitializeCompo nent call
                  >
                  >//
                  >
                  >}
                  >
                  >/// <summary>
                  >
                  >/// Clean up any resources being used.
                  >
                  >/// </summary>
                  >
                  >protected override void Dispose( bool disposing )
                  >
                  >{
                  >
                  >if( disposing )
                  >
                  >{
                  >
                  >if (components != null)
                  >
                  >{
                  >
                  >components.Dis pose();
                  >
                  >}
                  >
                  >}
                  >
                  >base.Dispose ( disposing );
                  >
                  >}
                  >
                  >#region Windows Form Designer generated code
                  >
                  >/// <summary>
                  >
                  >/// Required method for Designer support - do not modify
                  >
                  >/// the contents of this method with the code editor.
                  >
                  >/// </summary>
                  >
                  >private void InitializeCompo nent()
                  >
                  >{
                  >
                  >this.component s = new System.Componen tModel.Containe r();
                  >
                  >System.Resourc es.ResourceMana ger resources = new
                  >System.Resourc es.ResourceMana ger(typeof(Form 1));
                  >
                  >this.notifyIco n1 = new System.Windows. Forms.NotifyIco n(this.componen ts);
                  >
                  >//
                  >
                  >// notifyIcon1
                  >
                  >//
                  >
                  >this.notifyIco n1.Icon =
                  >((System.Drawi ng.Icon)(resour ces.GetObject(" notifyIcon1.Ico n")));
                  >
                  >this.notifyIco n1.Text = "notifyIcon 1";
                  >
                  >this.notifyIco n1.Visible = true;
                  >
                  >this.notifyIco n1.DoubleClick += new
                  >System.EventHa ndler(this.noti fyIcon1_DoubleC lick);
                  >
                  >//
                  >
                  >// Form1
                  >
                  >//
                  >
                  >this.AutoScale BaseSize = new System.Drawing. Size(5, 13);
                  >
                  >this.ClientSiz e = new System.Drawing. Size(292, 266);
                  >
                  >this.Name = "Form1";
                  >
                  >this.Text = "Form1";
                  >
                  >this.SizeChang ed += new System.EventHan dler(this.Form1 _SizeChanged);
                  >
                  >}
                  >
                  >#endregion
                  >
                  >/// <summary>
                  >
                  >/// The main entry point for the application.
                  >
                  >/// </summary>
                  >
                  >[STAThread]
                  >
                  >static void Main()
                  >
                  >{
                  >
                  >Application.Ru n(new Form1());
                  >
                  >}
                  >
                  >private void Form1_SizeChang ed(object sender, System.EventArg s e)
                  >
                  >{
                  >
                  >if ( this.WindowStat e == FormWindowState .Minimized )
                  >
                  >this.Hide();
                  >
                  >else
                  >
                  >this.Show();
                  >
                  >}
                  >
                  >private void notifyIcon1_Dou bleClick(object sender, System.EventArg s e)
                  >
                  >{
                  >
                  >this.Show();
                  >
                  >}
                  >
                  >}
                  >
                  >
                  >
                  >
                  >
                  >"Zeljko" <trashbox4@yaho o.com> wrote in message
                  >news:pufmrv86h q4ps3i3niodr5a0 ur36sjvkpd@4ax. com...[color=green]
                  >> Sure - here it is:
                  >>
                  >> public Form1()
                  >> {
                  >> //
                  >> // Required for Windows Form Designer support
                  >> //
                  >> InitializeCompo nent();
                  >> //PENDING_ICON etc are string constants - I added 3 icons to
                  >> the app, changing current notify icon based on the status of a windows
                  >> service
                  >> micoPending = new Icon(typeof(For m1), PENDING_ICON);
                  >> micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
                  >> micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);
                  >>
                  >> }
                  >>
                  >> protected override void OnLayout(Layout EventArgs levent)
                  >> {
                  >>
                  >> switch (WindowState){
                  >> case FormWindowState .Minimized:
                  >> this.WindowStat e = FormWindowState .Minimized;
                  >> this.Hide();
                  >> break;
                  >> case FormWindowState .Maximized:
                  >> this.WindowStat e = FormWindowState .Normal;
                  >> this.Show();
                  >> this.Activate() ;
                  >> break;
                  >> }
                  >> base.OnLayout (levent);
                  >> }
                  >>
                  >>
                  >>
                  >>
                  >>
                  >>
                  >> On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
                  >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                  >>[color=darkred]
                  >> >This technique has always worked for me, and is working here now. Have[/color][/color]
                  >you[color=green][color=darkred]
                  >> >assigned an Icon to the icon property of your notifyicon object.
                  >> >
                  >> >Can you post a small, complete example that reproduces this behavior?
                  >> >
                  >> >
                  >> >Regards
                  >> >Brian W
                  >> >
                  >> >
                  >> >
                  >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                  >> >news:46lkrvc03 ubmmlpl7vdh54uu h6l0tkkl3m@4ax. com...
                  >> >> Yes, I have tried. tray icon becomes invisible, and there is nothing I
                  >> >> can click on to make it visible again.
                  >> >>
                  >> >> Zeljko
                  >> >> On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
                  >> >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                  >> >>
                  >> >> >No, it won't, the tray icon remains visible. Have you tried?
                  >> >> >
                  >> >> >You restore the form in response to a click on the icon.
                  >> >> >
                  >> >> >
                  >> >> >
                  >> >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                  >> >> >news:nhjkrv4vh gq3ss3nm5lag8c7 8kbjtqq4d8@4ax. com...
                  >> >> >> But If I do that, I don't see tray icon anymore and can't maximize[/color][/color]
                  >the[color=green][color=darkred]
                  >> >> >> form again ?
                  >> >> >>
                  >> >> >> Zeljko
                  >> >> >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
                  >> >> >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                  >> >> >>
                  >> >> >> >When you minimize the form you must also set the Visible property[/color][/color]
                  >to[color=green][color=darkred]
                  >> >> >false
                  >> >> >> >
                  >> >> >> > this.Visible = false;
                  >> >> >> >
                  >> >> >> >
                  >> >> >> >HTH
                  >> >> >> >Brian W
                  >> >> >> >
                  >> >> >> >
                  >> >> >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                  >> >> >> >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...
                  >> >> >> >> Hi,
                  >> >> >> >>
                  >> >> >> >> I have a form with a tray icon. However, when I minimize the[/color][/color]
                  >form,[color=green][color=darkred]
                  >> >it
                  >> >> >> >> stays visible - not in the task bar (I have showintaskbar[/color][/color]
                  >property[color=green][color=darkred]
                  >> >set
                  >> >> >> >> to false), but in a form of a rectangle sitting above the task[/color][/color]
                  >bar.[color=green][color=darkred]
                  >> >> >> >> Can't figure out why that happens - it looks very ugly...
                  >> >> >> >>
                  >> >> >> >> Any ideas ?
                  >> >> >> >>
                  >> >> >> >> Zeljko
                  >> >> >> >
                  >> >> >>
                  >> >> >
                  >> >>
                  >> >[/color]
                  >>[/color]
                  >[/color]

                  Comment

                  • Lou

                    #10
                    Re: Tray Icon Problem

                    How do you assign an icon?


                    "Brian W" <brianw@gold_de ath_2_spam_rush .com> wrote in message
                    news:OgV2EpsrDH A.1760@TK2MSFTN GP10.phx.gbl...[color=blue]
                    > Sorry, this is not complete, for example it does not show me what is going
                    > on in InitializeCompo nent(), and does not show me what you are doing with
                    > micoPending, micoRunning & micoStopped. The example also does not show me
                    > how you are responding to either the Click or DoubleClick events of the
                    > NotifyIcon object. For that matter it doesn't show that you even have a
                    > TrayIcon object.
                    >
                    > With all that said, if I add your code to mine the window minimizes and
                    > hides with the tray icon still visible. So I'm sorry to say it still works
                    > for me here.
                    >
                    > Paste the following code as your form make sure you assign an icon to the
                    > NotifyIcon object, then tell me if this works for you.
                    >
                    >
                    > Regards
                    > Brian W
                    >
                    > public class Form1 : System.Windows. Forms.Form
                    >
                    > {
                    >
                    > private System.Windows. Forms.NotifyIco n notifyIcon1;
                    >
                    > private System.Componen tModel.IContain er components;
                    >
                    > public Form1()
                    >
                    > {
                    >
                    > //
                    >
                    > // Required for Windows Form Designer support
                    >
                    > //
                    >
                    > InitializeCompo nent();
                    >
                    > // TODO: Add any constructor code after InitializeCompo nent call
                    >
                    > //
                    >
                    > }
                    >
                    > /// <summary>
                    >
                    > /// Clean up any resources being used.
                    >
                    > /// </summary>
                    >
                    > protected override void Dispose( bool disposing )
                    >
                    > {
                    >
                    > if( disposing )
                    >
                    > {
                    >
                    > if (components != null)
                    >
                    > {
                    >
                    > components.Disp ose();
                    >
                    > }
                    >
                    > }
                    >
                    > base.Dispose( disposing );
                    >
                    > }
                    >
                    > #region Windows Form Designer generated code
                    >
                    > /// <summary>
                    >
                    > /// Required method for Designer support - do not modify
                    >
                    > /// the contents of this method with the code editor.
                    >
                    > /// </summary>
                    >
                    > private void InitializeCompo nent()
                    >
                    > {
                    >
                    > this.components = new System.Componen tModel.Containe r();
                    >
                    > System.Resource s.ResourceManag er resources = new
                    > System.Resource s.ResourceManag er(typeof(Form1 ));
                    >
                    > this.notifyIcon 1 = new System.Windows. Forms.NotifyIco n(this.componen ts);
                    >
                    > //
                    >
                    > // notifyIcon1
                    >
                    > //
                    >
                    > this.notifyIcon 1.Icon =
                    > ((System.Drawin g.Icon)(resourc es.GetObject("n otifyIcon1.Icon ")));
                    >
                    > this.notifyIcon 1.Text = "notifyIcon 1";
                    >
                    > this.notifyIcon 1.Visible = true;
                    >
                    > this.notifyIcon 1.DoubleClick += new
                    > System.EventHan dler(this.notif yIcon1_DoubleCl ick);
                    >
                    > //
                    >
                    > // Form1
                    >
                    > //
                    >
                    > this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
                    >
                    > this.ClientSize = new System.Drawing. Size(292, 266);
                    >
                    > this.Name = "Form1";
                    >
                    > this.Text = "Form1";
                    >
                    > this.SizeChange d += new System.EventHan dler(this.Form1 _SizeChanged);
                    >
                    > }
                    >
                    > #endregion
                    >
                    > /// <summary>
                    >
                    > /// The main entry point for the application.
                    >
                    > /// </summary>
                    >
                    > [STAThread]
                    >
                    > static void Main()
                    >
                    > {
                    >
                    > Application.Run (new Form1());
                    >
                    > }
                    >
                    > private void Form1_SizeChang ed(object sender, System.EventArg s e)
                    >
                    > {
                    >
                    > if ( this.WindowStat e == FormWindowState .Minimized )
                    >
                    > this.Hide();
                    >
                    > else
                    >
                    > this.Show();
                    >
                    > }
                    >
                    > private void notifyIcon1_Dou bleClick(object sender, System.EventArg s e)
                    >
                    > {
                    >
                    > this.Show();
                    >
                    > }
                    >
                    > }
                    >
                    >
                    >
                    >
                    >
                    > "Zeljko" <trashbox4@yaho o.com> wrote in message
                    > news:pufmrv86hq 4ps3i3niodr5a0u r36sjvkpd@4ax.c om...[color=green]
                    > > Sure - here it is:
                    > >
                    > > public Form1()
                    > > {
                    > > //
                    > > // Required for Windows Form Designer support
                    > > //
                    > > InitializeCompo nent();
                    > > //PENDING_ICON etc are string constants - I added 3 icons to
                    > > the app, changing current notify icon based on the status of a windows
                    > > service
                    > > micoPending = new Icon(typeof(For m1), PENDING_ICON);
                    > > micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
                    > > micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);
                    > >
                    > > }
                    > >
                    > > protected override void OnLayout(Layout EventArgs levent)
                    > > {
                    > >
                    > > switch (WindowState){
                    > > case FormWindowState .Minimized:
                    > > this.WindowStat e = FormWindowState .Minimized;
                    > > this.Hide();
                    > > break;
                    > > case FormWindowState .Maximized:
                    > > this.WindowStat e = FormWindowState .Normal;
                    > > this.Show();
                    > > this.Activate() ;
                    > > break;
                    > > }
                    > > base.OnLayout (levent);
                    > > }
                    > >
                    > >
                    > >
                    > >
                    > >
                    > >
                    > > On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
                    > > <brianw@gold_de ath_2_spam_rush .com> wrote:
                    > >[color=darkred]
                    > > >This technique has always worked for me, and is working here now. Have[/color][/color]
                    > you[color=green][color=darkred]
                    > > >assigned an Icon to the icon property of your notifyicon object.
                    > > >
                    > > >Can you post a small, complete example that reproduces this behavior?
                    > > >
                    > > >
                    > > >Regards
                    > > >Brian W
                    > > >
                    > > >
                    > > >
                    > > >"Zeljko" <trashbox4@yaho o.com> wrote in message
                    > > >news:46lkrvc03 ubmmlpl7vdh54uu h6l0tkkl3m@4ax. com...
                    > > >> Yes, I have tried. tray icon becomes invisible, and there is nothing[/color][/color][/color]
                    I[color=blue][color=green][color=darkred]
                    > > >> can click on to make it visible again.
                    > > >>
                    > > >> Zeljko
                    > > >> On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
                    > > >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                    > > >>
                    > > >> >No, it won't, the tray icon remains visible. Have you tried?
                    > > >> >
                    > > >> >You restore the form in response to a click on the icon.
                    > > >> >
                    > > >> >
                    > > >> >
                    > > >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                    > > >> >news:nhjkrv4vh gq3ss3nm5lag8c7 8kbjtqq4d8@4ax. com...
                    > > >> >> But If I do that, I don't see tray icon anymore and can't maximize[/color][/color]
                    > the[color=green][color=darkred]
                    > > >> >> form again ?
                    > > >> >>
                    > > >> >> Zeljko
                    > > >> >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
                    > > >> >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                    > > >> >>
                    > > >> >> >When you minimize the form you must also set the Visible property[/color][/color]
                    > to[color=green][color=darkred]
                    > > >> >false
                    > > >> >> >
                    > > >> >> > this.Visible = false;
                    > > >> >> >
                    > > >> >> >
                    > > >> >> >HTH
                    > > >> >> >Brian W
                    > > >> >> >
                    > > >> >> >
                    > > >> >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                    > > >> >> >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...
                    > > >> >> >> Hi,
                    > > >> >> >>
                    > > >> >> >> I have a form with a tray icon. However, when I minimize the[/color][/color]
                    > form,[color=green][color=darkred]
                    > > >it
                    > > >> >> >> stays visible - not in the task bar (I have showintaskbar[/color][/color]
                    > property[color=green][color=darkred]
                    > > >set
                    > > >> >> >> to false), but in a form of a rectangle sitting above the task[/color][/color]
                    > bar.[color=green][color=darkred]
                    > > >> >> >> Can't figure out why that happens - it looks very ugly...
                    > > >> >> >>
                    > > >> >> >> Any ideas ?
                    > > >> >> >>
                    > > >> >> >> Zeljko
                    > > >> >> >
                    > > >> >>
                    > > >> >
                    > > >>
                    > > >[/color]
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Brian W

                      #11
                      Re: Tray Icon Problem

                      See the .Icon property of the NotifyIcon class.

                      Regards
                      Brian W


                      "Lou" <lou.garvin@com cast.net> wrote in message
                      news:ejS0iVouDH A.2304@tk2msftn gp13.phx.gbl...[color=blue]
                      > How do you assign an icon?
                      >
                      >
                      > "Brian W" <brianw@gold_de ath_2_spam_rush .com> wrote in message
                      > news:OgV2EpsrDH A.1760@TK2MSFTN GP10.phx.gbl...[color=green]
                      > > Sorry, this is not complete, for example it does not show me what is[/color][/color]
                      going[color=blue][color=green]
                      > > on in InitializeCompo nent(), and does not show me what you are doing[/color][/color]
                      with[color=blue][color=green]
                      > > micoPending, micoRunning & micoStopped. The example also does not show[/color][/color]
                      me[color=blue][color=green]
                      > > how you are responding to either the Click or DoubleClick events of the
                      > > NotifyIcon object. For that matter it doesn't show that you even have a
                      > > TrayIcon object.
                      > >
                      > > With all that said, if I add your code to mine the window minimizes and
                      > > hides with the tray icon still visible. So I'm sorry to say it still[/color][/color]
                      works[color=blue][color=green]
                      > > for me here.
                      > >
                      > > Paste the following code as your form make sure you assign an icon to[/color][/color]
                      the[color=blue][color=green]
                      > > NotifyIcon object, then tell me if this works for you.
                      > >
                      > >
                      > > Regards
                      > > Brian W
                      > >
                      > > public class Form1 : System.Windows. Forms.Form
                      > >
                      > > {
                      > >
                      > > private System.Windows. Forms.NotifyIco n notifyIcon1;
                      > >
                      > > private System.Componen tModel.IContain er components;
                      > >
                      > > public Form1()
                      > >
                      > > {
                      > >
                      > > //
                      > >
                      > > // Required for Windows Form Designer support
                      > >
                      > > //
                      > >
                      > > InitializeCompo nent();
                      > >
                      > > // TODO: Add any constructor code after InitializeCompo nent call
                      > >
                      > > //
                      > >
                      > > }
                      > >
                      > > /// <summary>
                      > >
                      > > /// Clean up any resources being used.
                      > >
                      > > /// </summary>
                      > >
                      > > protected override void Dispose( bool disposing )
                      > >
                      > > {
                      > >
                      > > if( disposing )
                      > >
                      > > {
                      > >
                      > > if (components != null)
                      > >
                      > > {
                      > >
                      > > components.Disp ose();
                      > >
                      > > }
                      > >
                      > > }
                      > >
                      > > base.Dispose( disposing );
                      > >
                      > > }
                      > >
                      > > #region Windows Form Designer generated code
                      > >
                      > > /// <summary>
                      > >
                      > > /// Required method for Designer support - do not modify
                      > >
                      > > /// the contents of this method with the code editor.
                      > >
                      > > /// </summary>
                      > >
                      > > private void InitializeCompo nent()
                      > >
                      > > {
                      > >
                      > > this.components = new System.Componen tModel.Containe r();
                      > >
                      > > System.Resource s.ResourceManag er resources = new
                      > > System.Resource s.ResourceManag er(typeof(Form1 ));
                      > >
                      > > this.notifyIcon 1 = new System.Windows. Forms.NotifyIco n(this.componen ts);
                      > >
                      > > //
                      > >
                      > > // notifyIcon1
                      > >
                      > > //
                      > >
                      > > this.notifyIcon 1.Icon =
                      > > ((System.Drawin g.Icon)(resourc es.GetObject("n otifyIcon1.Icon ")));
                      > >
                      > > this.notifyIcon 1.Text = "notifyIcon 1";
                      > >
                      > > this.notifyIcon 1.Visible = true;
                      > >
                      > > this.notifyIcon 1.DoubleClick += new
                      > > System.EventHan dler(this.notif yIcon1_DoubleCl ick);
                      > >
                      > > //
                      > >
                      > > // Form1
                      > >
                      > > //
                      > >
                      > > this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
                      > >
                      > > this.ClientSize = new System.Drawing. Size(292, 266);
                      > >
                      > > this.Name = "Form1";
                      > >
                      > > this.Text = "Form1";
                      > >
                      > > this.SizeChange d += new System.EventHan dler(this.Form1 _SizeChanged);
                      > >
                      > > }
                      > >
                      > > #endregion
                      > >
                      > > /// <summary>
                      > >
                      > > /// The main entry point for the application.
                      > >
                      > > /// </summary>
                      > >
                      > > [STAThread]
                      > >
                      > > static void Main()
                      > >
                      > > {
                      > >
                      > > Application.Run (new Form1());
                      > >
                      > > }
                      > >
                      > > private void Form1_SizeChang ed(object sender, System.EventArg s e)
                      > >
                      > > {
                      > >
                      > > if ( this.WindowStat e == FormWindowState .Minimized )
                      > >
                      > > this.Hide();
                      > >
                      > > else
                      > >
                      > > this.Show();
                      > >
                      > > }
                      > >
                      > > private void notifyIcon1_Dou bleClick(object sender, System.EventArg s e)
                      > >
                      > > {
                      > >
                      > > this.Show();
                      > >
                      > > }
                      > >
                      > > }
                      > >
                      > >
                      > >
                      > >
                      > >
                      > > "Zeljko" <trashbox4@yaho o.com> wrote in message
                      > > news:pufmrv86hq 4ps3i3niodr5a0u r36sjvkpd@4ax.c om...[color=darkred]
                      > > > Sure - here it is:
                      > > >
                      > > > public Form1()
                      > > > {
                      > > > //
                      > > > // Required for Windows Form Designer support
                      > > > //
                      > > > InitializeCompo nent();
                      > > > //PENDING_ICON etc are string constants - I added 3 icons to
                      > > > the app, changing current notify icon based on the status of a windows
                      > > > service
                      > > > micoPending = new Icon(typeof(For m1), PENDING_ICON);
                      > > > micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
                      > > > micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);
                      > > >
                      > > > }
                      > > >
                      > > > protected override void OnLayout(Layout EventArgs levent)
                      > > > {
                      > > >
                      > > > switch (WindowState){
                      > > > case FormWindowState .Minimized:
                      > > > this.WindowStat e = FormWindowState .Minimized;
                      > > > this.Hide();
                      > > > break;
                      > > > case FormWindowState .Maximized:
                      > > > this.WindowStat e = FormWindowState .Normal;
                      > > > this.Show();
                      > > > this.Activate() ;
                      > > > break;
                      > > > }
                      > > > base.OnLayout (levent);
                      > > > }
                      > > >
                      > > >
                      > > >
                      > > >
                      > > >
                      > > >
                      > > > On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
                      > > > <brianw@gold_de ath_2_spam_rush .com> wrote:
                      > > >
                      > > > >This technique has always worked for me, and is working here now.[/color][/color][/color]
                      Have[color=blue][color=green]
                      > > you[color=darkred]
                      > > > >assigned an Icon to the icon property of your notifyicon object.
                      > > > >
                      > > > >Can you post a small, complete example that reproduces this behavior?
                      > > > >
                      > > > >
                      > > > >Regards
                      > > > >Brian W
                      > > > >
                      > > > >
                      > > > >
                      > > > >"Zeljko" <trashbox4@yaho o.com> wrote in message
                      > > > >news:46lkrvc03 ubmmlpl7vdh54uu h6l0tkkl3m@4ax. com...
                      > > > >> Yes, I have tried. tray icon becomes invisible, and there is[/color][/color][/color]
                      nothing[color=blue]
                      > I[color=green][color=darkred]
                      > > > >> can click on to make it visible again.
                      > > > >>
                      > > > >> Zeljko
                      > > > >> On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
                      > > > >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                      > > > >>
                      > > > >> >No, it won't, the tray icon remains visible. Have you tried?
                      > > > >> >
                      > > > >> >You restore the form in response to a click on the icon.
                      > > > >> >
                      > > > >> >
                      > > > >> >
                      > > > >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                      > > > >> >news:nhjkrv4vh gq3ss3nm5lag8c7 8kbjtqq4d8@4ax. com...
                      > > > >> >> But If I do that, I don't see tray icon anymore and can't[/color][/color][/color]
                      maximize[color=blue][color=green]
                      > > the[color=darkred]
                      > > > >> >> form again ?
                      > > > >> >>
                      > > > >> >> Zeljko
                      > > > >> >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
                      > > > >> >> <brianw@gold_de ath_2_spam_rush .com> wrote:
                      > > > >> >>
                      > > > >> >> >When you minimize the form you must also set the Visible[/color][/color][/color]
                      property[color=blue][color=green]
                      > > to[color=darkred]
                      > > > >> >false
                      > > > >> >> >
                      > > > >> >> > this.Visible = false;
                      > > > >> >> >
                      > > > >> >> >
                      > > > >> >> >HTH
                      > > > >> >> >Brian W
                      > > > >> >> >
                      > > > >> >> >
                      > > > >> >> >"Zeljko" <trashbox4@yaho o.com> wrote in message
                      > > > >> >> >news:0dgkrvcv7 l1l5vtoa8c3rtla dkjsgg4kg4@4ax. com...
                      > > > >> >> >> Hi,
                      > > > >> >> >>
                      > > > >> >> >> I have a form with a tray icon. However, when I minimize the[/color]
                      > > form,[color=darkred]
                      > > > >it
                      > > > >> >> >> stays visible - not in the task bar (I have showintaskbar[/color]
                      > > property[color=darkred]
                      > > > >set
                      > > > >> >> >> to false), but in a form of a rectangle sitting above the[/color][/color][/color]
                      task[color=blue][color=green]
                      > > bar.[color=darkred]
                      > > > >> >> >> Can't figure out why that happens - it looks very ugly...
                      > > > >> >> >>
                      > > > >> >> >> Any ideas ?
                      > > > >> >> >>
                      > > > >> >> >> Zeljko
                      > > > >> >> >
                      > > > >> >>
                      > > > >> >
                      > > > >>
                      > > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      Working...