Board index » cppbuilder » Problem Creating Service Application with User Interface

Problem Creating Service Application with User Interface


2004-08-18 11:10:18 PM
cppbuilder89
I'm using C++Builder 6, and I'm trying to create a simple service
application that establishes a TCP connection with any specified IP address
or host name periodically, to check for network connectivity and uptime. It
needs to be a service application so it is running before logon and after
logoff of a Windows user name, and so it automatically starts up after
rebooting. It needs to have a user interface so that the settings can be
changed.
I tried starting with the Service Application project from File..New..Other.
I added a form and a TTrayIcon component, and everything works fine if I run
them inside a non-service application project. But the form does not behave
correctly within the service application. When I run the program, the system
tray icon appears, and I use the popup menu I put on it to show the form.
This all works fine. But, when I try to close the form, the form window
freezes. When I try to minimize it, it disappears to the tray icon as it
should, but then I can't get it back. So I'm guessing there's something
about a service application that doesn't work well with windowed forms.
Is there any way to get a form to display properly within a service
application? Also, since the service would start up before login, before a
desktop and system tray are created, is there any way of determining whether
they are created yet, and is there some kind of event that fires when login
causes this creation? If there were a way of doing this, when the program is
executed, I could display the tray icon if someone was logged in, and if
not, wait until the event for login fires to display it.
 
 

Re:Problem Creating Service Application with User Interface

"Eric Pratt" < XXXX@XXXXX.COM >wrote in message
Quote
It needs to have a user interface so that the settings can be changed.
You would be best off using a separate non-service application for managing
the settings.
Quote
I added a form and a TTrayIcon component
Do not put those in the service directly.
Quote
Is there any way to get a form to display properly
within a service application?
Technically yes, but it does involve a bit of extra code, and I would not
recommend it in general anyway. Services are meant to be used as background
tasks with no UI at all, especially if they need to run when nobody is
actually at the computer.
Quote
Also, since the service would start up before login, before a
desktop and system tray are created, is there any way of
determining whether they are created yet, and is there some
kind of event that fires when login causes this creation? If there
were a way of doing this, when the program is executed, I could
display the tray icon if someone was logged in, and if not, wait
until the event for login fires to display it.
Put the tray icon into a separate non-service program that is set up to
auto-run after the user has logged in.
Gambit
 

Re:Problem Creating Service Application with User Interface

Quote
You would be best off using a separate non-service application for
managing
the settings.
A separate program it is, then. Thanks for your help!
 

{smallsort}