英文系统wince在程序中动态加载字库显示汉字

1.加载字库及创建字体


        
#define FONTPATH _T("\\Windows\\SIMSUN.TTC")
        
int cnt;
	cnt = AddFontResource(FONTPATH);
	if (cnt == 0)
	{
		return (GetLastError());
	}
	::SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0);

	LOGFONT lf;  
	memset(&lf,0,sizeof(LOGFONT));  
	lf.lfHeight = 12;  
	lf.lfWidth = 0;  
	lf.lfWeight = FW_NORMAL;  
	lf.lfCharSet = GB2312_CHARSET;  
	lf.lfOutPrecision= OUT_DEFAULT_PRECIS;  
	lf.lfClipPrecision= CLIP_STROKE_PRECIS;  
	lf.lfQuality = ANTIALIASED_QUALITY;  
	lf.lfPitchAndFamily= DEFAULT_PITCH|FF_MODERN;  
	_tcscpy(lf.lfFaceName, _T("SIMSUN"));  
	m_hfont = CreateFontIndirect(&lf); 

其中m_hfont的定义为 HFONT m_hfont;


2.在控件上显示汉字

CEdit *pedit;

        pedit = (CEdit*)GetDlgItem(IDC_EDIT1);
	pedit->SetFont(CFont::FromHandle(m_hfont));
	pedit->SetWindowText(_T("这是加载字体后显示的汉字。"));


你可能感兴趣的:(英文系统wince在程序中动态加载字库显示汉字)