|
-
September 7th, 2005, 04:06 AM
#1
Documens was'n printed out but could preview?
I made a simple Single Doc-View application and let the VC++ to handle the printing job.
when I select [Print] command from the menu , and select a printer to print out the document , nothing came out from the printer. but I can preview the document by select the buildin [print preview] command from the menu.
what may cause this kind of problom?
Thanks for any reply
Jeff
-
September 7th, 2005, 09:44 AM
#2
Re: Documens was'n printed out but could preview?
I have found out the reason to cause this problom.
Code:
void CCBCView::OnDraw(CDC* pDC)
{
CCADIODoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
drawsomething( pDC->m_hDC );
}
void void CCBCView::drawsomething( HDC hdc )
{
CDC dc;
dc.Attach( hdc ); // <<------ this cause error !!!!
dc.TextOut( hdc , "PRINT TEST" , 10 );
}
Once I construct a new CDC , and attach to the original CDC's handle that pass into OnDraw function . This App display in right way on the screen, but cannot print out any more .
-
September 7th, 2005, 09:55 AM
#3
Re: Documens was'n printed out but could preview?
You probably need to call Detach() on the CDC object as by default CDC destructor is probbaly trying to delete teh DC, thus invalidating the print job in some way
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
-
September 7th, 2005, 09:59 PM
#4
Re: Documens was'n printed out but could preview?
I think you should also consider to change the param of method drawsomething( HDC hdc ) from HDC hdc to CDC *pDC.
Jack
---------------------------------------------------------------------------------
XD++ MFC/C++ Flow/Diagram Library (Full Visio 2003 Like,100% Source Code Kit) -- http://www.********.net
-
September 7th, 2005, 11:56 PM
#5
Re: Documens was'n printed out but could preview?
Right. you always need to paint onto the DC passed to you by Windows as andytim has suggested.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|