Solved

print dlg question

Posted on 1997-04-25
1
311 Views
Last Modified: 2013-11-20
I would like to set up  a print option in my dialog box program.

I think it should go like this, am I way off base?

cprintdialog::cprintmydlg
{
        char* pBuf[100] //set up a char array of ptrs

        pBuf[0] = *m_MonPlan; //put a pointer to the member           variables
        PBuf[1] = *m_TuePlan;
        etc...

        //then print out the member variables.

        pDC->TextOut(0, pbuf); // write the string in           pbuf

        //would I use a iteration loop or will mfc print out
        //the whole string til a null char/pointer?
}

I have looked in the MS KB and got a doc, but it is still confusing to me. I understand I must get the CDC but do I need a m_startpage. any help appreciated. I have searched the msvc help, the numerous ref books, they got me this
far but when it comes to dlg boxes it isnt the most informative. Im sorry if this is obvious.
0
Comment
Question by:anglico
[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
1 Comment
 
LVL 2

Accepted Solution

by:
sapek earned 100 total points
ID: 1301196
If you are not using MFC Document/View architecture to do printing you don't need anythink like m_startpage. However you must do everything to layout the printout (just as you were printing form a none MFC app).
Generally you need thses steps:

1. Get printer DC. The easiest way to get is using windows PrintDlg (MFC's CPrintDialog class). It will display a print dialog and get you appropriate printer DC.

2. You need abort procedure and abort dialog. Read in documentation (not for MFC but for Win32, search for AbortProc) how to do this. You then use CDC::SetAbortProc to set abort proc for printing process. You can also look at some Win32 example for details how to setup and use abort proc and abort dialog

3. You must start new document (CDC::StartDoc) and new page (CDC::StartPage).

4. Use gdi functions (like TextOut) to output to the printer. You are responsible for positioning output on the paper (and things like line breaks, page breaks). You generally will want to set map mode to something other then MM_TEXT (like MM_LOENGLISH or MM_LOMETRIC), use CDC::SetMapMode for this. Note that in these map modes positive y is up.

5. call CDC::EndPage after every page

6. finish print job by CDC::EndDoc

This is general outline what you have to do print without MFC support. I sill sugest you to have a look at some Win32 example that supports printing with raw API.

Hope this helps,
Adam

0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

695 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