Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Flicker drawing owner drawn controls...

34 views
Skip to first unread message

chand...@gmail.com

unread,
Feb 11, 2009, 1:48:24 PM2/11/09
to
I have a main window with two children(say child1 and child2 )
clipping it's entire area. One of children(child2 ) windows contains
child controls.
|---------------------------| This is child 1
| --------------------------|
| | This is child 2
| |
|---------------------------|
These controls are owner drawn(set by BS_OWNERDRAW ) capturing
WM_DRAWITEM in the window message handler (of child2 ).

Problem is that now my second child window(child2) flickers whenever
it is activated or some other top level window is moved over it.

Although it never causes flicker when I move it

I have used double buffering(off screen dc) and am returning TRUE in
WM_ERASEBKGND message to reduce the flicker in all window drawings.

I have used WS_CLIPCHILDREN WS_CLIPSIBLINGS for the windows(child1 and
child2) which in turn contain more owner drawn child controls.

Here is how my custom control draw looks like

HDC memDC = CreateCompatibleDC(data.hDC);
HBITMAP hMemBmp = CreateCompatibleBitmap(data.hDC, destWidth,
destHeight);
HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC, hMemBmp);

Graphics* pCanvas = Graphics::FromHDC(memDC)

//Drawing is done here on pCanvas

BitBlt(data.hDC, 0, 0, destWidth, destHeight, memDC, 0, 0, SRCCOPY);

//Always select the old bitmap back into the device context
SelectObject(memDC, hOldBmp);
DeleteObject(hMemBmp);
DeleteObject(pCanvas);
DeleteDC(memDC);

Could any please suggest a solution for the same?

0 new messages