CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 58
  1. #31
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: [win32] - avoid flicker and do a correct redraw

    Clipping children literally means that parent does not repaint itself under children.

    WS_CLIPCHILDREN
    0x02000000L
    Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window.
    Therefore, children themselves are fully responsible for their looks including background.
    Last edited by Igor Vartanov; April 1st, 2015 at 02:23 AM.
    Best regards,
    Igor

  2. #32
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [win32] - avoid flicker and do a correct redraw

    so the only way is copy the parent background, right?

  3. #33
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: [win32] - avoid flicker and do a correct redraw

    if you clipchildren... there is no parent background to copy.

    If it makes you understand this better...
    Clipchildren is windows making a stencil or mask and sticking that on top of the dialog when it's painting the parent, all the bits in the stencil/mask end up remaining "unpainted"
    if you're in for a laugh...
    https://www.youtube.com/watch?v=EalqlDjTnPw
    Here you see mrbean carefully 'clip children' all his furniture and the door and leaving only his background (the walls) uncovered. And then "he paints the wall" :-p
    the "joke" of the sketch also happens to be masked/clipped away from the paint job.
    This is what WS_CLIPCHILDREN does.


    so what is there, is whatever happens to be there before the paint occured. This could be the previous child paint cycle, or it could be the content of another window that was in front of the window and has now been moved away. or it could be something different still.

  4. #34
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [win32] - avoid flicker and do a correct redraw

    i'm confused with just 1 thing that i can't do with WS_CLIPCHILDREN
    the WS_CLIPCHILDREN don't let me clear the child control, unless i fill it with a rectangle.
    can i clear the child control without fill it with a rectangle?

  5. #35
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: [win32] - avoid flicker and do a correct redraw

    There is no such thing as 'clear a window'. Clearing a window means filling it with something and the easiest way is to use a rectangle and fill it with a specified brush. However this is not a requirement and you can use a bitmap or paint lines or do anything else you want. You might just want to 'clear' certain areas of the window rather than the whole. But if can't do want you want using the 'normal' way then you'll have to do everything yourself which is what OReubens was talking about in his post #28.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #36
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: [win32] - avoid flicker and do a correct redraw

    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #37
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [win32] - avoid flicker and do a correct redraw


  8. #38
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: [win32] - avoid flicker and do a correct redraw

    Quote Originally Posted by Cambalinho View Post
    the Layered, for child controls, only works with windows 8 or above
    but it will still not do what you seem to be aiming at.

    if you have a layered child control, you STILL have to paint ALL of the child window yourself.

  9. #39
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: [win32] - avoid flicker and do a correct redraw

    ... And as I said before... in #28
    resolving flickering
    and transparency are totally unrelated issues.
    layered child windows does not solve flickering, in fact, it'll probably make it worse.

  10. #40
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [win32] - avoid flicker and do a correct redraw

    Quote Originally Posted by OReubens View Post
    ... And as I said before... in #28


    layered child windows does not solve flickering, in fact, it'll probably make it worse.
    lets going back, please.
    the flicker happens when 1 color 1 showed aboved other(like the show the backcolor 2 times), right?
    the WS_CLIPCHILDREN can resolve that, but i can when several problems for what i need.
    so can i avoid the flicker without use the WS_CLIPCHILDREN?

  11. #41
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: [win32] - avoid flicker and do a correct redraw

    Have you looked at the WS_EX_COMPOSITED extended window style?

    From MSDN:

    With WS_EX_COMPOSITED set, all descendants of a window get bottom-to-top painting order using double-buffering. Bottom-to-top painting order allows a descendent window to have translucency (alpha) and transparency (color-key) effects, but only if the descendent window also has the WS_EX_TRANSPARENT bit set. Double-buffering allows the window and its descendents to be painted without flicker.
    https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  12. #42
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [win32] - avoid flicker and do a correct redraw

    Quote Originally Posted by 2kaud View Post
    Have you looked at the WS_EX_COMPOSITED extended window style?

    From MSDN:



    https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx
    i have tested now. the parente using the WS_EX_COMPOSITED extended window style and the child control using the WS_EX_TRANSPARENT extended window style, but i get some flickers too.
    nothing better than Regions. i put the code working

  13. #43
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: [win32] - avoid flicker and do a correct redraw

    Quote Originally Posted by Cambalinho View Post
    lets going back, please.
    the flicker happens when 1 color 1 showed aboved other(like the show the backcolor 2 times), right?
    it is one of the major reasons, there are others.

    the WS_CLIPCHILDREN can resolve that, but i can when several problems for what i need.
    so can i avoid the flicker without use the WS_CLIPCHILDREN?
    This actually does NOT resolve flickering, it may seem to be doing that "at the moment", but that's more a cause by the fact your total painting solution at current isn't working than that it's actually being solved.
    if you solve the painting so it paints right, you'll probably get your flickering back.



    How to actually solve flickering ? See #28
    Create a memory bitmap for all control painting,
    paint only on that bitmap
    disable WM_ERASEBKGND for the control
    and blit the bitmap on WM_PAINT

    this solves flickering, because you never see anything being painted, the old image is being replaced by the new bitmap.
    If you see sheering with this method. You are updating way too fast (windows GUI updates shouldn't be done multiple times per framerate).

  14. #44
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [win32] - avoid flicker and do a correct redraw

    anotherthing: if the windows(parent window) is too big i will get flickers
    can you give me more information, please?
    yes i use a timer animation for refresh the window

  15. #45
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: [win32] - avoid flicker and do a correct redraw

    You need to understand the nature of flicker. Say at some moment you have your window painted right. Then on some reason a region appears invalid. Regular behavior under the circumstances implies erasing of the invalidated area (typically filling the rect with window brush) and then calling WM_PAINT handler that paints right colors back. Now, based on this, the flicker is the two fast paints in a row, when right colors are over-painted with background color (erased) and then re-painted with right color.

    What WS_CLIPCHILDREN does, and why it kinda solves flickering. The style tells Windows to never erase the windows areas under child windows no matter if WM_ERASEBKGND is handled or not. Indirectly this obliges children to paint themselves correctly, as parent just ignores the areas under those. So, no painting from parent reduces the number of overall paint/erase actions done in particular area.

    As for the matter of window size. Typically it should not cause any effect unless you do something really wrong. Say you update a couple of rectangles that intersect. The common area for the two rects may flicker in case you do painting directly to the destination DC (your window DC). This sort of flickering is solved by buffered painting, when overlapped paintings are done to memory DC (no physical device), and only when your entire bitmap is finished, it gets instantly blitted to your window (physical) DC. The performance of contemporary graphic cards is typically enough for handling rather big paintings, but in some cases the GPU performance may suffer from various reasons. You must not judge based on results obtained only from your developer's workstation, but should intentionally test on different hardware with different workload.
    Best regards,
    Igor

Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured