Click here to Skip to main content
16,016,345 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Linker error when using DirectDrawCreateEx(...) Resolved Pin
Alan Chambers23-May-02 8:52
Alan Chambers23-May-02 8:52 
GeneralOutlook (Express) Automation Pin
peterchen23-May-02 6:54
peterchen23-May-02 6:54 
GeneralRe: Outlook (Express) Automation Pin
Shog923-May-02 7:36
sitebuilderShog923-May-02 7:36 
General.lib to pack a folder/multiple files Pin
peterchen23-May-02 6:47
peterchen23-May-02 6:47 
GeneralRe: .lib to pack a folder/multiple files Pin
Roger Stewart23-May-02 7:24
professionalRoger Stewart23-May-02 7:24 
GeneralRe: .lib to pack a folder/multiple files Pin
Mike Nordell23-May-02 7:35
Mike Nordell23-May-02 7:35 
GeneralRe: .lib to pack a folder/multiple files Pin
Neville Franks23-May-02 12:45
Neville Franks23-May-02 12:45 
GeneralPrinting with displaying CPrintDialog() Pin
dazinith23-May-02 6:33
dazinith23-May-02 6:33 
I am trying to write a function for a CFormView called BatchPrintPage2().. the first part of this function is trying to get a handle on HDC. This is before I try to get the hDC:
DOCINFO di ;
CPrintInfo printInfo ;
CMyDoc *pDoc = (CMyDoc*)GetDocument() ;
CString filename ;
CDC dc ;
CRect draw_area ;

ASSERT_VALID(pDoc) ;
filename = pDoc->GetPathName() ; // make sure the compares will match
filename.MakeLower() ;
CPrintDialog dlg(FALSE) ;


at this point i try to get the hDC, the first way i was told to try was:
HDC hDC = dlg.CreatePrinterDC() ;

but this always returns null.
the other way i have tried is:
dlg.GetDefaults();
HDC hDC = dlg.m_pd.hDC;


this actually seems to work.. but then i get to the rest of the function..
di.cbSize = sizeof(DOCINFO) ;
di.lpszDocName = pDoc->GetPathName() ;
di.lpszOutput = filename ; // prepare the print information structure
dc.Attach(hDC) ;
printInfo.m_bDirect = TRUE ;
printInfo.m_rectDraw.left = 0 ;
printInfo.m_rectDraw.right = dc.GetDeviceCaps(HORZRES) ;
printInfo.m_rectDraw.top = 0 ;
printInfo.m_rectDraw.bottom = dc.GetDeviceCaps(VERTRES) ;
draw_area = printInfo.m_rectDraw ;
dc.StartDoc(&di) ;
OnPreparePrinting(&printInfo) ; // start printing the document
for (printInfo.m_nCurPage = 1 ; printInfo.m_nCurPage <= printInfo.GetMaxPage() ; printInfo.m_nCurPage++)
{
dc.StartPage() ;
OnPrint(&dc, &printInfo) ;
dc.EndPage() ; // reset page size as OnPrint may have modified them when header / footers were added to the page
printInfo.m_rectDraw = draw_area ;
}
OnEndPrinting(&dc, &printInfo) ;
dc.EndDoc() ;
VERIFY(dc.DeleteDC()) ;


this doesn't give any errors, but nothing prints. When tracing i see that OnDraw is called, but IsPrinting() is false. I have tried setting dc.m_bPrinting = TRUE, and this makes onDraw get called with IsPrinting() true, but it still prints nothing. My printer queue actually shows the job being sent to the printer, but when i captured the screen and look at it the 'Pages' and 'Size' columns are both blank..

also a major problem is that the 'for' loop listed above corrupts the hell out of my document.. my document file just gets destroyed with garbage from this for loop.. the dc.StartPage() sets the file to the following: (does this look like its printing to the document file somehow?)
%-12345X@PJL ENTER LANGUAGE=PCL600
*t600R&u600D*r3F&l0O&l1H&l2a8c1E*p0x0Y&l1X*b0M
*v0o0T E%-12345X


any help is much appreciated.. i can almost smell printing a bunch of views without a dialog Smile | :)

thanks!

-dz
GeneralRe: Printing with displaying CPrintDialog() Pin
Roger Allen23-May-02 7:26
Roger Allen23-May-02 7:26 
GeneralRe: Printing with displaying CPrintDialog() Pin
dazinith23-May-02 8:45
dazinith23-May-02 8:45 
GeneralRe: Printing with displaying CPrintDialog() Pin
Jonathan Craig23-May-02 10:59
Jonathan Craig23-May-02 10:59 
GeneralSorting a vector Pin
DrZOO23-May-02 5:41
DrZOO23-May-02 5:41 
GeneralRe: Sorting a vector Pin
Chris Losinger23-May-02 5:41
professionalChris Losinger23-May-02 5:41 
GeneralRe: Sorting a vector Pin
DrZOO23-May-02 6:12
DrZOO23-May-02 6:12 
GeneralRe: Sorting a vector Pin
Chris Losinger23-May-02 6:18
professionalChris Losinger23-May-02 6:18 
GeneralRe: Sorting a vector Pin
DrZOO23-May-02 6:36
DrZOO23-May-02 6:36 
GeneralRe: Sorting a vector Pin
Chris Losinger23-May-02 7:04
professionalChris Losinger23-May-02 7:04 
GeneralRe: Sorting a vector Pin
peterchen23-May-02 7:05
peterchen23-May-02 7:05 
GeneralShow desktop Pin
obr23-May-02 5:22
obr23-May-02 5:22 
GeneralRe: Show desktop Pin
Joaquín M López Muñoz23-May-02 8:53
Joaquín M López Muñoz23-May-02 8:53 
GeneralRe: Show desktop Pin
obr23-May-02 19:26
obr23-May-02 19:26 
GeneralOpening urls in new browser window Pin
Chris Hambleton23-May-02 5:07
Chris Hambleton23-May-02 5:07 
GeneralRe: Opening urls in new browser window Pin
RobJones23-May-02 7:33
RobJones23-May-02 7:33 
GeneralRe: Opening urls in new browser window Pin
Chris Hambleton23-May-02 7:50
Chris Hambleton23-May-02 7:50 
GeneralATL/WTL message routing Pin
_Magnus_23-May-02 4:53
_Magnus_23-May-02 4:53 

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.