CFontDialog incorrect default size
-
In the OnBeginPrinting function of my view class I am displaying a CFontDialog dialog box. I want the default font to be Arial and the default size to be 10. When the dialog box displays, it a shows default size of 62. Here is the code. These are the first lines in the OnBeginPrinting function.
ASSERT(pDC->GetMapMode() == MM_TEXT);
LOGFONT lf;
::ZeroMemory(&lf, sizeof(LOGFONT));
lf.lfHeight = -MulDiv(10, pDC->GetDeviceCaps(LOGPIXELSY), 72);
lstrcpy(lf.lfFaceName, _T("Arial"));
CFontDialog dlg&lf, CF_PRINTERFONTS, pDC);
if (dlg.DoModal() == IDOK)
{
m_strFont = dlg.GetFaceName();
m_nPointSize = dlg.GetSize() / 10;
}Why is the dialog displaying the wrong size value?
-
In the OnBeginPrinting function of my view class I am displaying a CFontDialog dialog box. I want the default font to be Arial and the default size to be 10. When the dialog box displays, it a shows default size of 62. Here is the code. These are the first lines in the OnBeginPrinting function.
ASSERT(pDC->GetMapMode() == MM_TEXT);
LOGFONT lf;
::ZeroMemory(&lf, sizeof(LOGFONT));
lf.lfHeight = -MulDiv(10, pDC->GetDeviceCaps(LOGPIXELSY), 72);
lstrcpy(lf.lfFaceName, _T("Arial"));
CFontDialog dlg&lf, CF_PRINTERFONTS, pDC);
if (dlg.DoModal() == IDOK)
{
m_strFont = dlg.GetFaceName();
m_nPointSize = dlg.GetSize() / 10;
}Why is the dialog displaying the wrong size value?
Lonnie Johnson wrote:
Why is the dialog displaying the wrong size value?
I don't know, but have you tried using values other than 10 to see if a pattern exists?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Lonnie Johnson wrote:
Why is the dialog displaying the wrong size value?
I don't know, but have you tried using values other than 10 to see if a pattern exists?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
Here are the results from some other point sizes. input point size size that appears in the dialog box. 8 50 12 62 14 88 16 100 18 113 20 125
-
In the OnBeginPrinting function of my view class I am displaying a CFontDialog dialog box. I want the default font to be Arial and the default size to be 10. When the dialog box displays, it a shows default size of 62. Here is the code. These are the first lines in the OnBeginPrinting function.
ASSERT(pDC->GetMapMode() == MM_TEXT);
LOGFONT lf;
::ZeroMemory(&lf, sizeof(LOGFONT));
lf.lfHeight = -MulDiv(10, pDC->GetDeviceCaps(LOGPIXELSY), 72);
lstrcpy(lf.lfFaceName, _T("Arial"));
CFontDialog dlg&lf, CF_PRINTERFONTS, pDC);
if (dlg.DoModal() == IDOK)
{
m_strFont = dlg.GetFaceName();
m_nPointSize = dlg.GetSize() / 10;
}Why is the dialog displaying the wrong size value?
-
What is the value returned from GetDeviceCaps()? printers have way more pixels per inch than screens do. What is the value of lfHeight?
The value returned by pDC->GetDeviceCaps(LOGPIXELSY) is 600. The computed value for lf.lfHeight when 8 points is used is -67. The resulting size value in the Select Font dialog is 50.
-
The value returned by pDC->GetDeviceCaps(LOGPIXELSY) is 600. The computed value for lf.lfHeight when 8 points is used is -67. The resulting size value in the Select Font dialog is 50.