Solved

How to print the Dialog Box

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

Accepted Solution

by:
Zoppo earned 35 total points
Comment Utility
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
Comment Utility
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
Comment Utility
ALso note that you might prefer PrintClient instead of Print
0
 

Author Comment

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

 
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

11 Experts available now in Live!

Get 1:1 Help Now