Dinamicaly changing window font
-
Anybody knows how to change window (or dialog window) font in Visual C++ after it has been created? Thank you, Goran
-
Anybody knows how to change window (or dialog window) font in Visual C++ after it has been created? Thank you, Goran
Hi! You need to send the WM_SETFONT message to the window. See MSDN for more details... Regards, Alex Gorev, Dundas Software.
-
Anybody knows how to change window (or dialog window) font in Visual C++ after it has been created? Thank you, Goran
Here is sample for dialog.. // get dialog font and create thin variation for control contents HFONT hFont = (HFONT)::SendMessage(m_hWnd, WM_GETFONT, 0, 0L); if( hFont ){ LOGFONT lf; ::GetObject(hFont, sizeof(LOGFONT), &lf); lf.lfWeight = FW_LIGHT; // check for attached font object already existing if( m_cfFont.m_hObject || m_cfFont.CreateFontIndirect(&lf) ){ // if supposed to set the thin font if( m_bThinFont ){ OnSetFont((CFont *)&m_cfFont); } } } void CGCDialog::OnSetFont(CFont *pFont) { HWND hWndChild = ::GetWindow(GetSafeHwnd(), GW_CHILD); while( hWndChild ){ CWnd::FromHandle(hWndChild)->SetFont(pFont); hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT); } }