Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!apple!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!dwal From: dwal@ellis.uchicago.edu (David Walton) Newsgroups: comp.sys.mac.misc Subject: Re: Centering Dialog Boxes on the Macintosh Message-ID: <1990Sep14.005540.13570@midway.uchicago.edu> Date: 14 Sep 90 00:55:40 GMT References: <11818@chaph.usc.edu> <378@disuns2.epfl.ch> Sender: news@midway.uchicago.edu (News Administrator) Organization: U. Chicago Computing Organizations, Academic and Public Comp. Lines: 29 In article <378@disuns2.epfl.ch> lorin@litsun.epfl.ch (Ronan-Yann Lorin) writes: >The problem is that you must use MoveWindow to move the dialog >instead of using things like (whichDialog->portRect).left = ... > > Ronan. I'm not sure what post this is in reference to, but it's quite easy to center a dialog (modal or otherwise) just by using the boundsRect field in the DialogTemplate data structure. For example: var mydialog:DialogTHndl; mydialogtemplate:=DialogTHndl(GetResource('DLOG', kdialogID)); HNoPurge(mydialogtemplate); HLock(mydialogtemplate);{ if you do any memory stuff } CenterRect(mydialogtemplate^^.boundsRect, screenRect); . . . mydialog:=GetNewDialog(kdialogID, nil, pointer(-1)); When you call GetNewDialog (assuming you've done the math correctly in CenterRect), your dialog should be centered. -- David Walton Internet: dwal@midway.uchicago.edu University of Chicago { Any opinions found herein are mine, not } Computing Organizations { those of my employers (or anybody else). }