from reading these site: http://www.catch22.net/tuts/flicker-free-drawing
i understand that i must avoid the pixel been changed more than once and a double-buffer:
//how avoid the pixel be changed more than once:
case WM_ERASEBKGND:
return 1;
//for other controls, we must use another messsage(see the child control messages)
and heres how we do a double buffer:
HDC hdcMem;
HBITMAP hbmMem;
HANDLE hOld;
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hwnd, &ps);
//if we use another message instead the WM_PAINT, we use the GetDC() function
//for get the HDC
// Create an off-screen DC for double-buffering
hdcMem = CreateCompatibleDC(hdc);//here we can use NULL too
hbmMem = CreateBitmap(win_width, win_height,1,32,NULL);
//that site use the CreateCompatibleBitmap() function, but use my line for get
//the correct results ;)
//select the new bitmap to hdcMem
hOld = SelectObject(hdcMem, hbmMem);
//the hOld is for get the original bimap.. good for restore the old image
// Draw into hdcMem here
// Transfer the off-screen DC to the screen
BitBlt(hdc, 0, 0, win_width, win_height, hdcMem, 0, 0, SRCCOPY);
// Free-up the off-screen DC
SelectObject(hdcMem, hOld);
DeleteObject(hbmMem);
DeleteDC (hdcMem);
doing these the image never more flicker... and it's great because we draw it just once ;)
anotherthing: please create the DC and delete it ouside the WM_PAINT message for avoid flicker too.
the form show us the image correctly. but the child controls continue flickering :(
can anyone advice me more?
i know about the WS_CLIPCHILDREN style(it's only for the form), but the static control(when it's transparent) the text, when is changed, is showed 1 above another instead clean the old text and show the actual.
anyone correct me please.. how can i avoid the child control flickers?