[comp.sys.mac.programmer] informational dialog help

sam@neoucom.UUCP (Scott A. Mason) (12/08/89)

I would like to request some help for a sticky little problem I've run
into.

I would like to display an informational dialog box that contains
predefined static text items only.  While this box is on the screen, I want
to call a few procedures in my C program.  When the procedures finish, I
want the box to go away.  Sounds pretty simple.

I've tried doing this already, and I either get a nice informational dialog
box that stays on the screen, and doesn't perform the procedures, or I get
an empty dialog box (no static text items were drawn) and the procedures
execute and the box goes away.

Running a Mac SE, Think C 3.02, System 6.0.4.
Thnanks in advance.
-- 
--------------------------------------------------------------------------------
"If it ain't broke, don't fix it," and certainly don't blame me.
UUCP:  {pitt,scooter,hal,cwjcc,aablue}!neoucom!sam   INTERNET:  sam@neoucom.EDU
Scott A. Mason, Coordinator of Systems Operations, NEOUCOM

oster@dewey.soe.berkeley.edu (David Phillip Oster) (12/09/89)

In article <1850@neoucom.UUCP> sam@neoucom.UUCP (Scott A. Mason) writes:
>I would like to display an informational dialog box that contains
>predefined static text items only.  While this box is on the screen, I want
>to call a few procedures in my C program.  When the procedures finish, I
>want the box to go away.  Sounds pretty simple.

Handle GetDIHandle(i)Integer i;{
	short theType;
	Handle theHandle;
	Rect theRect;

	GetDItem(thePort, i, &theType, &theHandle, &theRect);
	return theHandle;
}

DialogPtr gMesgDia;

BeginMessage(){
	GrafPtr savePort;

	GetPort(&savePort);
	if(NIL == (gMesgDia = GetNewDialog(resID, NIL, (WindowPtr) -1L))){
		return;
	}
	SetPort(gMesgDia);
	SetIText(GetDIHandle(textITEM), (StringPtr) "\pYour message here.");
	ShowWindow(thePort);
	DrawDialog(thePort);
	SetPort(savePort);
}

EndMessage(){
	if(NIL != gMesgDia){
		DisposDialog(gMesgDia);
		gMesgDia = NIL;
	}
}


Now, just say:
BeginMessage();
... do your work ...
EndMessage();

You might also look at your event loop, and see if you are calling
isDialogEvent() and DialogSelect() there.  You should be. See Inside Mac
for more info on those two calls.

--- David Phillip Oster            --  No, I come from Boston. I just work
Arpa: oster@dewey.soe.berkeley.edu --  in cyberspace.
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu