Solved

Printing out the bitmap in the client area

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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
SetCurrentDirectory path limit 7 131
Writing a parser for java language 4 86
c++ substatte a varabe for a string in a LPCTSTR statment 8 89
c++, dynamic object by json 1 53
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

828 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