MDI service application

Posted on 2006-05-11
Medium Priority
Last Modified: 2010-08-05
Can somebody give me an example of service application which consist of MDIForm and one MDIChild.
Both should be created when service is started.
They may be visible or hidden while created.
But afterwards they should be hidden not destroyed all the time service is running.
Question by:mokule
  • 4
  • 3
LVL 28

Expert Comment

ID: 16667245
if they will be hidden, why do you need them anyway? if you just want to drop compnents, you can use a datamodule.
and you will have to make the service be interactive otehrwise you won't be able to use the forms.
plus that services are designed to not interact with the user: it is the most important quality of them: they don't need user intervention and hence can run even if no user is logged on. but a form needs to be displayed and hance requires a "desktop" and thus a logged in user.

so all this is kind of not compatible. can you explain why and what you need this for? maybe there are better soultions.
LVL 17

Author Comment

ID: 16668330
I know all this.
> can you explain why and what you need this for ?
To make a long story short. It is rewritten application to service.
It'll be most convinient for me.
I can create normal forms with no problem, but not MDI.

Does anybody know if this is possible at all ?
LVL 28

Expert Comment

ID: 16668386
can you tell me what errors do you get? )if any) also, what is your delphi version? I'll get home in about 2 hours and investigate this on a delphi 7 environment.
I don't see any reason for why a normal form would work for you and a MDI one not. but then again, I don't have much experience with mdi's.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 17

Author Comment

ID: 16668511
This program is written under D7
I've got exception:
Cannot create form. No MDI forms are currently active.
It is thrown when I'm trying to create child window.
The main window is visible and it is MDI, but in fact it's Active property is False.
I've tried SetFocus and Activate with no success.
LVL 28

Accepted Solution

2266180 earned 2000 total points
ID: 16670347
I created a service application, added a form, made it mdi,added anotehr form, made it mdi child. added a timer on the service, 10 seconds delay, with a form.show and a timer disable. saved everything, compiled. run
project2.exe /install
opened services.msc, started the service. after 10 seconds the form appeard: mdi with one child window. no errors no nothing. I could drag the forms around minimize, maximize. everything was ok.
the one issue that I did notice is when closing the main form it seems to freeze (this is because in delphi, closing the main form means closing the application. but since the application is a service, it cannot be stopped the normal way. so you will have to hide the form and cancel the closing (in closequery event for example) and just hide the (main) form.
the above was done in delphi 7, win xp sp1. project available here: http://www.ciuly.com/delphi/serviceMDI.zip
LVL 17

Author Comment

ID: 16681775
do you know what to do to avoid button on the taskbar when window is hidden.
The service shouldn't have button on taskbar.
LVL 28

Expert Comment

ID: 16681813
yes, this should fix it: http://www.scalabium.com/faq/dct0096.htm
I am at work right now and cannot test. if the above does not work (though in a normal application does) then let me know and I will investigate tonight
LVL 17

Expert Comment

ID: 16731086
another way of keeping the service running when you close the mdi form is to add a dummyform.
set it as the "main form" in the project options but put
application.showmainform := false;
in the .dpr

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question