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. Invisible static control and window update hangs?

Invisible static control and window update hangs?

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
7 Posts 3 Posters 0 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi! I recently made a invisible static control by overriding CMyStatic::OnPaint() and doing nothing there. Ouch. This does totally screw up the update of my parent window! When hiding the parent window (a dialog) through another window and get my dialog back on top of z-order, then all controls will be painted until my invisible control. All controls after my invisible control will not be repainted, I need to move the window to get them repainted. That's pretty strange. I can't call the base class member CStatic::OnPaint(), because then it wouldn't be invisible anymore. I tried a bit and added this as only line in my OnPaint() handler: CPaintDC dc(this); Now window update works as usually. Can somebody explain what's happening? I really like to understand. Thanks :)

    M I 2 Replies Last reply
    0
    • A Anonymous

      Hi! I recently made a invisible static control by overriding CMyStatic::OnPaint() and doing nothing there. Ouch. This does totally screw up the update of my parent window! When hiding the parent window (a dialog) through another window and get my dialog back on top of z-order, then all controls will be painted until my invisible control. All controls after my invisible control will not be repainted, I need to move the window to get them repainted. That's pretty strange. I can't call the base class member CStatic::OnPaint(), because then it wouldn't be invisible anymore. I tried a bit and added this as only line in my OnPaint() handler: CPaintDC dc(this); Now window update works as usually. Can somebody explain what's happening? I really like to understand. Thanks :)

      M Offline
      M Offline
      Mythago
      wrote on last edited by
      #2

      If you Invalidate() a window it will try to redraw itself at the next opportunity. Because your 'invisible' static control is hidden for a while it is automatically Invalidate()ed. So when it comes to draw it again, it still thinks it is Invalidate()ed. If you Validate() your static control rather than creating a DC from the window, it will also work. :confused:HOWEVER, why did you not just create the window without WS_VISIBLE set?

      A 1 Reply Last reply
      0
      • A Anonymous

        Hi! I recently made a invisible static control by overriding CMyStatic::OnPaint() and doing nothing there. Ouch. This does totally screw up the update of my parent window! When hiding the parent window (a dialog) through another window and get my dialog back on top of z-order, then all controls will be painted until my invisible control. All controls after my invisible control will not be repainted, I need to move the window to get them repainted. That's pretty strange. I can't call the base class member CStatic::OnPaint(), because then it wouldn't be invisible anymore. I tried a bit and added this as only line in my OnPaint() handler: CPaintDC dc(this); Now window update works as usually. Can somebody explain what's happening? I really like to understand. Thanks :)

        I Offline
        I Offline
        includeh10
        wrote on last edited by
        #3

        u need to know a little win32 story. if u override WM_PAINT message, u must have min 2 lines to tell OS related info. the function CPaintDC dc(this) has these 2 lines inside. includeh10

        1 Reply Last reply
        0
        • M Mythago

          If you Invalidate() a window it will try to redraw itself at the next opportunity. Because your 'invisible' static control is hidden for a while it is automatically Invalidate()ed. So when it comes to draw it again, it still thinks it is Invalidate()ed. If you Validate() your static control rather than creating a DC from the window, it will also work. :confused:HOWEVER, why did you not just create the window without WS_VISIBLE set?

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          ah thx for the good explanation, I remember from my Win32 experience. :) Mythago wrote: HOWEVER, why did you not just create the window without WS_VISIBLE set? I remake a splitter control, the splitter itself _can_ be "invisible". If I set the WS_VISIBLE style I can't get mouse messages and stuff anymore.

          A 1 Reply Last reply
          0
          • A Anonymous

            ah thx for the good explanation, I remember from my Win32 experience. :) Mythago wrote: HOWEVER, why did you not just create the window without WS_VISIBLE set? I remake a splitter control, the splitter itself _can_ be "invisible". If I set the WS_VISIBLE style I can't get mouse messages and stuff anymore.

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            btw, one more question: Is there a easier MFC solution to validate a client rect than calling CPaintDC dc(this); ? Or does it already provide the mininum solution?

            M 1 Reply Last reply
            0
            • A Anonymous

              btw, one more question: Is there a easier MFC solution to validate a client rect than calling CPaintDC dc(this); ? Or does it already provide the mininum solution?

              M Offline
              M Offline
              Mythago
              wrote on last edited by
              #6

              Yes you can use ValidateRect(NULL) surprisingly...;)

              A 1 Reply Last reply
              0
              • M Mythago

                Yes you can use ValidateRect(NULL) surprisingly...;)

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                Mythago wrote: Yes you can use ValidateRect(NULL) surprisingly... my hero ;) M

                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