471,337 Members | 862 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Sys tray

How to put app po "sleep" in system tray (place with system clock)?
Thanks, Dalibor
Dec 14 '05 #1
4 1594
Look at System.Windows.Forms.NotifyIcon; you can drag this into the
component area of a form, set an icon and text, a menu, click-events, etc.

Obviously if this is actually placed on a (dummy) form, you might want to
make the form invisible and set ShowInTaskbar to false

Marc

"Dalibor Savanovic" <da******@eunet.yu> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
How to put app po "sleep" in system tray (place with system clock)?
Thanks, Dalibor

Dec 14 '05 #2
Hi,

NotifyIcon is your answer, also you may want to remove your app from
ALT+TAB and the task bar, here is the code for all this:

[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;

private System.Windows.Forms.NotifyIcon notifyIcon1;
// I use two icons depending of the status of the app
normalIcon = new Icon(this.GetType(),"Normal.ico");
alertIcon = new Icon(this.GetType(),"Alert.ico");
notifyIcon1.Icon = normalIcon;

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

//Make it gone frmo the ALT+TAB
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

"Dalibor Savanovic" <da******@eunet.yu> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
How to put app po "sleep" in system tray (place with system clock)?
Thanks, Dalibor

Dec 14 '05 #3
>//Make it gone frmo the ALT+TAB
int windowStyle = GetWindowLong(Handle, GWL_EXSTYLE);
SetWindowLong(Handle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDOW);


Can't you just set the FormBorderStyle property to SizableToolWindow?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 14 '05 #4
Hi ,

Good question, I haven;t try it :)

Got that code from somewhere and been using it since then.

I will try it later and will post back if the windows is indeed removed from
the alt+tab
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:O6**************@TK2MSFTNGP11.phx.gbl...
//Make it gone frmo the ALT+TAB
int windowStyle = GetWindowLong(Handle, GWL_EXSTYLE);
SetWindowLong(Handle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDOW);


Can't you just set the FormBorderStyle property to SizableToolWindow?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Dec 14 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Zeljko | last post: by
2 posts views Thread by Sean Dudley | last post: by
4 posts views Thread by Robert Samuel White | last post: by
10 posts views Thread by Crouchie1998 | last post: by
8 posts views Thread by Avi G | last post: by
3 posts views Thread by Usman Jamil | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.