Flicker when drawing owner-drawn control

Flicker when drawing owner-drawn control

Post by ZWVwY2F » Fri, 29 Aug 2008 00:24:01


WinCE 5.0 / EVC 4.0

I am dealing with a flicker issue when drawing an owner drawn custom
control. I am hopeful that someone here can help me out.

I made a subclass of the CButton class which handles all of the drawing
functions.
The class already addresses the usual suspects:

- double-buffering
- override OnEraseBkgnd and return 1

...but I still have flicker when drawing the control, whether I call
Invalidate or InvalidateRect on the object.

This object is redrawn in response to data received on the main dialog
(parent), which then calls object->Invalidate(). Is there anything wrong
with this approach?

Below is an abridged version of my DrawItem( ) method...

***************************************
this->GetClientRect(&DrawRect);
pDC = this->GetDC();
MemDC.CreateCompatibleDC(pDC);
MemBitmap.CreateCompatibleBitmap(pDC, (DrawRect.right - DrawRect.left),
(DrawRect.bottom - DrawRect.top));

// drawing code here //

pDC->BitBlt(DrawRect.left, DrawRect.top, (DrawRect.right - DrawRect.left),
(DrawRect.bottom - DrawRect.top), &MemDC, 0, 0, SRCCOPY);

// cleanup code here //

****************************************

The OnPaint( ) method simply calls CButton::OnPaint( );

Originally, I had the drawing code as part of the main dialog - with no
flicker. It made more sense for the object to draw itself, so I went the
owner drawn control route, but now I have flicker.

Thanks for helping,
- eepcat
 
 
 

Flicker when drawing owner-drawn control

Post by ZWVwY2F » Fri, 29 Aug 2008 00:45:02

...also...

this->ModifyStyle(0, WS_CLIPCHILDREN);

on the main dialog.

This, along with double buffering and OnEraseBkgnd are the only clear
advices I have gotten on this.
thanks