Click here to Skip to main content
15,896,726 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: String Table - message boxes interference Pin
André Dewispelaere20-Sep-00 4:06
André Dewispelaere20-Sep-00 4:06 
GeneralHooks:WH_HARDWARE Pin
alainserge26-Aug-00 6:35
alainserge26-Aug-00 6:35 
GeneralRe: Hooks:WH_HARDWARE Pin
Michael Dunn26-Aug-00 7:33
sitebuilderMichael Dunn26-Aug-00 7:33 
GeneralDialog from console Pin
Erik26-Aug-00 4:53
Erik26-Aug-00 4:53 
GeneralRe: Dialog from console Pin
Paolo Messina26-Aug-00 7:15
professionalPaolo Messina26-Aug-00 7:15 
GeneralRe: Dialog from console Pin
Erik28-Aug-00 4:04
Erik28-Aug-00 4:04 
GeneralRe: Dialog from console Pin
Paolo Messina29-Aug-00 7:58
professionalPaolo Messina29-Aug-00 7:58 
QuestionHow To change color of specific Text in listBox Pin
Dayan26-Aug-00 1:47
Dayan26-Aug-00 1:47 
AnswerRe: How To change color of specific Text in listBox Pin
Michael Dunn26-Aug-00 7:37
sitebuilderMichael Dunn26-Aug-00 7:37 
AnswerRe: How To change color of specific Text in listBox Pin
Buck27-Aug-00 11:35
Buck27-Aug-00 11:35 
AnswerRe: How To change color of specific Text in listBox Pin
#realJSOP28-Aug-00 1:33
professional#realJSOP28-Aug-00 1:33 
QuestionHow to dock like the ICQ window? Pin
Eq25-Aug-00 18:50
Eq25-Aug-00 18:50 
AnswerRe: How to dock like the ICQ window? Pin
Buck27-Aug-00 10:43
Buck27-Aug-00 10:43 
GeneralATL flicker problem Pin
Nick Hodapp25-Aug-00 6:16
sitebuilderNick Hodapp25-Aug-00 6:16 
GeneralRe: ATL flicker problem Pin
Steven Mitcham31-Aug-00 6:02
Steven Mitcham31-Aug-00 6:02 

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.