Guidance
指路人
g.yi.org
Software / Reginald / Examples / fontdlg.rex

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* 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
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2017-6-23  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:50