473,763 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

systray


How to put an application in systray with F1 or any shortcut button?
Nov 16 '05 #1
4 2705
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.h r...

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("user 32.dll",EntryPo int="SetForegro undWindow")]
public static extern bool SetForegroundWi ndow(IntPtr hWnd);
[DllImport("user 32.dll")]
private static extern bool MessageBeep(int type);
[DllImport("user 32.dll")]
public static extern int SetWindowLong( IntPtr window, int index, int
value);
[DllImport("user 32.dll")]
public static extern int GetWindowLong( IntPtr window, int index);
[DllImport("winm m.dll")]
public static extern int sndPlaySound(st ring lpszSoundName , int uFlags)
;
const int GWL_EXSTYLE = -20;
const int WS_EX_TOOLWINDO W = 0x00000080;
const int WS_EX_APPWINDOW = 0x00040000;

//This is the icon when there are no orders in the system
Icon normalIcon;
public Form1()
{
this.notifyIcon 1 = new System.Windows. Forms.NotifyIco n(this.componen ts);

// The Icon property sets the icon that will appear
// in the systray for this application.
notifyIcon1.Ico n = normalIcon;

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

// The Text property sets the text that will be displayed,
// in a tooltip, when the mouse hovers over the systray icon.
notifyIcon1.Tex t = "the text";
notifyIcon1.Vis ible = true;
//Remove from the taskbar and also from alt+tab
this.WindowStat e = System.Windows. Forms.FormWindo wState.Minimize d;
this.Visible = false;
this.ShowInTask bar = false;

int windowStyle = GetWindowLong(H andle, GWL_EXSTYLE);
SetWindowLong(H andle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDO W);
}
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.mach in AT dot.state.fl.us > wrote
in message news:%2******** ********@tk2msf tngp13.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.h r...

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@ask hdg_hotmail.com > wrote in message
news:%2******** ********@tk2msf tngp13.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.mach in AT dot.state.fl.us > wrote in message news:%2******** ********@tk2msf tngp13.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.h r...
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
9923
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 systray icon? please give direction... thx
3
5496
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 out. It is essential that I solve this problem but I have run out of ideas can anyone help (please!) The application starts in Start.cs which kicks off the Systray form using this call: Application.Run(new Systray());
0
1834
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 under certain conditions, but the exe is still listed in the processes leading me to believe the app is still running. It fires up perfectly on boot, however if the user logs off, and then logs back in (not reboot), or if the system goes to...
0
931
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 under certain conditions, but the exe is still listed in the processes leading me to believe the app is still running. It fires up perfectly on boot, however if the user logs off, and then logs back in (not reboot), or if the system goes to...
8
2671
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 install 2. Have the service interact with the SysTray In my ProjectInstaller.vb Private Sub ServiceInstaller1_AfterInstall(ByVal sender As
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10145
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9998
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.