/* An example of FUNCDEF'ing the Windows API to present * a font dialog. */ NUMERIC DIGITS 10 OPTIONS "WINFUNC NOSOURCE C_CALL" /* ============== FUNCDEF some needed OS functions ============ */ DO /* Define a LOGFONT and CHOOSEFONT struct used with ChooseFont() */ LOGFONT = "32, 32, 32, 32, 32, 8, 8, 8, 8, 8, 8, 8, 8, str[32]" CHOOSEFONT = "32u, void, void, struct LOGFONT * stor, 32, 32u, 32u, 32u, void, void, void, void, 16u, 16u, 32, 32" /* Register the Windows OS function ChooseFont() */ FUNCDEF("ChooseFont", "32u, struct CHOOSEFONT", "comdlg32") CATCH FAILURE CONDITION("M") RETURN END /* ==================== Present the Font dialog ==================== */ /* Initialize the CHOOSEFONT struct */ ChooseFont. = 0 /* All fields default to 0 */ ChooseFont.1 = 60 /* The size of a CHOOSEFONT dialog */ /* ChooseFont.2 may be set to the handle of some window that you want * to be the owner of the font dialog */ ChooseFont.6 = 1 /* CF_SCREENFONTS */ + 65536 /* CF_FORCEFONTEXIST */ + 4 /* CF_SHOWHELP */ /* Present the dialog */ err = ChooseFont(ChooseFont) IF err \== 0 THEN DO /* Report the chosen font. ChooseFont() has filled in the LOGFONT */ SAY "Font height:" ChooseFont.4.1 SAY "Font width:" ChooseFont.4.2 SELECT WHEN ChooseFont.4.5 = 300 THEN SAY "Font weight: Light" WHEN ChooseFont.4.5 = 400 THEN SAY "Font weight: Normal" WHEN ChooseFont.4.5 = 700 THEN SAY "Font weight: Bold" OTHERWISE SAY "Font weight:" ChooseFont.4.5 END IF ChooseFont.4.6 == 1 THEN SAY "Italic" IF ChooseFont.4.7 == 1 THEN SAY "Underlined" IF ChooseFont.4.8 == 1 THEN SAY "Strike out" SAY "Font name:" ChooseFont.4.14 END ELSE SAY "ERROR: Presenting Font dialog" RETURN