Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: Basic DLOG/DITL question Message-ID: <51596@apple.Apple.COM> Date: 17 Apr 91 01:15:40 GMT References: <17230@burdvax.PRC.Unisys.COM> Organization: Apple Computer Inc., Cupertino, CA Lines: 58 dave@PRC.Unisys.COM (David Lee Matuszek) writes: >OK, I'm missing something really fundamental here. > >[...explains that he has a DLOG and a DITL with buttons and stuff...] > >In THINK Pascal 3.0 I call > > myDialog := GetNewDialog(128, nil, WindowPtr(-1)); > >and the DLOG window appears. But nothing appears in the window. > >[...talks about changing text items and drawing buttons and only they show > up...] What you're missing is that just because you now have a dialog, it's not going to automatically draw all the stuff in the window. Calling GetNewDialog just causes the dialog's window to appear (if it's visible). To cause the items to be drawn and to handle clicking on buttons, you need to call ModalDialog() or IsDialogEvent()/DialogSelect(), depending on if your dialog is modal or not. For the modal case, you could do something like this: myDialog := GetNewDialog(128, nil, WindowPtr(-1)); IF myDialog <> nil THEN BEGIN REPEAT ModalDialog(nil, itemHit); CASE itemHit OF ... {handle any enabled items as you wish} END; UNTIL itemHit = OK; DisposDialog(myDialog); END; This is the kind of thing you'd do when someone selects a menu item, for example, and you want to let them tweak some stuff, click OK, and let the changes take effect. If you want to have a moveable dialog where you can click on menus, other windows, etc., you need to do something like this: REPEAT IF GetNextEvent(EveryEvent, myEvent) THEN BEGIN ... {do any pre-processing here, i.e., clicks in the menu bar} IF IsDialogEvent(myEvent) THEN IF DialogSelect(myEvent, theDialog, itemHit) THEN CASE itemHit OF ... {handle any enabled items as you wish} END; END; UNTIL FALSE; ModalDialog essentially has this code built into it, but you're stuck there until the user does something. Check out the Dialog Manager chapter of Inside Macintosh, volume 1 for more detailed info... steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen Never hit a man with glasses. stevec@apple.com Hit him with a baseball bat.