Board index » delphi » Showing DCOM server's main form BUG ?

Showing DCOM server's main form BUG ?

I need a running DCOM server with no visible form.

I set Application.ShowMainForm:= false.

Everything works OK until I want to display server status (i.e.
connected users etc.), in other words user interface of the project,
which is on the main form.

Upon user request I show the main form. When the user click OK or Close
on the form, I hide the form.

Whatever I set in Action in the OnClose event, whatever method I
actually call (Hide, Close), the main form ALWAYS destroys itself and
the application terminates, including the DCOM server which runs in its
process space, even though it has active connections !!!

Of course, bunch of errors on the clients occur and the whole system is
down.

Is there anything I can do to circumvent this? The only way I could
think of is to put the UI on a secondary form and showing / hiding this
one - although there are some disadvantages like missing application
icon on the taskbar, etc. I think this solution is quite lame, still it
is the only solution that works so far.

Anyone has a better idea?

Thanks,

Michal Bukovjan
XBUK...@ST.VSE.CZ

 

Re:Showing DCOM server's main form BUG ?


Untested.  All disclaimers apply.  Implement an OnCloseQuery event.  In it,
hide your form.  Set CanClose := ObjectCount = 0 which will allow the app to
close only if there are no active clients.

Quote
Xbukm03 wrote in message <3513C234.4...@vse.cz>...
>I need a running DCOM server with no visible form.

>I set Application.ShowMainForm:= false.

>Everything works OK until I want to display server status (i.e.
>connected users etc.), in other words user interface of the project,
>which is on the main form.

>Upon user request I show the main form. When the user click OK or Close
>on the form, I hide the form.

>Whatever I set in Action in the OnClose event, whatever method I
>actually call (Hide, Close), the main form ALWAYS destroys itself and
>the application terminates, including the DCOM server which runs in its
>process space, even though it has active connections !!!

>Of course, bunch of errors on the clients occur and the whole system is
>down.

>Is there anything I can do to circumvent this? The only way I could
>think of is to put the UI on a secondary form and showing / hiding this
>one - although there are some disadvantages like missing application
>icon on the taskbar, etc. I think this solution is quite lame, still it
>is the only solution that works so far.

>Anyone has a better idea?

>Thanks,

>Michal Bukovjan
>XBUK...@ST.VSE.CZ

Re:Showing DCOM server's main form BUG ?


Hello,

try this:

uses
  ComServ;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  CanClose := (ComServer = NIL) or (ComServer.ObjectCount <= 0);
  if not (CanClose) then Hide;
end;

What I'm doing here is just hiding the form if a close is requested and the
server still has outstanding references.

--
Binh Ly
Brickhouse Data Systems, Inc
http://www.brickhouse.com

Xbukm03 <Xbuk...@vse.cz> wrote in article <3513C234.4...@vse.cz>...

Quote
> I need a running DCOM server with no visible form.

> I set Application.ShowMainForm:= false.

> Everything works OK until I want to display server status (i.e.
> connected users etc.), in other words user interface of the project,
> which is on the main form.

> Upon user request I show the main form. When the user click OK or Close
> on the form, I hide the form.

> Whatever I set in Action in the OnClose event, whatever method I
> actually call (Hide, Close), the main form ALWAYS destroys itself and
> the application terminates, including the DCOM server which runs in its
> process space, even though it has active connections !!!

> Of course, bunch of errors on the clients occur and the whole system is
> down.

> Is there anything I can do to circumvent this? The only way I could
> think of is to put the UI on a secondary form and showing / hiding this
> one - although there are some disadvantages like missing application
> icon on the taskbar, etc. I think this solution is quite lame, still it
> is the only solution that works so far.

> Anyone has a better idea?

> Thanks,

> Michal Bukovjan
> XBUK...@ST.VSE.CZ

Other Threads