Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Colors and Fonts : Allowing the user to change colors and fonts : Font dialog box example
 
Font dialog box example
The i-fdial1.p procedure opens the dialog box that allows you to separately change the font of either its radio set or buttons to a custom font.
i-fdial1.p
IF FONT-TABLE:NUM-ENTRIES < 13 THEN
  FONT-TABLE:NUM-ENTRIES = 13.

DEFINE VARIABLE ButtonFont AS INTEGER NO-UNDO INITIAL 12.
DEFINE VARIABLE FontSelect AS INTEGER NO-UNDO INITIAL 11
  VIEW-AS RADIO-SET RADIO-BUTTONS "Radio Font", 11, "Button Font", 12
  FONT RadioFont.
DEFINE VARIABLE RadioFont AS INTEGER NO-UNDO INITIAL 11.

DEFINE BUTTON bCANCEL LABEL "CANCEL" FONT ButtonFont.
DEFINE BUTTON bOK     LABEL "OK"     FONT ButtonFont.

FORM
  SKIP(0.5) SPACE(0.5) FontSelect SPACE(2) bOK SPACE(2) bCANCEL
  SPACE(0.5) SKIP(0.5)
  WITH FRAME fFont TITLE "Choose frame fonts ..." VIEW-AS DIALOG-BOX.

ON CHOOSE OF bOK IN FRAME fFont DO
  ASSIGN FontSelect.
  SYSTEM-DIALOG FONT FontSelect.
END.

ON CHOOSE OF bCANCEL IN FRAME fFont STOP.

ENABLE FontSelect bOK bCANCEL WITH FRAME fFont.

WAIT-FOR WINDOW-CLOSE OF FRAME fFont.
When you run this procedure in Windows, the following dialog box appears:
When you run the procedure, the radio set displays in the default MS Sans Serif font and buttons display in the default Courier New font. To change a font, select the Radio Font (font 11) or Button Font (font 12) radio item, then click OK to open the font dialog box shown in the following figure. Click CANCEL to terminate the procedure without any further font changes.
To change the radio-set font selected in the Figure 31 figure to bold 8-point Arial, set up the Font dialog as shown in the following figure.
Figure 32. Changing font 11 to bold 8-point Arial
After you click OK, the Choose frame fonts dialog box reappears with the radio set in the new font. For example: