Solved

How to print the Dialog Box

Posted on 2000-05-15
4
184 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 124
Turn a spreadsheet into a vba executable. 2 86
Hibernate methods 2 71
twoTwo  challenge 35 103
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…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

777 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