[comp.sys.mac.programmer] Copy to clipboard in MultiFinder

fang@dukempd.phy.duke.edu (Fang Zhong) (11/10/88)

	The following codes put a PICT drawing into the clipboard.
It works fine in Finder, but it fails to do the job in
MultiFinder. Can any shed a light on this problem?  Thanks.


	PicHandle = toolbx (OPENPICTURE,rect)
	.../drawing commands/....
	call toolbx (CLOSEPICTURE)

	  clipboard = toolbx(ZEROSCRAP)	    !copy pict to clipboard
	  call toolbx(HLOCK,PicHandle)
	  ptrsize = toolbx(GETHANDLESIZE,PicHandle)
	  pictptr = LONG(PicHandle)
	  clipboard = toolbx(PUTSCRAP,ptrsize,'PICT',pictptr)
	  call toolbx(HUNLOCK,PicHandle)

anson@spray.CalComp.COM (Ed Anson) (11/10/88)

In article <737@dukempd.phy.duke.edu> fang@dukempd.phy.duke.edu (Fang Zhong) writes:
>
>	The following codes put a PICT drawing into the clipboard.
>It works fine in Finder, but it fails to do the job in
>MultiFinder. Can any shed a light on this problem?  Thanks.

There was a Tech Note on this subject some time ago, but I can't recall the
number.

The long and short of it is this: MultiFinder checks for selection of a 
menu item Edit/Copy. If this has not occurred, it doesn't bother moving the
scrap to the other partition when switching applications. The assumption is
that copying to the scrap is a user-initiated function.

In other words, you can probably read back the scrap in the same application
that wrote it, but not in another. Of course, that's probably not what you
want to do.

The best workaround I have found is to call MenuKey with a 'C'. This makes
MultiFinder think the user did a Copy (assuming the menu item is present).

I hope this helps.
-- 
=====================================================================
   Ed Anson,    Calcomp Display Products Division,    Hudson NH 03051
   (603) 885-8712,      anson@elrond.CalComp.COM

wdh@well.UUCP (Bill Hofmann) (11/13/88)

<<Discussion of why a copy to the scrap didn't seem to work, with the
  suggestion of doing a MenuKey passing 'C'.>>

I ran into this problem some ways back, and after beating my head against
the wall for literally days, discovered what was documented (later) in
one of the Multifinder tech notes.  Multifinder maintains scraps for each
application, and copies from one to another only if it is "primed" for the
copy.  What primes it is a call to SystemEdit with the proper argument
(check IM I-441) for Copy.  I had to do this for my special menu item
Copy Table even though I never had it highlighted when a system window
(ie, DA window) was frontmost.  A little screwed up, but I suppose there
are reasons.

-Bill Hofmann