Streamlining OnDraw() 
Author Message
 Streamlining OnDraw()

I'm afraid I don't understand this CDC jazz too much. There are
certain parts that seem unnecessarily complicated. For instance, I
have to call CreateCompatibleDC(). Subsequent calls are either to the
CDC pointer returned by it, and others are to the pointer in the
function header.
   Anyway, the only thing written to the view is a true colour bitmap
with a halftone brush. I was wondering if you could tell me if any of
the following code need not be executed on each OnDraw() call, but
only when there is a new design on the view. Here's an abstraction:

   CDC dcMemory;
   HBITMAP hBmp = CreateDIBitmap(pDC->m_hDC, &m_BMPHeader, CBM_INIT,
                    &m_BMPInit, &m_BMPColour,DIB_RGB_COLORS);
   dcMemory.CreateCompatibleDC(pDC);

   CBitmap *ptheirbitmap = CBitmap::FromHandle(hBmp);
   dcMemory.SelectObject(ptheirbitmap);

   DeleteObject(hBmp);

   int nSavedStretchMode = pDC->SetStretchBltMode(STRETCH_HALFTONE);
   ::SetBrushOrgEx(dcMemory.m_hDC, 0, 0, NULL));
   pDC->StretchBlt (0, 0, m_nRealWidth, m_nRealHeight, &dcMemory, 0,
0,
                        m_nFakeWidth, m_nFakeHeight, SRCCOPY));
   pDC->SetStretchBltMode(nSavedStretchMode);

   dcMemory.DeleteDC();

I don't understand a lot of it. It was a great deal of trial and
error. I imagine there are things I'm doing less than optimally.
However, all that code seems to be based on pDC, so I don't see how I
could do any of it outside of OnDraw()'s scope.



Sat, 12 Nov 2005 12:43:36 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Streamline Navigation in ASP.NET

2. Essentially CView::OnDraw and COleServerItem::OnDraw produce different results

3. Essentially CView::OnDraw and COleServerItem::OnDraw produce different results

4. Using OnDraw overrides for multiple recordset views

5. Calling OnDraw method Explicitly

6. Does a button have an OnDraw

7. OnDraw

8. ActiveX Control OnDraw problem displaying icon

9. OnDraw(ATL_DRAWINFO& di)

10. ActiveX Control & OnDraw

11. Invoke OnDraw method manually

12. OnDraw Function and Object Wizard with Activex Control

 

 
Powered by phpBB® Forum Software