Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. win32 - how avoid flickers?

win32 - how avoid flickers?

Scheduled Pinned Locked Moved C / C++ / MFC
question
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11511469
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups