[net.micro.mac] More Problems with PICT and Scrap

llad@ur-tut.UUCP (Dennis Venable) (10/15/85)

First, I wish to thank Larry Rosenstein of Apple for responding to my earlier
plea for aid.  His comments were right on the button and fixed the problem 
with copying from my DA to the desk scrap.

I now have a couple of new problems I could use some help on. 
(Larry, are you listening?)

Again, somebody PLEASE HELP ME!!

Ok, I essentially have two problems that are related.  I have a desk accessory
that produces a PICT (picture) when copied to the desk scrap.  This can be
pasted into whatever accepts PICT's such as Word, Paint, Draw, etc.  Now I wish
to copy from the scrap back into the accessory.  I use the standard GetScrap 
and DrawPicture as follows (Aztec C):

	fromDeskScrap()
	{
	long io, offset;
	Picture **hP;
	hP = (Picture **)NewHandle(0L);
	io = GetScrap(hP,'PICT',&offset);
	if (io > 0) DrawPicture(hP,&(**hP).picFrame);
	else SysBeep(20);
	}

This essentially works for copying from Paint to the DA and Draw to DA while in
Paint and Draw but if I am in Finder or Word (which is the primary program I
wish to run my DA with) it causes a crash in the DrawPicture() routine.  I have
enclosed the GetScrap and DrawPicture calls with HLock and HUnlock to lock the
handle, I have tried not declaring hP with NewHandle but just using stack 
variables, ala

	Picture **hP, *pP;
	hP = &pP;

and get an Illegal Operation on Invalid Handle error.  I have even tried 
allocating my own stack-based heap for hP to come from, and Finder and Word 
still insist on crashing!  Any ideas will be greatly appreciated.  Word and
Finder seem to be incredibly hostile! (PS: Finder gives an Illegal Error,
Word gives an 1111 Error, whatever that is; debugger is Maxbugs)

My second problem is also related to pasting into my DA.  I wish to use
picture comments to define information that can be used in the pasting.  I 
have no problem writing the comments, but trying to install my own comment 
reading routine causes a crash.  My code is as follows:

	/* Globals */
	QDProcs qdp;
	...
	open()
	{
	void readCom();
	...
	GetPort(&myPort);
	SetStdProcs(&qdp);
	qdp.commentProc = &readCom;
	myPort->grafProcs = &qdp;
	...
	}

	readCom(...)  /* comment reading routine */
	{
	...
	}

As soon as installation code is invoked the system crashes.  Any ideas?

Thanks again for any help received.  As I said in my earlier plea for aid,
either personal responses or net responses are gratefully accepted, as long as
I get responses!

Thanks again!
/Dennis Venable
{allegra,seismo,decvax}!rochester!ur-tut!llad