Solved

print dlg question

Posted on 1997-04-25
1
279 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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 78
Define unique primary key 9 81
maxBlock challenge 30 99
sumHeights2  challenge 7 75
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

16 Experts available now in Live!

Get 1:1 Help Now