WINCE字体动态加载

1. 加载字体

if (NULL != AddFontResource(SDBOOTDisk\\FZY3JW.ttf))
      ::SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
 else
      AfxMessageBox(L"加载方正准圆简体字体失败!");


2.创建字体并设置控件字体

 CFont hFontNew;

 LOGFONT lf;
 memset(&lf, 0, sizeof(LOGFONT));
 WCHAR lffn[]= TEXT("方正准圆简体");
 wcscpy(lf.lfFaceName,lffn);
 lf.lfHeight = 20;
 lf.lfWidth = 0;
 lf.lfQuality = CLEARTYPE_QUALITY;
 lf.lfCharSet = GB2312_CHARSET;
 hFontNew.CreateFontIndirect(&lf);
 GetDlgItem(IDC_BTN_FONT1)->SetFont(&hFontFZY3JW);

 

 3.卸载字体

if(RemoveFontResource(FZY3JW_FONT))
      ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
 else
      AfxMessageBox(L"卸载字体失败");

你可能感兴趣的:(WINCE字体动态加载)