Solved

non-CView based printing

Posted on 1998-08-01
4
244 Views
Last Modified: 2013-11-19
I need to do non-WYSIWYG printing from an MFC app at
the document level.  I'm running into unbelivable
difficulties.  It seems that it should be enough to do
the following:

  1) Create a CPrintInfo object

  2) Call DoPrintDialog on its CPrintDialog member

  3) Get the handle for the printer device context by
     calling CPrintDialog::GetPrinterDC().  Attach
     that handle to a new CDC object (let pDC be
     a pointer to this object)

  4) Make a DOCINFO structure and call pDC->StartDoc().

  5) Call pDC->StartPage().

  6) Output whatever I want via pDC->TextOut() .

  7) Call pDC->EndPage() and (eventually) pDC->EndDoc() .

But things keep happening that I don't understand--fonts
change on me, code that used to work stops working after
trivial changes, GetTextExtent() returns inconsistent
values, etc.  Is there something obvious I'm
missing?  I saw somewhere that StartPage() resets device
attributes; how can I reset them?  I tried keeping around
a pointer to one of the views just so I could call
pView->OnPrepareDC() after every call to CDC::StartPage(),
but it didn't seem to help.
0
Comment
Question by:trovatore
  • 2
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 150 total points
Comment Utility
0
 

Author Comment

by:trovatore
Comment Utility
Codeguru is not responding.  For 150 pts you couldn't summarize
the basic ideas?

0
 

Author Comment

by:trovatore
Comment Utility
OK, I got through to Codeguru, but the answer was not terribly
relevant.  I finally figured it out by myself.  The correct
answer is, "You have to call pDC->SetMapMode() and
pDC->SetViewportOrg() and pDC->SelectObject(CFont*)
after every call to pDC->StartPage()".


0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
Sorry, I misunderstood your question because I didn't read it carefully. I did encounter the exactly same problem. I should have provided the correct answer. You may reject my answer and ask the customer service to refund you.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now