469,609 Members | 2,217 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Windows Service & NotifyIcon

I have a NotifyIcon in my Windows Service project and I am trying to

add a ContextMenu to this NotifyIcon or use some of the mouse events.
Everything isn't working. I think so base class of the service
System.ServiceProcess.ServiceBase don't catchWindows messages like mouse or
timer messages. Any Idea?
Thanks,

Artur Kowalski

Nov 15 '05 #1
1 5142
MSDN:
"
a.. Windows Service applications run in a different window station than the
interactive station of the logged-on user. A window station is a secure
object that contains a clipboard, a set of global atoms, and a group of
desktop objects. Because the station of the Windows Service is not an
interactive station, dialog boxes raised from within a Windows Service
application will not be seen and may cause your program to stop responding.
Similarly, error messages should be logged in the Windows event log rather
than raised in the user interface.
The Windows Service classes supported by the .NET Framework do not support
interaction with interactive stations, that is, the logged-on user. The .NET
Framework also does not include classes that represent stations and
desktops. If your Windows Service must interact with other stations, you
will need to access the unmanaged Windows API.

The interaction of the Windows Service with the user or other stations must
be carefully designed to include scenarios such as there being no logged on
user, or the user having an unexpected set of desktop objects. In some
cases, it may be more appropriate to write a Windows application that runs
under the control of the user.

"

So:
1. Why a service? The service is supposed to be a completely automatic piece
of code that services clients. It wrotes events in event log and is
started/stopped via service manager. If you need user interaction why didn't
you design a simple Windows application?
2. Anyhow, if you want to manage the service locally/remotely via a
customised UI, and to issue more than start/stop functionality you have to
find a common repository (message queues, files or whatever) for the
messages send by a Windows app (the UI) that produces requests for the
service, and the service that consumes them.

--
Horatiu Ripa
"Artur Kowalski" <ar******@bsb.pl> wrote in message
news:bl**********@atlantis.news.tpi.pl...
I have a NotifyIcon in my Windows Service project and I am trying to

add a ContextMenu to this NotifyIcon or use some of the mouse events.
Everything isn't working. I think so base class of the service
System.ServiceProcess.ServiceBase don't catchWindows messages like mouse or timer messages. Any Idea?
Thanks,

Artur Kowalski

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Rob Y | last post: by
2 posts views Thread by Andrew Mueller | last post: by
11 posts views Thread by Andrew Mueller | last post: by
3 posts views Thread by Seymen Ertas | last post: by
1 post views Thread by chinimimita.hernandez | last post: by
1 post views Thread by Jacek Jurkowski | last post: by
5 posts views Thread by sonali_reddy123 | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.