LRESULT DlgSettingsAppearance::OnClickedBtnBrowseFont(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { DoDataExchange(DDX_SAVE); LOGFONT lf; ::ZeroMemory(&lf, sizeof(LOGFONT)); wcsncpy_s(lf.lfFaceName, _countof(lf.lfFaceName), LPCTSTR(m_strFontName), 32); lf.lfHeight = -MulDiv(m_fontSettings.dwSize, GetDeviceCaps(::GetDC(NULL), LOGPIXELSY), 72); lf.lfWeight = (m_nFontBold > 0) ? FW_BOLD : FW_NORMAL; lf.lfItalic = static_cast<BYTE>(m_nFontItalic); CFontDialog fontDlg(&lf, CF_FIXEDPITCHONLY|CF_SCREENFONTS); if (fontDlg.DoModal() == IDOK) { m_strFontName = fontDlg.GetFaceName();// fontDlg.m_lf.lfFaceName; m_fontSettings.dwSize= static_cast<DWORD>(static_cast<double>(-fontDlg.m_lf.lfHeight*72)/static_cast<double>(GetDeviceCaps(::GetDC(NULL), LOGPIXELSY)) + 0.5); m_nFontBold = fontDlg.IsBold() ? 1 : 0; //(fontDlg.m_lf.lfWeight == FW_BOLD) ? 1 : 0; m_nFontItalic = fontDlg.IsItalic() ? 1 : 0; // fontDlg.m_lf.lfItalic; DoDataExchange(DDX_LOAD); } return 0; }
void ViewFilesDialog::OnFviewFont(void) { // Choose a font, then apply the choice to all of the text in the box. LOGFONT logFont; CFont font; /* * Create a LOGFONT structure with the desired default characteristics, * then use that to initialize the font dialog. */ CreateSimpleFont(&font, this, fTypeFace, fPointSize); font.GetLogFont(&logFont); CFontDialog fontDlg(&logFont); fontDlg.m_cf.Flags &= ~(CF_EFFECTS); if (fontDlg.DoModal() == IDOK) { //fontDlg.GetCurrentFont(&logFont); fTypeFace = fontDlg.GetFaceName(); fPointSize = fontDlg.GetSize() / 10; LOGI("Now using %d-point '%ls'", fPointSize, (LPCWSTR) fTypeFace); NewFontSelected(false); } }