Solved

print dlg question

Posted on 1997-04-25
1
285 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

930 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now