Keeping application to notify icon | | |
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 | | | | 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] | | | | 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] | | | | 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] | | | | 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] |  | Similar C# / C Sharp bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,295 network members.
|