views:

68

answers:

1

Hi All,

I'm using this code block to get the font name, style and size selected by the user from the font dialog of CMFCPropertyFontProperty control. I'm already able to get the name and the style, but the size seems to return a different value.

*CMFCPropertyGridProperty pCurSel = m_wndPropList.GetCurSel(); CMFCPropertyGridFontProperty* pFontProp = dynamic_cast(pCurSel);

if ( pFontProp ) {

LPLOGFONT font_info = pFontProp->GetLogFont();

INT nSize = 0;

nSize = font_info->lfHeight;

//nSize seems to return a negative value... :(

}**

I realize that there's a formula for it : lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);

But I can't seem to get it working... how do I get the hDC from CMFCPropertyFontProperty? please help...

A: 

You can just use GetDC(NULL); to get an HDC for the screen which I assume will be the same as what the font dialog will use.

The LOGFONT documentation describes the meaning of +ve and -ve values for the lfHeight member,

http://msdn.microsoft.com/en-us/library/dd145037(VS.85).aspx

Chris Oldwood