[comp.sys.mac.programmer] Sublaunching ???

finnegan@dhw68k.cts.com (Greg Finnegan) (12/11/90)

We just added sublaunching to our application and everything works
fine so far.  However, if you sublaunch to another application (with
a document that you want to open) and that application is already
running under MultiFinder, the application just comes to the front.
Apparently, MultiFinder does some low level mucking to allow
sublaunching to open apps with a document.

Anybody have any ideas how I might do the same?

Greg.

-- 

uucp: ...{spsd,zardoz,felix}!dhw68k!finnegan
InterNet: finnegan@dhw68k.cts.com
--------------------------------------------

russotto@eng.umd.edu (Matthew T. Russotto) (12/12/90)

In article <1990Dec11.004705.20759@dhw68k.cts.com> finnegan@dhw68k.cts.com (Greg Finnegan) writes:
>
>We just added sublaunching to our application and everything works
>fine so far.  However, if you sublaunch to another application (with
>a document that you want to open) and that application is already
>running under MultiFinder, the application just comes to the front.
>Apparently, MultiFinder does some low level mucking to allow
>sublaunching to open apps with a document.
>
>Anybody have any ideas how I might do the same?
>
>Greg.

Yes, but not many (I've tried).  The OSDispatch trap is what does it, I
believe--- if you can figure out its format, you can do it.
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
     .sig under construction, like the rest of this campus.

mystone@mondo.engin.umich.edu (Dean Yu) (12/13/90)

In article <1990Dec12.155057.5967@eng.umd.edu> russotto@eng.umd.edu (Matthew T. Russotto) writes:
>In article <1990Dec11.004705.20759@dhw68k.cts.com> finnegan@dhw68k.cts.com (Greg Finnegan) writes:
>>
>>We just added sublaunching to our application and everything works
>>fine so far.  However, if you sublaunch to another application (with
>>a document that you want to open) and that application is already
>>running under MultiFinder, the application just comes to the front.
>>Apparently, MultiFinder does some low level mucking to allow
>>sublaunching to open apps with a document.
>>
>>Anybody have any ideas how I might do the same?
>>
>>Greg.
>
>Yes, but not many (I've tried).  The OSDispatch trap is what does it, I
>believe--- if you can figure out its format, you can do it.

  I was going to suggest that you fill the AppParmHandle low memory global
with the information needed for the application to open the documents, but
then I realised that you wanted to open those documents from an application
that was already running.
  This is how I understand MultiFinder makes applications open documents;
whether you can use this info or not is questionable, but it's interesting
nevertheless.
  When you double-click on a document in the Finder and the application which
created that document is already running, MultiFinder switches it into the
foreground.  MultiFinder then searches your menus for an Open item in the
File menu.  If you don't have an Open in the standard place, MultiFinder
looks for 'mstr' and 'mst#' resources in the application to tell it where the
Open item is.
  Once it finds that item, it calculates where on the screen that item would
be if the menu were pulled down.  It posts a mouseDown event in the menu bar
over the menu title, and a mouseUp event over the menu item.  A patch on
_MenuSelect is installed so you don't see the menu pop down briefly.
  A patch is also installed on _Pack3 (Standard File).  This patch doesn't
bring up the Standard File dialog, but simply returns an SFReply record
containing information for the document you double clicked on in the Finder.
  That's all there is to it!

_______________________________________________________________________________
Dean Yu                            | E-mail:    mystone@mondo.engin.umich.edu
Patches 'R' Us                     | Real-mail: Dean Yu
A Division of Cyberite Systems     |            909 Church St Apt C
                                   |            Ann Arbor, MI 48104
I'm not the voice of Reason, much  | Phone:     313 662-4073
    less the voice of Cyberite.    |            313 662-4163
-------------------------------------------------------------------------------

daven@svc.portal.com (12/13/90)

In article <1990Dec11.004705.20759@dhw68k.cts.com> finnegan@dhw68k.cts.com (Greg Finnegan) writes:
>
>We just added sublaunching to our application and everything works
>fine so far.  However, if you sublaunch to another application (with
>a document that you want to open) and that application is already
>running under MultiFinder, the application just comes to the front.
>Apparently, MultiFinder does some low level mucking to allow
>sublaunching to open apps with a document.
>
>Anybody have any ideas how I might do the same?

What MultiFinder does at the low level is "fake" menu hits on "Open..." in
the file menu. I assume it also then fakes out the application's call to
SFGetFile to just return the document that needs to be opened.

Apple requires applications with unusual "Open" menu items supply a resource
in the application of type MSTR. These tell MultiFinder what the menu items
actual text is.


-- 
-------------------------------------------------------------------------------
   Dave Newman              |  daven@svc.portal.com        |  AppleLink: D0025
   Sofware Ventures Corp.   |  AOL: MicroPhone             |  CIS: 76004,2161
   Berkeley, CA  94705      |  WELL: tinman@well.sf.ca.us  |  (415) 644-3232

leonardr@svc.portal.com (Leonard Rosenthol) (12/13/90)

In article <1990Dec12.193848.14629@engin.umich.edu>,
mystone@mondo.engin.umich.edu (Dean Yu) writes:
>   When you double-click on a document in the Finder and the application which
> created that document is already running, MultiFinder switches it into the
> foreground.  MultiFinder then searches your menus for an Open item in the
> File menu.  If you don't have an Open in the standard place, MultiFinder
> looks for 'mstr' and 'mst#' resources in the application to tell it where the
> Open item is.
>   Once it finds that item, it calculates where on the screen that item would
> be if the menu were pulled down.  It posts a mouseDown event in the menu bar
> over the menu title, and a mouseUp event over the menu item.  A patch on
> _MenuSelect is installed so you don't see the menu pop down briefly.
>   A patch is also installed on _Pack3 (Standard File).  This patch doesn't
> bring up the Standard File dialog, but simply returns an SFReply record
> containing information for the document you double clicked on in the Finder.
>   That's all there is to it!
> 
	Since I have never seen the MF code, I can't say whether you are
completely correct, Dean, but I do know that when I have reimplemented this
for a 'launching utility', I didn't bother with the item location.
	Due to the presence of the _MenuSelect patch, you only need to post
the mouseDown into the menu bar, causing the app to call MenuSelect, and
then your patch can just return whatever it wants - no need for the item
calculation!  The _Pack3 patch does indeed work as noted.

--
----------------------------------------------------------------------
+ Leonard Rosenthol              | Internet: leonardr@sv.portal.com  +
+ Software Ventures              | GEnie:    MACgician               +
+ MicroPhone II Development Team | AOL:      MACgician1              +
----------------------------------------------------------------------

peirce@outpost.UUCP (Michael Peirce) (12/13/90)

In article <1990Dec12.155057.5967@eng.umd.edu>, russotto@eng.umd.edu (Matthew T. Russotto) writes:
> 
> In article <1990Dec11.004705.20759@dhw68k.cts.com> finnegan@dhw68k.cts.com (Greg Finnegan) writes:
> >
> >We just added sublaunching to our application and everything works
> >fine so far.  However, if you sublaunch to another application (with
> >a document that you want to open) and that application is already
> >running under MultiFinder, the application just comes to the front.
> >Apparently, MultiFinder does some low level mucking to allow
> >sublaunching to open apps with a document.
> >
> >Anybody have any ideas how I might do the same?
> >
> >Greg.
> 
> Yes, but not many (I've tried).  The OSDispatch trap is what does it, I
> believe--- if you can figure out its format, you can do it.

Warning: if you plan of mucking with OSDispatch note that Apple has
changed is significantly with System 7.  Since it's not documented,
there are free to do this. They even changed with again from System
7.0a7 to System 7.0b1.  

-- michael


--  Michael Peirce         --   {apple,decwrl}!claris!outpost!peirce
--  Peirce Software        --   Suite 301, 719 Hibiscus Place
--  Macintosh Programming  --   San Jose, California 95117
--         and Consulting  --   (408) 244-6554