void CTextInputCtrl::SetFont(HWND hwndParent) { CHOOSEFONT cf; LOGFONT lf = _lfCurrentFont; cf.lStructSize = sizeof(CHOOSEFONT); cf.hwndOwner = hwndParent; cf.lpLogFont = &lf; cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS; cf.rgbColors = RGB(0, 0, 0); cf.lCustData = 0; cf.lpfnHook = NULL; cf.lpTemplateName = NULL; cf.hInstance = NULL; cf.lpszStyle = NULL; cf.nFontType = SCREEN_FONTTYPE; cf.nSizeMin = 0; cf.nSizeMax = 0; if (ChooseFont(&cf)) { _lfCurrentFont = lf; // Level 2 Support SetCompositionFont(); InvalidateRect(_hwnd, NULL, TRUE); } }
void CImeView::InitIme(HWND hwnd) { char ga[] = "가"; SIZE size; HFONT hFont; LOGFONT lf; if(hwnd) m_hWnd = hwnd; hFont = (HFONT)SendMessage(m_hWnd,WM_GETFONT, 0, 0); if (hFont) { if (GetObject(hFont, sizeof(LOGFONT), &lf)) { SetCompositionFont(&lf); } } //m_hKeyWnd = hwnd; m_hKeyLayout = GetKeyboardLayout(0); // 0 means Current thread m_property = ImmGetProperty(m_hKeyLayout, IGP_PROPERTY); for (int i = 0; i < MAX_LISTCAND; i++) { m_hwndCand[i] = NULL; m_CandList[i] = NULL; } return; HDC hDC = ::GetDC(m_hWnd); HFONT hScrFont = (HFONT)GetStockObject(SYSTEM_FIXED_FONT); HFONT hOldFont = (HFONT)SelectObject(hDC, hScrFont); GetTextExtentPoint(hDC, (LPSTR)&ga, 2, &size); SelectObject(hDC, hOldFont); ::ReleaseDC(m_hWnd, hDC); m_charWidth = size.cx / 2; m_charHeight = size.cy; }