Killing a Shell_NotifyIcon balloon tip and powering on monitor in C#

K

kieran.j.lee

Hi,

I have hunted round the web and managed to put together some code which
displays a balloon tip for a notification icon in the system tray when
I am running a windows service. This times out after about 10 seconds
if I move the mouse around the screen which is pretty much okay, but if
I don't do anything the balloon just stays showing for a long time. Is
there a method to kill this balloon tip without killing the whole icon
(a method I have temporarily employed is making the icon invisible and
then making it visible again the next time I want to display a balloon
tip). Ideally, I would like the icon to remain so users are able to
see the service is running in the background.

Also, does anyone know how to power up the monitor when Power
Management has switched the monitor off from within code? I have tried


public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MONITORPOWER = 0xF170;
public const int MONITOR_ON = 1;
public const int MONITOR_OFF = 2;

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int
lParam);

[DllImport("user32.dll")]
static extern IntPtr GetDesktopWindow();

SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_MONITORPOWER, 1);

without success.

Regards,
Kieran Lee
 
K

kieran.j.lee

As is often the case, I sussed out the first part of my query moments
after sending the email by simply adding a timer and raising an even
when the timer elapsed.

Still stumped as to the power management though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top