Path: utzoo!attcan!uunet!samsung!usc!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: modeless dialogs Message-ID: <46507@apple.Apple.COM> Date: 12 Nov 90 20:51:24 GMT References: <1990Nov9.184626.3290@hub.cs.jmu.edu> Distribution: comp Organization: Apple Computer Inc., Cupertino, CA Lines: 68 jmidili@hub.cs.jmu.edu (jeff midili) writes: >Are modeless dialogs actually dialogs or are they windows? How >do you call one? Do you create it as a dialog or a window >under resedit? > >It seems that if I declare it as a window with resedit, and create >a windowptr for it within my program, I can display the window, but >not the contents. > >If I make it a dialog with resedit, and assign a dialogptr to it >with GetNewDialog, I can show it with SelectWindow() and ShowWindow(), >but I can do anything within the event loop with it. Like close it >if the goaway box is clicked. > >What is the proper method for handling modeless dialogs???? The only difference between a modal and modeless dialog is how an app handles it. Typically a modal dialog lets you diddle some settings, but you can't do anything else outside the dialog until you click OK or Cancel (for example). A modeless dialog allows you to switch to other windows or dialogs (even modal ones), just like a regular window. Dialog windows (they *are* windows after all) are used when you have a mostly fixed set of elements to display so you don't have to deal with localization issues so much. The layout can be changed and the code in your program doesn't need to know that it did. The program just says, "well, the user pressed button 3, so I need to do this". If you use a window instead, your program needs to build up the elements itself since there's no DITL to specify what's in the window. So how do you work with a modeless dialog (modal dialogs are easy, just use ModalDialog())? Here's a snippet that will do a lot of the work: do { if (GetNextEvent(EveryEvent, &theEvent)) { if (theEvent.what == MouseDown) { switch (FindWindow(theEvent.where, &theWindow)) { case inSysWindow: SystemClick(&theEvent, theWindow); break; case inDrag: DragWindow(theWindow, theEvent.where, &dragRect); break; case inGoAway: if (TrackGoAway(theWindow, theEvent.where)) { // HideWindow(), DisposWindow(), DisposDialog(), ... // ...depends on what you want to do } break; } if (IsDialogEvent(&theEvent)) { if (DialogSelect(&theEvent, &theDialog, &itemHit)) { switch (itemHit) { case xxx: ... } } } } } while (true); steve