Click here to Skip to main content
15,923,168 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSeemingly unbelievable menu problem Pin
David Bates30-Aug-00 12:35
David Bates30-Aug-00 12:35 
GeneralEdit Box Problem!! Pin
sunny30-Aug-00 11:35
sunny30-Aug-00 11:35 
GeneralRe: Edit Box Problem!! Pin
Erik Funkenbusch30-Aug-00 13:48
Erik Funkenbusch30-Aug-00 13:48 
GeneralRe: Edit Box Problem!! Pin
Oleg Zhuk30-Aug-00 23:12
Oleg Zhuk30-Aug-00 23:12 
GeneralRe: Edit Box Problem!! Pin
HP31-Aug-00 1:17
HP31-Aug-00 1:17 
GeneralTab Control Help Pin
sunny30-Aug-00 11:02
sunny30-Aug-00 11:02 
GeneralRe: Tab Control Help Pin
Erik Funkenbusch30-Aug-00 13:50
Erik Funkenbusch30-Aug-00 13:50 
GeneralRe: Tab Control Help Pin
jschacker31-Aug-00 9:59
jschacker31-Aug-00 9:59 
GeneralData to Printer Port Pin
Gary30-Aug-00 10:36
Gary30-Aug-00 10:36 
GeneralMultimedia Timer Class Pin
C. Hampton30-Aug-00 7:33
sussC. Hampton30-Aug-00 7:33 
GeneralRe: Multimedia Timer Class Pin
Paolo Messina30-Aug-00 8:26
professionalPaolo Messina30-Aug-00 8:26 
GeneralAcquiring PSID for ReportEvent Pin
sai30-Aug-00 5:52
sai30-Aug-00 5:52 
GeneralSocketproblem using service Pin
Andreas30-Aug-00 5:03
Andreas30-Aug-00 5:03 
GeneralGenerating COM-TypeLibraries with MIDL Pin
Sven Wiegand30-Aug-00 4:08
Sven Wiegand30-Aug-00 4:08 
QuestionHow can I use ownerdraw in a CCtrlView based on listbox Pin
Ronald L. Russell (Ron)30-Aug-00 4:00
sussRonald L. Russell (Ron)30-Aug-00 4:00 
GeneralTransparency ... Pin
Oleg Zhuk30-Aug-00 0:29
Oleg Zhuk30-Aug-00 0:29 
QuestionHow do you use the CToolTipCtrl? Pin
Newbie29-Aug-00 17:37
Newbie29-Aug-00 17:37 
AnswerRe: How do you use the CToolTipCtrl? Pin
Jeremy Davis29-Aug-00 22:23
Jeremy Davis29-Aug-00 22:23 
AnswerRe: How do you use the CToolTipCtrl? Pin
jschacker1-Sep-00 8:12
jschacker1-Sep-00 8:12 
GeneralAbout SMB (CIFS) example code Pin
Joe Huang29-Aug-00 17:18
Joe Huang29-Aug-00 17:18 
GeneralTab Contorl Pin
sunny29-Aug-00 10:22
sunny29-Aug-00 10:22 
GeneralPrinting in Document-View architecture Pin
André Dewispelaere29-Aug-00 5:55
André Dewispelaere29-Aug-00 5:55 
GeneralRe: Printing in Document-View architecture Pin
jschacker31-Aug-00 10:48
jschacker31-Aug-00 10:48 
Here is some code I used for printing multi-page documents. It doesn't use the m_rectDraw for calculating the number of pages. It gets a printer device context from the current selected printer. Then calls GetDeviceCaps(HORZRES) and GetDeviceCaps(VERTRES) to get the printer page size.


BOOL CInfoWindowView::OnPreparePrinting(CPrintInfo* pInfo)
{
pInfo->SetMaxPage(GetNumberOfPrintPages(pInfo));

// default preparation
return DoPreparePrinting(pInfo);
}

WORD CInfoWindowView::GetNumberOfPrintPages(CPrintInfo* /*pInfo*/)
{
PRINTDLG PrtDlg;
HDC hDC;

//// Create a printer DC
if(!AfxGetApp()->GetPrinterDeviceDefaults(&PrtDlg))
{
TRACE("No default printer.\n");
// use screen DC for calculations
// It's OK to do this because this CDC will not be used for any
// output.
hDC = ::CreateDC("display",NULL,NULL,NULL);
}
else
{
CPrintDialog dlg(FALSE);
dlg.m_pd.hDevMode = PrtDlg.hDevMode;
dlg.m_pd.hDevNames = PrtDlg.hDevNames;
hDC = dlg.CreatePrinterDC();
}

CDC* pDC = CDC::FromHandle(hDC);
// This is a printer DC, so set m_bPrinting
// this is necessary so CScrollView::OnPrepareDC won't modify the
// ViewportOrg, and cause LPtoDP to return an inappropriate result.
pDC->m_bPrinting = TRUE;

//// Calculate print stuff.
CFont font;
CFont *pOldFont;
CSize size;
CInfoWindowDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

//Setup the font.
font.CreatePointFont(INFO_WINDOW_FONT_SIZE, INFO_WINDOW_FONT_FACE, pDC);
pOldFont = pDC->SelectObject(&font);
size = pDC->GetTextExtent("X");

//// Get the printer page sizeS.
LONG lHeaderHeight;
LONG lFooterHeight;
LONG lPageWidth, lPageHeight;

lPageWidth = pDC->GetDeviceCaps(HORZRES);
lPageHeight = pDC->GetDeviceCaps(VERTRES);

//Header height is 4 lines.
lHeaderHeight = size.cy * 4;

//Footer height is 2 lines.
lFooterHeight = size.cy * 2;

//Set header, page, and footer rects.
m_rectPrintHeader.SetRect(0, 0, lPageWidth, lHeaderHeight);

//Print area for info.
m_rectPrintPage.SetRect(0, m_rectPrintHeader.bottom,
lPageWidth, m_rectPrintHeader.bottom +
(lPageHeight - (lHeaderHeight + lFooterHeight)));

//Footer area.
m_rectPrintFooter.SetRect(0, m_rectPrintPage.bottom,
lPageWidth, lPageHeight);
(size.cy * 1));

//Calculate other stuff.
m_wLinesPerPrinterPage = WORD(m_rectPrintPage.Height() / size.cy);
m_wPrinterPages = (WORD)ceil((double)pDoc->GetNumberOfTextLines() / m_wLinesPerPrinterPage);
m_wPrinterPages = (WORD)__max(m_wPrinterPages, 1);

//// Clean up.
pDC->SelectObject(pOldFont);
pDC->DeleteDC();

return m_wPrinterPages;
}


I hope this helps.

Jonathan Craig
GeneralRe: Printing in Document-View architecture Pin
André Dewispelaere20-Sep-00 3:52
André Dewispelaere20-Sep-00 3:52 
GeneralString Table - message boxes interference Pin
André Dewispelaere29-Aug-00 5:33
André Dewispelaere29-Aug-00 5:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.