PrintPreview - Problem inTrying to copy Printpreview' DC's image

PrintPreview - Problem inTrying to copy Printpreview' DC's image

Post by Omer Sahi » Wed, 11 Nov 1998 04:00:00


PrintPreview's painting and scrolling is so slow. Instead of drawing it's
contents
everytime on  OnDraw; I decided to draw on the real DC once,  copy  it's
bitmap
to a compatible DC and later, when OnDraw is called again for that page, I
only
copy the bitmap from compatible Dc to PrintPreview's DC's Bitmap.
Unfortunately two problems happens:
 1) The bitmap looks some distortioned
 2) Bitmap's bottom part (which is invisible at the beginning), can't be
copied. When
I scroll the view, this part looks totaly black.

When I copy , I change the origination and Mapping mode. I change mapping
mode from Anisotrophic to  text.
         omer

Best Regards:

Here is how OnDraw  looks
OnDraw(CDC *pDC, CPrintInfo *pInfo)
{
        if (this is the same of the previous page )
        {
        // compy compatible Dc's image to the current dc
            pDC->SetViewportOrg(0, 0);
           pDC->SetWindowOrg(0, 0);
           nPrevMapMode = pDC->SetMapMode(MM_TEXT);  
        pDC->BitBlt(0, 0, size.cx, size.cy, m_pTempDC, 0, 0,SRCCOPY);                
        return;
        }
 // draw to this page for the first time
 // ....
// Save the Dc's bitmap into a compatible bitmap
if (m_pTempDC->CreateCompatibleDC(pDC))
        {
            size.cx = pDC->GetDeviceCaps(HORZRES);
            size.cy = pDC->GetDeviceCaps(VERTRES);
            if (m_pTempBitmap->CreateCompatibleBitmap(pDC, size.cx,
size.cy))
            {
                    pView->OnPrepareDC(m_pTempDC, pInfo);
                    pDC->SetViewportOrg(0, 0);
                    pDC->SetWindowOrg(0, 0);
                   pDC->SetMapMode(MM_TEXT);
                    m_pTempDC->SetViewportOrg(0, 0);
                    m_pTempDC->SetWindowOrg(0, 0);
                    m_pTempDC->SetMapMode(MM_TEXT);
                    m_pOldBitmap = m_pTempDC->SelectObject(m_pTempBitmap);
                    BOOL bResult = pDC->GetDeviceCaps(RASTERCAPS) &
RC_BITBLT;
                    m_pTempDC->BitBlt(0, 0, size.cx, size.cy, pDC, 0, 0,
SRCCOPY);

            }
    }

Quote:}


 
 
 

1. Printer DC's and Enhanced Metafile DC's and Memory DC's

I am having problems selecting a bitmap created via
CreateCompatibleBitmap() into a memory DC created via CreateCompatibleDC()
whose "hardware" DC is actually a metafile which was created from a printer
DC.  Whew!  

I can find no limitation in the documentation for doing this but
SelectObject() returns NULL when I try to select the compatible bitmap into
the compatible DC of the compatible EMF DC of the printer DC.   Have I
missed something in the docs?  Is this a bug?  If it is a bug, what's the
work-around?

Any help would be appreciated.

E.C.
--
Eric Chamberlain                eric dot chamberlain at graphicode dot com
GraphiCode, Inc.                Senior Software Engineer
6608 216th St. SW               Phone: (425) 672-1980
Suite 100                       Fax:   (425) 672-2705
Mountlake Terrace, WA 98043
USA                             Web Site: http://www.graphicode.com
**********************************************************************
*  Pursuant to US Code, Title 47, Chapter 5, Subchapter II, Sec. 227,
*  any and all nonsolicited commercial E-mail sent to this address is
*  subject to a download and archival fee in the amount of $500 US.
*  E-mailing denotes acceptance of these terms.
**********************************************************************

2. bad hardisk

3. How to copy a window's DC to another DC?

4. Cumulative C5328310 HELP, URGENT!!

5. Problem of Handling PrintPreview w.Win32

6. How to kill hung processes?

7. Are Memory DC's faster than Window DC's

8. Sir Clive on Classic FM! [MP3]

9. MFC: Help needed copying images from memory DC to display DC

10. MFC: Copying images from memory DC to display DC?

11. MFC PrintPreview and CReBars

12. Lost PrintPreview CDialogBar focus in an ActiveX Control???

13. Customizing PrintPreview sample ???