r2 - 21 Feb 2009 - 00:30:02 - FeynmanHejianYou are here: TWiki >  Products Web > MiniGUIFAQV204 > MiniGUIFAQV204P14

MiniGUI 2.0.4/1.6.10常见问题及解答之控件使用

1 如何修改控件使用的字体?

1.1 较短回答

如果您要改变控件的字体,则有如下两种途径:全局修改和特定修改。全局修改时,通过修改 MiniGUI 的运行时配置选项完成,所有控件将使用这个字体来显示文本;特定修改时使用 SetWindowFont 函数指定某个控件使用特定的逻辑字体,您需要首先创建这个逻辑字体,并负责在不需要时销毁该逻辑字体。

1.2 完整回答

1.2.1 全局修改

修改 MiniGUI 运行时配置选项,在 [systemfonts] 段中创建您希望的字体,并指定 control 参数使用这个字体。比如,您希望所有控件使用 12 点阵字体,则可以如下修改:

 [systemfont]
 font_number=6
 font0=rbf-fixed-rrncnn-8-16-ISO8859-1
 font1=*-fixed-rrncnn-*-16-GB2312
 font2=*-Courier-rrncnn-*-16-GB2312
 font3=*-SansSerif-rrncnn-*-16-GB2312
 font4=*-Times-rrncnn-*-16-GB2312
 font5=*-Helvetica-rrncnn-*-12-GB2312
 
 default=0
 wchar_def=1
 fixed=1
 caption=2
 menu=3
 control=5

在上面的配置中,font5 是要建立的逻辑字体名称,其中指定了字体的大小是 12 点阵,control=5 则指定了控件使用 font5 创建的逻辑字体。

1.2.2 特定修改

在创建控件后,使用函数 SetWindowFont? (hWnd,font) 修改控件使用的字体,您需要首先调用 CreateLogFont 函数创建所需要的逻辑字体。比如,你希望改变某个按钮所使用的字体,则可以如下编写代码:

static PLOGFONT my_button_font;

...

my_button_font = CreateLogFontByName ("*-Helvetica-rrncnn-*-12-GB2312");
if (my_button_font)
SetWindowFont (my_button, my_button_font);

...

DestroyLogFont (my_button_font);

1.2.3 例外

MiniGUI 中,某些控件的字体是不可动态修改的,比如 simedit 控件。这个控件使用系统逻辑字体中的 fixed 逻辑字体,因此,我们只能通过修改运行时配置选项来达到改变该类控件所使用字体的目的,而无法指定某个特定的 simedit 控件所使用的字体。

-- FeynmanHejian - 20 Feb 2009

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the Feynman Software and/or the contributing authors. All material on this collaboration platform is the property of Feynman Software and/or the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback