Path: utzoo!attcan!uunet!mcsun!isgate!krafla!aries From: aries@rhi.hi.is (Reynir Hugason) Newsgroups: comp.sys.mac.programmer Subject: Re: Setting Fonts in Dialogs Message-ID: <1632@krafla.rhi.hi.is> Date: 11 Apr 90 14:17:57 GMT References: <1739@cybaswan.UUCP> Organization: University of Iceland Lines: 67 >>I have been trying to set the font of an editText item in a dialog box by >>getting the handle to the item and setting its txFont field. The problem is >>the dialog seems to just ignore this and carry on using the system font. >>Is it possible to change the font in a dialog, if so how do you do it? Of course it is possible but how you do it really depends on what requirements you have. Here are three possible solutions. 1. If you have many editText items and just want to change one of them you can use the ictb or the method Amanda suggested with the userItems. Perhaps its better, if you have many editTexts, to throw them away altogether and use userItems instead; but then again perhaps its even better to throw the dialog manager away in such a case and simply do-it-yourself, because it isn't a user-interface (at least not a very good one :-)). 2. If you want to change all of the editText items its best to do the following: myDialog:=GetNewDialog(whatEver,NIL,Pointer(-1)); TextFont(myNewFont); TextSize(myNewSize); TextFace(myNewFace); GetFontInfo(fInfo); WITH DialogPeek(myDialog)^.textH, fInfo DO BEGIN txFont:=myNewFont; txSize:=myNewSize; txFace:=myNewFace; { you can skip this lineHeight calculation but we } { european users will hate you for it! } fontAscent:=ascent; lineHeight:=ascent+descent+leading; END; ShowWindow(myDialog); If you want the editText to be in say GENEVA 9pt and the static to be in CHICAGO 12pt you could make all the static text into PICTs and use the method described above. 3. You can call SetDAFont; BUT NOTE WHAT IM HAS TO SAY ABOUT IT! For subsequently created dialogs and alerts, SetDAFont causes the font of the dialog or alert window's grafPort to be set to the font having the specified font number. THIS ALTERNATIVE IS NOT A VERY GOOD ONE, at least I don't think it is! For example if you have to do some data validation: When the user enters something invalid into your editText items and clicks on OK you will want to display a friendly alert box in order to inform the poor fellow of his/her mistakes. This means you will have to call SetDAFont twice!! I hope this answers your question. ============================================================================== Mimir R. (aries@rhi.hi.is) | Taeknigardur, Dunhaga 5 | Programmers get overlaid (ehem, that is to say..) IS-105, Reykjavik | ICELAND | DISCLAIMER: Who me?! ==============================================================================