简体   繁体   中英

MFC feature pack - How to get the font, style and size using CMFCPropertyGridProperty::GetValue

By using CMFCPropertyGridProperty::GetValue I'm able to get the contents of the property grid.

I have one property though that gets the font, where when you click on it, shows a dialog box to select the font, size and style.

Using this code:

CMFCPropertyGridProperty* pCurSel = m_wndPropList.GetCurSel();

CString test = pCurSel->GetValue();

I'm able to get the string on the field, However if you get the value as a string, you ONLY get the font name and the font size [ ex. tahoma(8) ]. I would like to get the value as a string so I could write these values on an XML file. The dialog box for selecting font, size and style must be returning a value of type DWORD (I suppose). But how do I extract it's return value so that I would literally get what is selected like 'tahoma', '10', and 'Bold'?

Please help... thanks...

CMFCPropertyGridProperty* pCurSel = m_wndPropList.GetCurSel();
CMFCPropertyGridFontProperty* pFontProp = dynamic_cast<CMFCPropertyGridFontProperty*>(pCurSel);
if ( pFontProp ) {
  LPLOGFONT font_info = pFontProp->GetLogFont();
  // use font_info fields
}

LOGFONT structure description

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM