[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

print dlg question

Posted on 1997-04-25
1
Medium Priority
?
324 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
1 Comment
 
LVL 2

Accepted Solution

by:
sapek earned 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month19 days, 19 hours left to enroll

872 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