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. How to get rid of ugly repainting process when resizing main window?

How to get rid of ugly repainting process when resizing main window?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialhelpquestion
4 Posts 4 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.
  • S Offline
    S Offline
    s_k
    wrote on last edited by
    #1

    Hi, I've SDI application I start with SW_MAXIMIZE parameter passed to CFrameWnd::ShowWindow(). But I absolutely don't like that while the window is appearing on the screen, user can see its repainting progress (two ListViews changing their size, toolbar changing its size etc..). And it looks very ugly. Is there any way how to get rid of this? For example Visual C++ has very nice repainting when changing size/maximizing - there are no "intermediate stages" of repainting progress that could be seen by user. I think there must be some way how to do it - let all parts of application window (toolbars, views, ....) to find out their dimensions and placement BUT don't show main window untill this all is done! Hope someone will understand my problem... Thank you for any suggestion.

    C T M 3 Replies Last reply
    0
    • S s_k

      Hi, I've SDI application I start with SW_MAXIMIZE parameter passed to CFrameWnd::ShowWindow(). But I absolutely don't like that while the window is appearing on the screen, user can see its repainting progress (two ListViews changing their size, toolbar changing its size etc..). And it looks very ugly. Is there any way how to get rid of this? For example Visual C++ has very nice repainting when changing size/maximizing - there are no "intermediate stages" of repainting progress that could be seen by user. I think there must be some way how to do it - let all parts of application window (toolbars, views, ....) to find out their dimensions and placement BUT don't show main window untill this all is done! Hope someone will understand my problem... Thank you for any suggestion.

      C Offline
      C Offline
      cmk
      wrote on last edited by
      #2

      There are 3 things to look at wrt window repainting/flickering : 1. WM_ERASEBKGND - if you are drawing the control and repaint the entire area in your WM_PAINT handler then don't do anything in WM_ERASEBKGND (and return 1). This avoids flicker caused by WM_ERASEBKGND filling control with background color then WM_PAINT painting actual control detail. 2. Again, if you are painting the control, then think about rendering the control to a bitmap then bliting the bitmap to the screen. 3. If you need to reposition a number of windows at once try using BeginDeferWindowPos(), DeferWindowPos(), and EndDeferWindowPos(). This is usefull for splitter windows. 4. (ok, 4 things to look at) For initial display you could create all windows hidden, position them, then make them all visible. Another way is to create main window offscreen then when children have adjusted their sizes, move main window onscreen. ...cmk Save the whales - collect the whole set

      1 Reply Last reply
      0
      • S s_k

        Hi, I've SDI application I start with SW_MAXIMIZE parameter passed to CFrameWnd::ShowWindow(). But I absolutely don't like that while the window is appearing on the screen, user can see its repainting progress (two ListViews changing their size, toolbar changing its size etc..). And it looks very ugly. Is there any way how to get rid of this? For example Visual C++ has very nice repainting when changing size/maximizing - there are no "intermediate stages" of repainting progress that could be seen by user. I think there must be some way how to do it - let all parts of application window (toolbars, views, ....) to find out their dimensions and placement BUT don't show main window untill this all is done! Hope someone will understand my problem... Thank you for any suggestion.

        T Offline
        T Offline
        Tim Smith
        wrote on last edited by
        #3

        The window class is handling that for you. If you are using MFC, window classes are generally hidden from you. The flags you want to change are CS_HREDRAW and CS_VREDRAW. These flags tell windows to repaint the window when it changes size. At least I think that is the case. :) Tim Smith I'm going to patent thought. I have yet to see any prior art.

        1 Reply Last reply
        0
        • S s_k

          Hi, I've SDI application I start with SW_MAXIMIZE parameter passed to CFrameWnd::ShowWindow(). But I absolutely don't like that while the window is appearing on the screen, user can see its repainting progress (two ListViews changing their size, toolbar changing its size etc..). And it looks very ugly. Is there any way how to get rid of this? For example Visual C++ has very nice repainting when changing size/maximizing - there are no "intermediate stages" of repainting progress that could be seen by user. I think there must be some way how to do it - let all parts of application window (toolbars, views, ....) to find out their dimensions and placement BUT don't show main window untill this all is done! Hope someone will understand my problem... Thank you for any suggestion.

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Additionally, make sure your view and controls have the WS_CLIPCHILDREN|WS_CLIPSIBLINGS styles --Mike-- "Big handwavy generalizations made from a position of deep ignorance is one of the biggest wastes of time on the net today. -- Joel Spolsky Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber

          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