Solved

Printing out the bitmap in the client area

Posted on 1998-09-05
2
195 Views
Last Modified: 2010-04-10
This is the Printing Method I implemented.
But it just print out the blank page.
My intent was to print out the image which is displayed in the client area.
If there's any problem you found please let me know.
Thank you in advance.

afx_msg void CMainWin::OnPrintPicture()
{
    CPrintDialog *pDlg = new CPrintDialog(FALSE);

    if(pDlg->DoModal() == IDCANCEL)
    {
            delete pDlg;
        return;
    }
         
    CClientDC dc(this);
    CDC             dc1;
      
    dc1.CreateCompatibleDC(&dc);
      dc1.BitBlt(0, 0, maxX, maxY, &dc, 0, 0, SRCCOPY);
    HDC hdc = pDlg->GetPrinterDC();
    DOCINFO di = {sizeof(DOCINFO), NULL, NULL};

    ::StartDoc(hdc, &di);
    ::StartPage(hdc);
    ::BitBlt(hdc, 0, 0, maxX, maxY, dc1.m_hDC, 0, 0, SRCCOPY);
    ::RestoreDC(hdc, -1);
    ::EndPage(hdc);
    ::EndDoc(hdc);

    delete pDlg;
}
0
Comment
Question by:jaewoo082098
2 Comments
 
LVL 2

Expert Comment

by:prasanth
Comment Utility
What happens if you copy directly from the client dc (dc) insetad of copying it first to dc1 and then copying it again to the printer?
0
 
LVL 3

Accepted Solution

by:
LucHoltkamp earned 20 total points
Comment Utility
You should indeed copy directly to the PrinterDC.

You can copy to the CompatibleDC but then you must select a bitmap in the CompatibleDC. It's a memory device CONTEXT and needs a device to blit on, in the case  a memory device context, and is needs a bitmap..
luc.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 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

16 Experts available now in Live!

Get 1:1 Help Now