?
Solved

Printing out the bitmap in the client area

Posted on 1998-09-05
2
Medium Priority
?
212 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
[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 Comments
 
LVL 2

Expert Comment

by:prasanth
ID: 1172053
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 60 total points
ID: 1172054
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

765 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