Solved

Printing out the bitmap in the client area

Posted on 1998-09-05
2
210 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 20 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

Suggested Solutions

Title # Comments Views Activity
ASP.net build a IF/Then Walkthrough Guide 1 317
sorting efficency of sorting algorithm 30 149
How can i compile this github project?? 2 103
c++, dynamic object by json 1 65
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 learn how to clear a vector as well as how to detect empty vectors in C++.

734 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