Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Trying to reduce Flickering when using SetTimer

2»

Comments

  • MT2002MT2002 Member Posts: 1,444

    : [color=Blue]
    : Where does this code belong MT? ... WM_PAINT/WM_CREATE/WM_TIMER
    : [/color]

    Your main program loop. ie, perhaps its the message loop for your main window?
    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.brokenthorn.com]Website :: OS Development Series[rightbr][/link][/size]
  • Sonx_hvn7Sonx_hvn7 Member Posts: 54
    : My attempt to your suggestions
    : : [color=Blue]
    : You call BeginPaint() twice in one WM_PAINT cycle. Also, why you are
    : releasing MemDC here at the end of drawing? You should do it in
    : WM_DESTROY.
    :
    : Also, the enum was there to make the code readable. With 0 and 1 it
    : is confusing now.
    : : [/color]
    : : [code]: :
    : : case WM_PAINT:
    : : {
    : : hdc = [color=Red]BeginPaint[/color](hwnd, &pntS);
    : :
    : : [color=Green]/* Retrieve the client's area width and height */[/color]
    : : GetClientRect(hwnd, &clientRECT);
    : :
    : : [color=Green]/* Create memory DC on back buffer */[/color]
    : : MemDC = MemoryDCForArea(hdc,
    : : clientRECT.right, [color=Green]// width[/color]
    : : clientRECT.bottom, [color=Green]// height[/color]
    : : 0);
    : :
    : : [color=Green]/* *** Rendering screen data (User Interface) *** */[/color]
    : : DrawArea(hwnd, MemDC, colors);
    : :
    : : [color=Green]// From menDC to screen[/color]
    : : BitBlt(hdc,0,0,clientRECT.right,clientRECT.bottom,MemDC,0,0,SRCCOPY);
    : :
    : : [color=Green]/* Calculate & show results
    : : output = ProcessData(hwnd);
    : : DisplayResults(hwnd, hdc, &output, rsltFont);*/[/color]
    : :
    : : [color=Green]/* Delete/release memory DC on back buffer */[/color]
    : : MemDC = MemoryDCForArea( [color=Red]BeginPaint[/color](hwnd, &pntS),
    : : clientRECT.right, [color=Green]// width[/color]
    : : clientRECT.top, 1); [color=Green]// height[/color]
    : : [color=Red]// This whole ^^^ statement should be in WM_DESTROY.
    : : // Also, when you releasing pass zeros as HDC and size.[/color]
    : :
    : : EndPaint(hwnd, &pntS);
    : : }
    : : return 0;
    : : [/code]: :
    :
    [color=Blue]Asmguru, remember you once told me to set the window background to NULL [/color][code] wcx.hbrBackground = NULL;[color=Green]//(HBRUSH)(COLOR_BTNFACE+1);[/color] [/code][color=Blue] , i just did this together with the double buffering and now the flickering it's only on the edit controls.. The rectangles and text is stable.. And aslo, i get the black background on the main window... If i can solve these two things, then i'll be super!

    About edit controls, they are not Painted but created using CreateWindowEX, why should they flicker? I mean i can't use any DC to create/paint them
    [/color]

    [b]Updated this post 15min later...![/b]

    [color=Red]
    I've got things wrong, the flickering only stopped because i moved the rendering of my objects to Memory DC within WM_CREATE, which obviously doesn't update... making background NULL only stops the fickering of Window itself, not the objects... So i'm back to square 1[/color]
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [color=Blue]When the flickering occurs? When your timer fires or when you resize the window?

    Also, why GetDC()?

    You can avoid black background if you paint it (background) yourself BEFORE you paint all the rectangles. Use FillRect() and you are done.[/color]
  • Sonx_hvn7Sonx_hvn7 Member Posts: 54
    : When the flickering occurs? When your timer fires or
    : when you resize the window?

    [color=Blue]
    When my timer fires....[/color]

    : Also, why GetDC()?

    [color=Blue]Didn't make a difference but noticed lot of references using the BeginPaint() DC, so will change back[/color]

    : You can avoid black background if you paint it (background) yourself
    : BEFORE you paint all the rectangles. Use FillRect() and you are
    : done.

    [color=Blue]I have with no difference... I think this has to do with painting on the back buffer (off-screen DC) and returning a non-zero on WM_ERASEBKGND...[/color]

2»
Sign In or Register to comment.