//IconFont
LOGFONT logFont;
int size = sizeof(LOGFONT);
bool isGood = SystemParametersInfo(SPI_GETICONTITLELOGFONT,size,&logFont,0);
if(isGood == true)
{
CFont * f;
f = new CFont;
const LOGFONT* pFont = new LOGFONT(logFont);
f->CreateFontIndirectW(pFont);
//::EnumChildWindows(m_hWnd, ::SetChildFont, (LPARAM)f);
}
//other Font
NONCLIENTMETRICS ncm = new NONCLIENTMETRICS();
bool isGood = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), ref ncm, 0);
if (isGood == true)
{
LOGFONT logFont2;
//logFont2=ncm.lfntCaptionFont);//CaptionFont
//logFont2 =ncm.lfntSMCaptionFont;//CaptionFont_Small
//logFont2 = ncm.lfntMenuFont;//MenuFont
//logFont2 = ncm.lfntStatusFont;//StatusFont
logFont2 = ncm.lfntMessageFont;//MessageFont
CFont * f;
f = new CFont;
const LOGFONT* pFont = new LOGFONT(logFont2);
f->CreateFontIndirectW(pFont);
//::EnumChildWindows(m_hWnd, ::SetChildFont, (LPARAM)f);
}
以上是取得系统字体的大小,然后再调用上面的第二种方法!
窗体上的所有字体都会跟着系统字体的大小改变!