Solved

non-CView based printing

Posted on 1998-08-01
4
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

729 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