OnBeginPrinting, OnEndPrinting functions
Michael.FOURNEAU@is.belgacom.be
Friday, June 07, 1996
Hello,
I am developing an application with MSVC 1.51 under Windows 3.1.
When I use "Print Preview" or "Print" commands, I get the following error
message:
"ELMI caused a General Protection Fault in module ELMI.EXE at 0003:3A27"
and the application is stopped.
All the variables used are defined in my elmiview.h as Public !
I must define a new Font size for the "Print" command.
I am lost ! Can somebody help me ?
Michael.
Here there are both functions:
CElmiView::OnBeginPrinting(...)
CElmiView::OnEndPrinting(...)
/************************************\
* CElmiView::OnBeginPrinting (...) *
\************************************/
void CElmiView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// default preparation
mPageHeight = pDC->GetDeviceCaps (VERTRES);
mPageWidth = pDC->GetDeviceCaps (HORZRES);
// LOGFONT struct: attributes for the font used
m_lf.lfHeight=(int)(mPageWidth * LFHEIGHT_VIEW / 640); //
Character size //++++
m_Font.DeleteObject();
m_Font.CreateFontIndirect(&m_lf);
DocSize = GetTotalSize();
DocSize.cy = (int) (DocSize.cy * (1.0 * m_lf.lfHeight) /
LFHEIGHT_VIEW);
mNumRows = DocSize.cy / mPageHeight + (DocSize.cy % mPageHeight > 0);
mNumCols = DocSize.cx / mPageWidth + (DocSize.cx % mPageWidth > 0);
pInfo->SetMinPage (1);
pInfo->SetMaxPage (mNumRows * mNumCols);
}
/**********************************\
* CElmiView::OnEndPrinting (...) *
\**********************************/
void CElmiView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// LOGFONT struct: attributes for the font used
m_lf.lfHeight=LFHEIGHT_VIEW; // Character size //++++
m_Font.DeleteObject();
m_Font.CreateFontIndirect(&m_lf);
}
------------------- END --------------------
LeRoy Baxter -- lbaxter@cinfo.com
Sunday, June 09, 1996
Well, I'm not sure about this, but my code for printing works and the major difference is this:
in the OnPreparePrinting(), remove the m_Font.DeleteObject();
in the OnEndPrinting(), remove the m_Font.CreateFontIndirect(&m_lf);
----------
From: Michael.FOURNEAU@is.belgacom.be[SMTP:Michael.FOURNEAU@is.belgacom.be]
Sent: Friday, June 07, 1996 1:02 PM
To: mfc-l@netcom.com
Cc: windev-l@netcom.com
Subject: OnBeginPrinting, OnEndPrinting functions
Hello,
I am developing an application with MSVC 1.51 under Windows 3.1.
When I use "Print Preview" or "Print" commands, I get the following error
message:
"ELMI caused a General Protection Fault in module ELMI.EXE at 0003:3A27"
and the application is stopped.
All the variables used are defined in my elmiview.h as Public !
I must define a new Font size for the "Print" command.
I am lost ! Can somebody help me ?
Michael.
Here there are both functions:
CElmiView::OnBeginPrinting(...)
CElmiView::OnEndPrinting(...)
/************************************\
* CElmiView::OnBeginPrinting (...) *
\************************************/
void CElmiView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// default preparation
mPageHeight = pDC->GetDeviceCaps (VERTRES);
mPageWidth = pDC->GetDeviceCaps (HORZRES);
// LOGFONT struct: attributes for the font used
m_lf.lfHeight=(int)(mPageWidth * LFHEIGHT_VIEW / 640); //
Character size //++++
m_Font.DeleteObject();
m_Font.CreateFontIndirect(&m_lf);
DocSize = GetTotalSize();
DocSize.cy = (int) (DocSize.cy * (1.0 * m_lf.lfHeight) /
LFHEIGHT_VIEW);
mNumRows = DocSize.cy / mPageHeight + (DocSize.cy % mPageHeight > 0);
mNumCols = DocSize.cx / mPageWidth + (DocSize.cx % mPageWidth > 0);
pInfo->SetMinPage (1);
pInfo->SetMaxPage (mNumRows * mNumCols);
}
/**********************************\
* CElmiView::OnEndPrinting (...) *
\**********************************/
void CElmiView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// LOGFONT struct: attributes for the font used
m_lf.lfHeight=LFHEIGHT_VIEW; // Character size //++++
m_Font.DeleteObject();
m_Font.CreateFontIndirect(&m_lf);
}
------------------- END --------------------
| Вернуться в корень Архива
|