void CMainFrame::OnFontNameChange() { CString szText; m_wndEditBar.m_fontNameCombo.GetLBText( m_wndEditBar.m_fontNameCombo.GetCurSel(),szText); CHTMLEdView *pView = (CHTMLEdView*)GetActiveView(); ASSERT_VALID(pView); pView->SetFontFace(szText); }
HRESULT SetFont(CMainFrame* pFrame, IPropertyStore* pStore) { HRESULT hr = S_OK; // Get the HTML editor. CHTMLEdView *pView = (CHTMLEdView*)pFrame->GetActiveView(); if (pView == NULL) { return E_FAIL; } // Set Font Face. PROPVARIANT face; hr = pStore->GetValue(UI_PKEY_FontProperties_Family, &face); if (FAILED(hr)) { return hr; } CString strFontFace(face.pwszVal); hr = pView->SetFontFace(strFontFace.GetBuffer()); if (FAILED(hr)) { return hr; } PropVariantClear(&face); // Set Font Size. PROPVARIANT size; hr = pStore->GetValue(UI_PKEY_FontProperties_Size, &size); if (FAILED(hr)) { return hr; } USHORT uSize; VarUI2FromDec(&size.decVal, &uSize); hr = pView->SetFontSize(uSize - 7); if (FAILED(hr)) { return hr; } PropVariantClear(&size); return hr; }