launching on Wintel/inter-process communication

Richard Gaskin ambassador at fourthworld.com
Mon Dec 2 17:29:01 EST 2002


Chipp Walters wrote:

>> Launching an app with a document on Windows is a snap -- the
>> first time you do it.  If you run a launch command to launch
>> a given app a second time, as documented you will get an error.
> 
> Don't know if you can use this information, but...
> 
> I am able to launch multiple instances of the same REV program by clicking
> on a .rev file from a browser (see www.buttongadget.com)

My Windows Explorer is working well, I was referring to MC's launch command.
 
>> So how do we open a second document in the currently-running application
>> instance?
>> 
>> One strategy discussed here earlier is to have the app write a temp file,
>> which would be seem by a second instance which could simply let the user
>> know that the app is already running.  But the user may legitimately
>> wonder: "So what?"  It is a reasonable expectation that double-clicking
>> a document will launch the appropriate app and display the document.
> 
> Launching a second instance of the running app and loading the
> 'double-clicked' document should work. In fact, I'm sure of it. ButtonGadget
> does this. If you need registry setting code, let me know.
> Ken Ray has document association code at:
> http://www.sonsothunder.com/index2.htm?/devres/revolution/revolution.htm

That part works.  I was referring to those cases where I need to have only
one instance of the app open (see below).
 
>> It seems less reasonable, certainly less convenient, to tell them they
>> need to switch to the first instance and hunt down the document in an
>> "Open file" menu item.
> 
> Can you use DDE? Ken would know more about this...

Hmmm... I hate relying on externals, esp. using a protocol MS warns us will
be phased out.  But there are some advantages to DDE...hmmm...

> Perhaps opening a second instance with the document loaded is the correct
> way to do this.
> 
> I hate when I double-click an .htm file and it loads up in my existing
> browser window. I rather it open into it's own window.

Indeed, rude.  From the user's perspective it's more akin to the scenario in
which launchung a new instance forces the first one to quit: both involve
changing the user's world out from under them.

But if we opened the new URL in a new window, we'd present the new data
without disturbing the user's existing setup.

For single-window things like a Web browser, opening that new window in a
second instance works well.

But with my app, rather than either the single-window or multiple-window
models, mine uses something more like what the Win HIG describes as the
project model, as discussed at
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html
/ch10f.asp>.  This is arguably the closest match to Rev's model as well.

In the first of my two apps, I have an index of documents which can be opend
by clicking them in an index window.  The second app serves a different
purpose, but from time to time needs to launch documents belonging to the
first app.

In the worst case, I would accept being able to successfully launch a second
instance of the index app, but the launch command won't allow that without
quitting the first instance (and even then I've had it unable to launch--
must it hit idle?).

But really far better would be to have the index app notified so it could
open the document within itself.  That preserves the user's state, keeps
only one intance to avoid confusing the user ("Why are there two index
windows?"), and is lighter on system resources.

DDE remains on the table as an option but in addition to the reasons noted
above, the thread at
<http://www.mail-archive.com/metacard@lists.runrev.com/msg06642.html>
suggests it may be problematic.

MetaBench tells me it takes less than a millisecond to check the existence
of a file, so as horrifying as it might otherwise sound I'm leaning toward
polling, on half-second intervals, provided no one can come up with a reason
why this would not be at least functional.

Sure miss Apple events sometimes....

-- 
 Richard Gaskin 
 Fourth World Media Corporation
 Developer of WebMerge 2.1: Publish any database on any site
 ___________________________________________________________
 Ambassador at FourthWorld.com       http://www.FourthWorld.com
 Tel: 323-225-3717                       AIM: FourthWorldInc




More information about the metacard mailing list