Path: utzoo!attcan!uunet!cs.utexas.edu!usc!chaph.usc.edu!nunki.usc.edu!talcott From: talcott@nunki.usc.edu (Adam Talcott) Newsgroups: comp.sys.mac.misc Subject: Centering Dialog Boxes on the Macintosh Summary: How can I center a dialog box? Message-ID: <11818@chaph.usc.edu> Date: 4 Sep 90 15:24:04 GMT Sender: news@chaph.usc.edu Organization: University of Southern California, Los Angeles, CA Lines: 42 Nntp-Posting-Host: nunki.usc.edu Over the summer I began to learn to use the Macintosh Toolbox. I have begun writing my first piece of Macintosh software and have stumbled into one problem. I understand that Apple's Interface Guidelines requires dialog boxes to be centered horizontally and have one-third of the screen above the dialog and two thirds of the screen below. My problem is I can center the border of the dialog to conform to these standards, but the contents of the dialog box do not move!! What do I do to move this? The following are the lines of code I use (in THINK C): CenterDialog( whichDialog ) DialogPtr whichDialog; { Rect dialogRect; int dialogWidth, dialogHeight, screenWidth, screenHeight; if ( whichDialog != NIL_POINTER ) { screenWidth = ( screenBits.bounds ).right - ( screenBits.bounds ).left; screenHeight = ( screenBits.bounds ).bottom - ( screenBits.bounds ).top; dialogWidth = ( whichDialog->portRect ).right - ( whichDialog->portRect ).left; dialogHeight = ( whichDialog->portRect ).bottom - ( whichDialog->portRect ).top; /* Center horizontally */ ( whichDialog->portRect ).left = ( screenWidth - dialogWidth ) / 2; ( whichDialog->portRect ).right = ( whichDialog->portRect ).left + dialogWidth; /* Place one-third of screen above, two-thirds of screen below dialog */ ( whichDialog->portRect ).top = ( screenHeight - dialogHeight ) / 3; ( whichDialog->portRect ).bottom = ( whichDialog->portRect ).top + dialogHeight; } } Any help is greatly appreciated (if you didn't understand, e-mail and I'll attempt to explain it better). -- | Adam Talcott | Not a bad bit of rescuing, | | talcott@nunki.usc.edu | huh? You know, sometimes I | | Electrical Engineering (Computers) Senior | even amaze myself. | | University of Southern California | --Han Solo |