Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

Sys tray

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dalibor Savanovic - 14 Dec 2005 13:49 GMT
How to put app po "sleep" in system tray (place with system clock)?
Thanks, Dalibor
Marc Gravell - 14 Dec 2005 13:54 GMT
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

> How to put app po "sleep" in system tray (place with system clock)?
> Thanks, Dalibor
Ignacio Machin ( .NET/ C# MVP ) - 14 Dec 2005 14:03 GMT
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,

Signature

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

> How to put app po "sleep" in system tray (place with system clock)?
> Thanks, Dalibor
Mattias Sjögren - 14 Dec 2005 19:20 GMT
>//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

Signature

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

Ignacio Machin ( .NET/ C# MVP ) - 14 Dec 2005 19:58 GMT
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

Signature

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

> >//Make it gone frmo the ALT+TAB
>>int windowStyle = GetWindowLong(Handle, GWL_EXSTYLE);
[quoted text clipped - 3 lines]
>
> Mattias

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.