Solved

How to print the Dialog Box

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 95
sumDigits challenge 9 170
Doc'in system (example?) BA 7 115
haveThree challenge 22 121
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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