Sys tray

  • Thread starter Thread starter Dalibor Savanovic
  • Start date Start date
D

Dalibor Savanovic

How to put app po "sleep" in system tray (place with system clock)?
Thanks, Dalibor
 
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
 
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,
 
//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
 
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
 
Back
Top