minigui 的中文字体部署及支持&窗口模态、非模态

一、minigui支持ttf字体

1.1 首先我们准备两个素材

song-gb2312.ttf gb2312编码的中文字体库
times.ttf ISO8859编码英文字符串

1.2 将其添加到 MiniGUI.cfg

[truetypefonts]
font_number=2
name0=ttf-fixed-rrncnn-0-0-GB2312-0
fontfile0=/mnt/minigui_debug/res/font/song-gb2312.ttf
name1=ttf-times-rrncnn-0-0-ISO8859-1
fontfile1=/mnt/minigui_debug/res/font/times.ttf

name#n (name0)字段ttf(字体类型)-fixed(字体索引名称)-rrncnn-0-0-GB2312(编码格式)-0
fontfile#n (fontfile0) 字库路径

1.3 代码编写

1、加载字体

    logfontTimes = CreateLogFont(FONT_TYPE_NAME_SCALE_TTF,"times", FONT_CHARSET_ISO8859_1,
                     FONT_WEIGHT_BOOK, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,
                     FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,
                     24, 0);
    logfontSong = CreateLogFont(FONT_TYPE_NAME_SCALE_TTF, "fixed", FONT_CHARSET_GB2312_0,
                    FONT_WEIGHT_DEMIBOLD, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,
                    FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,
                    24, 0);

2、输出字符串

   static void TextOutSongTTF(HDC hdc, PLOGFONT fontType, int x, int y, char* str,unsigned long colorType)
	{
    SelectFont(hdc, fontType); //字体句柄
    SetBkMode(hdc, BM_TRANSPARENT); //背景颜色
    SetTextColor(hdc, colorType); //字符颜色
    TextOut(hdc, x, y, str); //输出位置及字符串内容
	}          
  TextOutSongTTF(hdc,logfontSong,50,20,(char*)"你好",COLOR_lightwhite); //char* 字符串必须是GB2312编码的中文

注意:字符串必须是GB2312编码的中文

二、模态和非模态窗口

模态的dialog创建接口是 modal 模式接口,就是调用该接口创建的窗口不会返回,一直阻塞在调用的接口处,直到窗口消息进行close销毁。这样设计的目的应该就是为了窗口置顶来处理所有的交互事件。

    brief Creates a modal dialog box from a dialog box template 
    in memory and other information.
     
    MG_EXPORT int GUIAPI DialogBoxIndirectParamEx (PDLGTEMPLATE pDlgTemplate,
    HWND hOwner, WNDPROC DlgProc, LPARAM lParam,
    const char* werdr_name, WINDOW_ELEMENT_ATTR* we_attrs,
    const char* window_name, const char* layer_name); 

非模态窗口创建接口 modeless 非模态的窗口创建,用于单页面拼接窗口的情况。

	brief Uses a dialog template and other information to create a modeless main 
	window and controls in it, and pass a parameter to the window procedure.
	
    MG_EXPORT HWND GUIAPI CreateMainWindowIndirectParamEx (PDLGTEMPLATE pDlgTemplate,
    HWND hOwner, WNDPROC WndProc, LPARAM lParam,
    const char* werdr_name, WINDOW_ELEMENT_ATTR* we_attrs,
    const char* window_name, const char* layer_name);

这篇文章主要补充了minigui的一些细节问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值