Strange problem with print preview
Hi!
I've got strange(?) problem with print preview. I've got my own class based
on the CPreviewView class. I override OnBeginPrinting, OnPrint and
OnEndPrinting, but i've got problem. In OnBeginPrinting i create my font.
void CMyPrintPreview::OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo)
{
pDC->SetMapMode(MM_LOMETRIC);
CreateFont(pDC, "Comic Sans MS", FontSize, FW_NORMAL, 0, 0);
}
And I'm using this font in my OnPrint function. CreateFont looks like that:
void CMyPrintPreview::CreateFont(CDC* pDC, string FaceName, int Height, int
Weight, int italic, int underline)
{
pDC->SetMapMode(MM_LOMETRIC);
if(!m_pLF){
m_pLF=(LOGFONT*)calloc(1,sizeof(LOGFONT));
m_pLF->lfHeight= Height*6;
strcpy(m_pLF->lfFaceName, FaceName.c_str());
m_pLF->lfWeight=Weight; // 900 // = Weight
m_pLF->lfClipPrecision = CLIP_LH_ANGLES;
m_pLF->lfItalic=italic; // 0 by default
m_pLF->lfUnderline=underline; // 0 by default
m_Font.CreateFontIndirect(m_pLF);
}
CFont* pAnOldFont = (CFont*)(pDC->SelectObject(&m_Font));
pDC->SelectObject(&m_Font);
}
And problem is with print preview. On print preview my font is different -
similar to Arial and much bigger. When i print on printer - everything is
OK. I see Comic Sans MS on the paper with properly font size. I'm sure, that
OnBeginPrinting is called when i call print preview. Why this font is
different on my print preview?
Greetings,
Dawid.