Solved

non-CView based printing

Posted on 1998-08-01
4
248 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
ID: 1320068
0
 

Author Comment

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

0
 

Author Comment

by:trovatore
ID: 1320070
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
ID: 1320071
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 52
Question regarding Copy/Paste 16 96
fix34  challenge 9 144
Making an alias 7 101
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

830 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