473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

systray


How to put an application in systray with F1 or any shortcut button?
Nov 16 '05 #1
4 2674
Hi Mario

To put an icon in the systray you use the NotifyIcon component. take a look
at MSDN for it.
If you want your application removed from the taskbar, as well as showing no
windows let me know as you may need aditional code.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"mario" <BL****@BLA.com> wrote in message news:c5**********@bagan.srce.hr...

How to put an application in systray with F1 or any shortcut button?

Nov 16 '05 #2
Hi Mario

This is the code I'm using now, I'm cutting&paste from my app so maybe it
will not compile as it is.

using System.Runtime.InteropServices;

[DllImport("user32.dll",EntryPoint="SetForegroundWi ndow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern bool MessageBeep(int type);
[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);
[DllImport("winmm.dll")]
public static extern int sndPlaySound(string lpszSoundName , int uFlags)
;
const int GWL_EXSTYLE = -20;
const int WS_EX_TOOLWINDOW = 0x00000080;
const int WS_EX_APPWINDOW = 0x00040000;

//This is the icon when there are no orders in the system
Icon normalIcon;
public Form1()
{
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;

// The ContextMenu property sets the menu that will
// appear when the systray icon is right clicked.
notifyIcon1.ContextMenu = this.contextMenu1;

// The Text property sets the text that will be displayed,
// in a tooltip, when the mouse hovers over the systray icon.
notifyIcon1.Text = "the text";
notifyIcon1.Visible = true;
//Remove from the taskbar and also from alt+tab
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Visible = false;
this.ShowInTaskbar = false;

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
Nov 16 '05 #3
I also have managed to keep my app in the taskbar tray but am having
problems with hiding the window from the taskbar. Any help on this would be
greatly appreciated...

Thanks

John

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%2****************@tk2msftngp13.phx.gbl...
Hi Mario

To put an icon in the systray you use the NotifyIcon component. take a look at MSDN for it.
If you want your application removed from the taskbar, as well as showing no windows let me know as you may need aditional code.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"mario" <BL****@BLA.com> wrote in message

news:c5**********@bagan.srce.hr...

How to put an application in systray with F1 or any shortcut button?


Nov 16 '05 #4
Hi John,

Take a look at my other post. I got that some from somewhere in the
newsgroup :)

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"John Young" <polomint77@askhdg_hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I also have managed to keep my app in the taskbar tray but am having
problems with hiding the window from the taskbar. Any help on this would be greatly appreciated...

Thanks

John

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
Hi Mario

To put an icon in the systray you use the NotifyIcon component. take a look
at MSDN for it.
If you want your application removed from the taskbar, as well as showing no
windows let me know as you may need aditional code.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"mario" <BL****@BLA.com> wrote in message

news:c5**********@bagan.srce.hr...
How to put an application in systray with F1 or any shortcut button?



Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Action | last post by:
I can add a systray icon in normal windows application... but when i do it in windows service, the systray icon just don't show up is that because i don't have any "component" to contain the...
3
by: Jon Bosker | last post by:
I have written an application that lives in the systray but when I try to close windows or logout it does not close my application and therefore prevents windows from shutting down or logging me...
0
by: kapcreations | last post by:
I have a system tray app which gets the status of a windows service, and displays the appropriate icon for the status of the service in the systray. the problem I am having is the icon disapears...
0
by: kapcreations | last post by:
I have a system tray app which gets the status of a windows service, and displays the appropriate icon for the status of the service in the systray. the problem I am having is the icon disapears...
8
by: Rob R. Ainscough | last post by:
I have a VS 2005 Windows Service with a Installer project as part of my solution. The Service installs fine but I can't seem to make either of these work: 1. Have the service start after...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.