Connecting Tech Pros Worldwide Help | Site Map

Keeping application to notify icon

  #1  
Old November 16th, 2005, 10:49 PM
Beenish Sahar Khan
Guest
 
Posts: n/a
I want to start my application so that its notify icon is added to the
system tray, i don't want to show any starting form. I want user to interact
through the notify icon...just like MSN. Is there any way to do this?
regards,
beenish


  #2  
Old November 16th, 2005, 10:51 PM
Ignacio Machin \( .NET/ C# MVP \)
Guest
 
Posts: n/a

re: Keeping application to notify icon


hi,

find below pieces of code I use for this

//declarations

[DllImport("user32.dll",EntryPoint="SetForegroundWi ndow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern int SetWindowLong( IntPtr window, int index, int
value);
[DllImport("user32.dll")]
public static extern int GetWindowLong( IntPtr window, int index);

const int GWL_EXSTYLE = -20;
const int WS_EX_TOOLWINDOW = 0x00000080;
const int WS_EX_APPWINDOW = 0x00040000;


//PUT THIS code in the constructor
this.Text = "";

// Create the NotifyIcon.
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);

// The Icon property sets the icon that will appear
// in the systray for this application.
notifyIcon1.Icon = normalIcon;
notifyIcon1.Visible = true;

this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Visible = false;
this.ShowInTaskbar = false;
iconTimer.Start();

int windowStyle = GetWindowLong(Handle, GWL_EXSTYLE);
SetWindowLong(Handle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDOW);


cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



"Beenish Sahar Khan" <beenish.khan@kolachi.net> wrote in message
news:esUMQD9HFHA.572@tk2msftngp13.phx.gbl...[color=blue]
>I want to start my application so that its notify icon is added to the
> system tray, i don't want to show any starting form. I want user to
> interact
> through the notify icon...just like MSN. Is there any way to do this?
> regards,
> beenish
>
>[/color]


  #3  
Old November 16th, 2005, 11:03 PM
Beenish Sahar Khan
Guest
 
Posts: n/a

re: Keeping application to notify icon


Thanks alot, its working :D

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%23RnxUGAIFHA.1096@tk2msftngp13.phx.gbl...[color=blue]
> hi,
>
> find below pieces of code I use for this
>
> //declarations
>
> [DllImport("user32.dll",EntryPoint="SetForegroundWi ndow")]
> public static extern bool SetForegroundWindow(IntPtr hWnd);
> [DllImport("user32.dll")]
> public static extern int SetWindowLong( IntPtr window, int index, int
> value);
> [DllImport("user32.dll")]
> public static extern int GetWindowLong( IntPtr window, int index);
>
> const int GWL_EXSTYLE = -20;
> const int WS_EX_TOOLWINDOW = 0x00000080;
> const int WS_EX_APPWINDOW = 0x00040000;
>
>
> //PUT THIS code in the constructor
> this.Text = "";
>
> // Create the NotifyIcon.
> this.notifyIcon1 = new[/color]
System.Windows.Forms.NotifyIcon(this.components);[color=blue]
>
> // The Icon property sets the icon that will appear
> // in the systray for this application.
> notifyIcon1.Icon = normalIcon;
> notifyIcon1.Visible = true;
>
> this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
> this.Visible = false;
> this.ShowInTaskbar = false;
> iconTimer.Start();
>
> int windowStyle = GetWindowLong(Handle, GWL_EXSTYLE);
> SetWindowLong(Handle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDOW);
>
>
> cheers,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
>
>
> "Beenish Sahar Khan" <beenish.khan@kolachi.net> wrote in message
> news:esUMQD9HFHA.572@tk2msftngp13.phx.gbl...[color=green]
> >I want to start my application so that its notify icon is added to the
> > system tray, i don't want to show any starting form. I want user to
> > interact
> > through the notify icon...just like MSN. Is there any way to do this?
> > regards,
> > beenish
> >
> >[/color]
>
>[/color]


  #4  
Old November 16th, 2005, 11:07 PM
Beenish Sahar Khan
Guest
 
Posts: n/a

re: Keeping application to notify icon


Thanks for your solution, one more question that i would like to ask is ,
once i've made my form invisble using the below mentioned solution, now
after sometime, while the application is still running, i want to make the
particular form visible, what should i do to make it visible.
Beenish
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%23RnxUGAIFHA.1096@tk2msftngp13.phx.gbl...[color=blue]
> hi,
>
> find below pieces of code I use for this
>
> //declarations
>
> [DllImport("user32.dll",EntryPoint="SetForegroundWi ndow")]
> public static extern bool SetForegroundWindow(IntPtr hWnd);
> [DllImport("user32.dll")]
> public static extern int SetWindowLong( IntPtr window, int index, int
> value);
> [DllImport("user32.dll")]
> public static extern int GetWindowLong( IntPtr window, int index);
>
> const int GWL_EXSTYLE = -20;
> const int WS_EX_TOOLWINDOW = 0x00000080;
> const int WS_EX_APPWINDOW = 0x00040000;
>
>
> //PUT THIS code in the constructor
> this.Text = "";
>
> // Create the NotifyIcon.
> this.notifyIcon1 = new[/color]
System.Windows.Forms.NotifyIcon(this.components);[color=blue]
>
> // The Icon property sets the icon that will appear
> // in the systray for this application.
> notifyIcon1.Icon = normalIcon;
> notifyIcon1.Visible = true;
>
> this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
> this.Visible = false;
> this.ShowInTaskbar = false;
> iconTimer.Start();
>
> int windowStyle = GetWindowLong(Handle, GWL_EXSTYLE);
> SetWindowLong(Handle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDOW);
>
>
> cheers,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
>
>
> "Beenish Sahar Khan" <beenish.khan@kolachi.net> wrote in message
> news:esUMQD9HFHA.572@tk2msftngp13.phx.gbl...[color=green]
> >I want to start my application so that its notify icon is added to the
> > system tray, i don't want to show any starting form. I want user to
> > interact
> > through the notify icon...just like MSN. Is there any way to do this?
> > regards,
> > beenish
> >
> >[/color]
>
>[/color]


  #5  
Old November 16th, 2005, 11:07 PM
Beenish Sahar Khan
Guest
 
Posts: n/a

re: Keeping application to notify icon


Infact, i will rephrase my question that while running my application i
would like to hide it or show it multiple times, how do i show it so when
the next time i try to hide it, it will hide cleanly. as currently if i
simple make it visible and show it in taskbar, it do not hide again. :( I
request you to provide me a solution to this problem.
regards,
Beenish
"Beenish Sahar Khan" <beenish.khan@kolachi.net> wrote in message
news:uAW4fq6IFHA.732@TK2MSFTNGP12.phx.gbl...[color=blue]
> Thanks for your solution, one more question that i would like to ask is ,
> once i've made my form invisble using the below mentioned solution, now
> after sometime, while the application is still running, i want to make[/color]
the[color=blue]
> particular form visible, what should i do to make it visible.
> Beenish
> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>[/color]
wrote[color=blue]
> in message news:%23RnxUGAIFHA.1096@tk2msftngp13.phx.gbl...[color=green]
> > hi,
> >
> > find below pieces of code I use for this
> >
> > //declarations
> >
> > [DllImport("user32.dll",EntryPoint="SetForegroundWi ndow")]
> > public static extern bool SetForegroundWindow(IntPtr hWnd);
> > [DllImport("user32.dll")]
> > public static extern int SetWindowLong( IntPtr window, int index, int
> > value);
> > [DllImport("user32.dll")]
> > public static extern int GetWindowLong( IntPtr window, int index);
> >
> > const int GWL_EXSTYLE = -20;
> > const int WS_EX_TOOLWINDOW = 0x00000080;
> > const int WS_EX_APPWINDOW = 0x00040000;
> >
> >
> > //PUT THIS code in the constructor
> > this.Text = "";
> >
> > // Create the NotifyIcon.
> > this.notifyIcon1 = new[/color]
> System.Windows.Forms.NotifyIcon(this.components);[color=green]
> >
> > // The Icon property sets the icon that will appear
> > // in the systray for this application.
> > notifyIcon1.Icon = normalIcon;
> > notifyIcon1.Visible = true;
> >
> > this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
> > this.Visible = false;
> > this.ShowInTaskbar = false;
> > iconTimer.Start();
> >
> > int windowStyle = GetWindowLong(Handle, GWL_EXSTYLE);
> > SetWindowLong(Handle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDOW);
> >
> >
> > cheers,
> >
> > --
> > Ignacio Machin,
> > ignacio.machin AT dot.state.fl.us
> > Florida Department Of Transportation
> >
> >
> >
> > "Beenish Sahar Khan" <beenish.khan@kolachi.net> wrote in message
> > news:esUMQD9HFHA.572@tk2msftngp13.phx.gbl...[color=darkred]
> > >I want to start my application so that its notify icon is added to the
> > > system tray, i don't want to show any starting form. I want user to
> > > interact
> > > through the notify icon...just like MSN. Is there any way to do this?
> > > regards,
> > > beenish
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
is local pc online? giddy answers 7 November 17th, 2006 07:15 AM
notify icon and context menu for Windows Service Application Lalit answers 7 November 22nd, 2005 07:36 PM
Keeping application to notify icon Beenish Sahar Khan answers 3 November 16th, 2005 10:50 PM
notify icon and context menu for Windows Service Application Lalit answers 7 July 21st, 2005 11:21 PM