Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. NotifyIcon Program ?

NotifyIcon Program ?

Scheduled Pinned Locked Moved C#
toolstutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Skoder
    wrote on last edited by
    #1

    Hello, can anyone tell me how i can make a program which is only running with a NotifyIcon as the only control ? (like etc. Daemon tools if anyone know that program) Is it possible without creating a Form ? Or should I Create a Form, then put a notifyIcon on it and let it be minimized from the start (and somehow never be able to be maximized) or maybe never draw itself ? (i guess there must be some "correct" way of doing this?) Also i dont want program to be able to be selected when doing Alt+Tab etc. Anyone know how to do this ? Best regards Martin :confused:

    S K 2 Replies Last reply
    0
    • S Skoder

      Hello, can anyone tell me how i can make a program which is only running with a NotifyIcon as the only control ? (like etc. Daemon tools if anyone know that program) Is it possible without creating a Form ? Or should I Create a Form, then put a notifyIcon on it and let it be minimized from the start (and somehow never be able to be maximized) or maybe never draw itself ? (i guess there must be some "correct" way of doing this?) Also i dont want program to be able to be selected when doing Alt+Tab etc. Anyone know how to do this ? Best regards Martin :confused:

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      You could hide the form by setting Opacity to zero and I *think* if you set VisibleInTaskbar to false, it won't be shown when Alt+Tabbing. Regards Senthil _____________________________ My Blog | My Articles | My Flickr | WinMacro

      1 Reply Last reply
      0
      • S Skoder

        Hello, can anyone tell me how i can make a program which is only running with a NotifyIcon as the only control ? (like etc. Daemon tools if anyone know that program) Is it possible without creating a Form ? Or should I Create a Form, then put a notifyIcon on it and let it be minimized from the start (and somehow never be able to be maximized) or maybe never draw itself ? (i guess there must be some "correct" way of doing this?) Also i dont want program to be able to be selected when doing Alt+Tab etc. Anyone know how to do this ? Best regards Martin :confused:

        K Offline
        K Offline
        kasik
        wrote on last edited by
        #3

        You don't need a form to do this, you just need to start a message loop. In the following example, calling Application.Run() starts the loop meaning that the NotifyIcon won't vanish instantly.

        public class TaskTray
        {
        [STAThread]
        public static void Main()
        {
        new TaskTray();
        if ( !Application.MessageLoop )
        Application.Run();
        }

        private NotifyIcon nIcon = new NotifyIcon();
        public TaskTray()
        {
            nIcon.Icon = new System.Drawing.Icon( typeof( TaskTray ), "myIcon.ico" );
            nIcon.Visible = true;
            nIcon.DoubleClick += new EventHandler( nIcon\_DoubleClick );
        }
        
        public void nIcon\_DoubleClick( object sender, EventArgs e )
        {
            nIcon.Visible = false;
            Application.Exit();
        }
        

        }

        Hope this helps :) Cheers, Will H

        S 1 Reply Last reply
        0
        • K kasik

          You don't need a form to do this, you just need to start a message loop. In the following example, calling Application.Run() starts the loop meaning that the NotifyIcon won't vanish instantly.

          public class TaskTray
          {
          [STAThread]
          public static void Main()
          {
          new TaskTray();
          if ( !Application.MessageLoop )
          Application.Run();
          }

          private NotifyIcon nIcon = new NotifyIcon();
          public TaskTray()
          {
              nIcon.Icon = new System.Drawing.Icon( typeof( TaskTray ), "myIcon.ico" );
              nIcon.Visible = true;
              nIcon.DoubleClick += new EventHandler( nIcon\_DoubleClick );
          }
          
          public void nIcon\_DoubleClick( object sender, EventArgs e )
          {
              nIcon.Visible = false;
              Application.Exit();
          }
          

          }

          Hope this helps :) Cheers, Will H

          S Offline
          S Offline
          Skoder
          wrote on last edited by
          #4

          Thanks, that was just perfect and what i needed. :-) Thanks again :) Best regards Martin

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups