Solved

How to print the Dialog Box

Posted on 2000-05-15
4
187 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 35 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

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