473,467 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Create 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 2680
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
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 ...

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.