win32 - how avoid flickers?
C / C++ / MFC
1
Posts
1
Posters
1
Views
1
Watching
-
for avoid flickers i must do: 1 - use the WS_CLIPCHILDREN on parent window; 2 -
case WM_ERASEBKGND:
{
return (LRESULT) 1;
}
break;seems be used only on parent window too. the child controls are transparent: (i use the button class for create a label. why?!? because be correctly transparent using the BS_OWNERDRAW style.)
case WM_ERASEBKGND:
{
return (LRESULT)1;
}
break;case WM\_CTLCOLORSTATIC: { return (LRESULT)GetStockObject(NULL\_BRUSH); } break; case WM\_PAINT: { PAINTSTRUCT test; BeginPaint(hwnd, &test); image imglabel(test.rcPaint.right-test.rcPaint.left,test.rcPaint.bottom - test.rcPaint.top); brush brshbackcolor(inst->clrBackColor); brshbackcolor.ToDC(imglabel); brush brshTransparent; FillRect(imglabel,&test.rcPaint,brshbackcolor); if(inst->imgtest.haveimage()) DrawHICONtoHDC(imglabel, inst->imgtest,1,1); SetBkMode(imglabel,TRANSPARENT); char \*text=(char\*)inst->strCaption.c\_str(); SetTextColor(imglabel,inst->clrTextColor ); DrawTextEx(imglabel,text,-1,&test.rcPaint,DT\_LEFT,NULL); if(inst->blnBorder==true) DrawEdge(imglabel, &test.rcPaint,BDR\_SUNKENINNER | BDR\_RAISEDOUTER,BF\_RECT); TransparentBlt(test.hdc,0,0,test.rcPaint.right,test.rcPaint.bottom,imglabel,0,0,test.rcPaint.right,test.rcPaint.bottom, inst->clrBackColor); //BitBlt(test.hdc,0,0,test.rcPaint.right,test.rcPaint.bottom,imglabel,0,0, SRCCOPY); EndPaint(hwnd, &test); return 0; } break;
and the how i readraw the window:
RECT d;
GetClientRect(hwnd,&d);
RedrawWindow(hwnd,&d,nullptr,RDW_UPDATENOW | RDW_INVALIDATE | RDW_ERASENOW);but when, with animation\timer, the next image is drawed above the older one, instead clean all control and then redraw it. (i need avoid the flicker and draw the control correctly and not 1 image above other) can anyone advice me?