[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

non-CView based printing

Posted on 1998-08-01
4
Medium Priority
?
252 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 300 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

649 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