Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to print the Dialog Box

Posted on 2000-05-15
4
Medium Priority
?
190 Views
Last Modified: 2013-11-20
Hi,
  I have a dialog box as a help display.
 Since This Help contains good information I want to provide PRINT option there.
I have a Button on the dialog.
Also I have a function "ONPRINT"
. hOW do I proceed from here to make dialog gets printed??
thanks in advance..
0
Comment
Question by:mkjoshi
[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
4 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 140 total points
ID: 2810483
Hi mkjoshi,

simply create a printer dc (see CPrinterDialog and PRINTDLG on how to do this) and call CWnd::Print() with the dc against your dialog.

hope that helps,

ZOPPO
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2812753
Here is what I do

void CMyDialog::PrintMe() {
    // Instantiate a CPrintDialog.
    CPrintDialog printDlg(FALSE, PD_ALLPAGES | PD_RETURNDC, NULL);
    // Initialize some of the fields in PRINTDLG structure.
    printDlg.m_pd.nMinPage = printDlg.m_pd.nMaxPage = 1;
    printDlg.m_pd.nFromPage = printDlg.m_pd.nToPage = 1;
    // Display Windows print dialog box.
    printDlg.DoModal();
    // Obtain a handle to the device context.
    HDC hdcPrn = printDlg.GetPrinterDC();
    if (hdcPrn != NULL) {
        CDC *pDC = new CDC;
        pDC->Attach (hdcPrn);      // attach a printer DC
        pDC->StartDoc("job");      // begin a new print job
        pDC->StartPage();          // begin a new page
        Print(pDC,PRF_CHILDREN|PRF_CLIENT|PRF_ERASEBKGND);
        pDC->EndPage();            // end a page
        pDC->EndDoc();             // end a print job
        pDC->Detach();             // detach the printer DC
        delete pDC;
    }
}

This is essentially what Zoppo is saying.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2812764
ALso note that you might prefer PrintClient instead of Print
0
 

Author Comment

by:mkjoshi
ID: 2813121
RONSLOW,
 I USED your code and tryied but no good result.
            When I click PRINT nutton on Dialog nothing getting printed.

 
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

610 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