Change the font in dialog and alert windows
Static texts in dialogs can be changed using standard FB if you set the dialog window to be the current window port.
' FB II code oldRes = FN CURRESFILE ' get current res file CALL USERESFILE (gAppRef%) ' apps res fork CALL GETPORT (oldport&) ' get FB window grafport Dlg&=FN GETNEWDIALOG(303,0,-1) 'get hndl for DLOG resource LONG IF Dlg& > 0 'valid handle? CALL SETPORT(Dlg&) 'set grafport CALL SELECTWINDOW (Dlg&) 'set output to DLOG window CALL TEXTFONT (2) ' set font for static texts CALL TEXTSIZE (10) ' set text size for static texts CALL DRAWDIALOG(Dlg&) 'draw DLOG window on screen DO CALL MODALDIALOG (0, butn%) 'get input from DLOG window UNTIL butn% = 1 CALL DISPOSDIALOG (Dlg&) ' dispose of dialog CALL SETPORT (oldport&) ' set port back to FB window CALL USERESFILE (oldRes) ' set res file to previous res file END IF
Al Staffieri Jr.
Well, the solution turned out to be pretty simple. This will change the font of both the static and edit text items and, I presume, alert boxes.
% _dlgFont,_helveticaTo restore the system font for someone else's dialog boxes:
% _dlgFont,0There doesn't seem to be an easy way of changing the size or style of the edit text. I suppose you could manually get the handles to all the edit fields in the dialog box and poke the desired values into the text edit fields, but this would be a lot of work. You would have to write a routine which cycled through all the items in the dialog, checked the item type, and worked only with items that were of the type editable text. The routine would looksomething like this:
LOCAL FN SetFontSize(dPtr&) item%=0 DO INC(item%) CALL GETDITEM (dPtr&,item%,dItmType%,dItmH&,dItmRect) LONG IF dItmH&>0 AND dItmType%=_editText dItmH&..txFont%=_helvetica dItmH&..txSize%=12 END IF UNTIL dItmH&=0 END FNYou would also have to set the font and size of the active edit field:
dPtr&.textH..txFont%=_helvetica dPtr&.textH..txSize%=12I haven't tried this so the values of the constants need to be checked against those in the dialog record and edit record. I don't this FB always uses the same values as IM. It also would skip over any items that were disabled.