Re: (WTL) How to handle COM EXE that displays a GUI?
One way is to decouple the UI from the business logic (e.g.
the dialog from the COM object and the startup code).
Have the dialog be brought up by both the COM object and
your startup code independently. When the dialog is dismissed
by the user you tell its owner and they react appropriately.
E.g. the COM object for example generates an event on its
outgoing interface, while your startup code closes the server.
This last bit BTW is typically done by increasing the module
ref count on startup when /Embedded switch is not present on
the command line (e.g. when the EXE was strated interactively,
not by COM) and decreasing it again when the user dismisses
the server UI. This will let the server keep running with no UI
if a COM client has attached to it in the mean time. A better
written COM UI server would check on startup if another
process already exists for it and UI-activate that process and
immediately terminate the new process. The form of IPC for
achieving that is up to you. I'd likely choose a hidden window.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Cartoper" <cartoper@gmail.com> wrote in message
news:d16ef439-cebc-43a6-80a4-73b2a2a05c1b@b15g2000hsa.googlegroups.com...
I am trying to write a COM object that what defined by people that
don't understand COM. Right now the applicaiton is a WTL EXE Server.
Under normal use, a client will instantiate the COM object and through
the COM object display a configuration dialog. The catch is that if
the user simply double clicks on the EXE the configuration dialog is
suppose to appear.
What I have done is setup the configuration dialog so that it is given
the COM object in it's constructor. So when displaying the
configuration dialog via running the EXE, first the COM object is
created before creating and showing the configuration dialog. How do
I make sure the application knows to exit when the configuration
dialog is closed?
Remember I am working with WTL so I do have my own CMessageLoop.
Cartoper