Notify Icon show form

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

    Notify Icon show form

    I have a utility that minimizes to the system tray.
    When I double click or right-click and select restore I want to show the
    window and for it to be the active window again.
    I have tried
    this.Show
    this.Activate
    this.BringToFro nt

    But in all cases, the form just restores to the task bar and does not
    show itself.

    The only way I could do it was with the win23 api's
    ShowWindowAsync and SetForegroundWi ndow.

    This is fine and works as desired, I just wondered if I was missing
    anything and there was a managed way to do it?

    Cheers
    JB
  • Adam Clauss

    #2
    Re: Notify Icon show form

    Hmm, I haven't actually tried it, but from what I've seen it should just be
    a call to Hide() to hide the form and then a call to Show() to bring it
    back. What are you currently using to make the form go away?

    Might look at:


    --
    Adam Clauss
    cabadam@tamu.ed u

    "John B" <jbngspam@yahoo .com> wrote in message
    news:42828928$0 $79463$14726298 @news.sunsite.d k...[color=blue]
    >I have a utility that minimizes to the system tray.
    > When I double click or right-click and select restore I want to show the
    > window and for it to be the active window again.
    > I have tried
    > this.Show
    > this.Activate
    > this.BringToFro nt
    >
    > But in all cases, the form just restores to the task bar and does not show
    > itself.
    >
    > The only way I could do it was with the win23 api's
    > ShowWindowAsync and SetForegroundWi ndow.
    >
    > This is fine and works as desired, I just wondered if I was missing
    > anything and there was a managed way to do it?
    >
    > Cheers
    > JB[/color]


    Comment

    • psg

      #3
      Re: Notify Icon show form

      "John B" <jbngspam@yahoo .com> wrote in message
      news:42828928$0 $79463$14726298 @news.sunsite.d k...[color=blue]
      >I have a utility that minimizes to the system tray.
      > When I double click or right-click and select restore I want to show the
      > window and for it to be the active window again.
      > I have tried
      > this.Show
      > this.Activate
      > this.BringToFro nt[/color]

      for me this works:
      *************** *************** ***
      private void notifyIcon1_Mou seDown(object sender,
      System.Windows. Forms.MouseEven tArgs e)
      {
      this.Show();
      this.Activate() ;
      if (this.WindowSta te == FormWindowState .Minimized)
      {
      this.WindowStat e = FormWindowState .Normal;
      }
      }

      *************** *************** ***
      additionally:
      *************** *************** ***
      // after Form initialisation
      this.Resize += new EventHandler(Hi deForm);

      void HideForm(object sender, EventArgs e)
      {
      if(this.WindowS tate == FormWindowState .Minimized)
      {
      this.Hide();
      }
      else this.Show();
      }
      *************** *************** ***

      RGDS PSG


      Comment

      • John B

        #4
        Re: Notify Icon show form

        Adam Clauss wrote:[color=blue]
        > Hmm, I haven't actually tried it, but from what I've seen it should just be
        > a call to Hide() to hide the form and then a call to Show() to bring it
        > back. What are you currently using to make the form go away?
        >
        > Might look at:
        > http://www.codeproject.com/csharp/trayiconmenu01.asp
        >[/color]
        this.Hide()

        psg's suggestion fixed it though.
        Thanks for your help.

        JB

        Comment

        • John B

          #5
          Re: Notify Icon show form

          psg wrote:[color=blue]
          > "John B" <jbngspam@yahoo .com> wrote in message
          > news:42828928$0 $79463$14726298 @news.sunsite.d k...
          >[color=green]
          >>I have a utility that minimizes to the system tray.
          >>When I double click or right-click and select restore I want to show the
          >>window and for it to be the active window again.
          >>I have tried
          >>this.Show
          >>this.Activa te
          >>this.BringToF ront[/color]
          >
          >
          > for me this works:
          > *************** *************** ***
          > private void notifyIcon1_Mou seDown(object sender,
          > System.Windows. Forms.MouseEven tArgs e)
          > {
          > this.Show();
          > this.Activate() ;
          > if (this.WindowSta te == FormWindowState .Minimized)
          > {
          > this.WindowStat e = FormWindowState .Normal;
          > }
          > }
          >
          > *************** *************** ***
          > additionally:
          > *************** *************** ***
          > // after Form initialisation
          > this.Resize += new EventHandler(Hi deForm);
          >
          > void HideForm(object sender, EventArgs e)
          > {
          > if(this.WindowS tate == FormWindowState .Minimized)
          > {
          > this.Hide();
          > }
          > else this.Show();
          > }
          > *************** *************** ***
          >
          > RGDS PSG
          >
          >[/color]
          Works beautifully.
          Thanks
          I didnt set the form.windowstat e, which is why it never brought it back up.

          Cheers
          JB

          Comment

          Working...