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. Control ghosting during dialog resize

Control ghosting during dialog resize

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++announcement
4 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.
  • R Offline
    R Offline
    rem c
    wrote on last edited by
    #1

    Hello guys, i'm stuck with this problem, i wrote a class wich handles the resizing en reposition of controls when a dialog resizes, but the problem is when I resize the dialog from the top or from the bottom you see a ghost of the control. This gives the effect that the controls are shaking during a resize. The problem I think is, is that when MFC resize the dialog it updates the dialog and it's controls so you will see the controls with their previous x & y coordinates, then mfc calls my overriden onsize where i update the controls coordinates and size and repaint the dialog. So my question is how can i stop mfc from repainting the dialog when is resized so i can do this manual after mine onsize. I checked other implementations of the CResizableDlg classes articles here, but they seem to have the same problem. Anyone got some suggestions :confused: Thanks Remco

    R G R 3 Replies Last reply
    0
    • R rem c

      Hello guys, i'm stuck with this problem, i wrote a class wich handles the resizing en reposition of controls when a dialog resizes, but the problem is when I resize the dialog from the top or from the bottom you see a ghost of the control. This gives the effect that the controls are shaking during a resize. The problem I think is, is that when MFC resize the dialog it updates the dialog and it's controls so you will see the controls with their previous x & y coordinates, then mfc calls my overriden onsize where i update the controls coordinates and size and repaint the dialog. So my question is how can i stop mfc from repainting the dialog when is resized so i can do this manual after mine onsize. I checked other implementations of the CResizableDlg classes articles here, but they seem to have the same problem. Anyone got some suggestions :confused: Thanks Remco

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      How are you handling the OnEraseBkgnd message? I would recommend something like this:

      BOOL CYourDialog::OnEraseBkgnd(CDC* pDC)
      {
      static int controlsNotToBeErased[] =
      {
      IDC_REFINE_BUTTON,
      IDC_SCRIPT,
      IDC_AUTOCLIP,
      IDC_CLIP,
      IDC_REFINE_CONFIG,
      IDC_SCRIPT_SETUP,
      IDC_SUPPRESS_CO2,
      IDC_SUPRESS_WATER_CAPACITY,
      IDC_SET_COMBO,
      IDC_REFINE,
      IDC_GRAPHS,
      IDC_REFINEGRAPH,
      IDC_CO2CHECK,
      IDC_CO2,
      IDC_SOLUBILITYCHECK,
      IDC_SOLUBILITY,
      IDC_VOLATILITYCHECK,
      IDC_VOLATILITY,
      IDC_GLPKA
      };
      CRect clip;
      pDC->SaveDC();
      for (int i = 0; i < sizeof(controlsNotToBeErased) / sizeof(int); i++)
      {
      CWnd *pWnd = GetDlgItem(controlsNotToBeErased[i]);
      if (pWnd && pWnd->IsWindowVisible())
      {
      pWnd->GetWindowRect(&clip); // get rect of the control
      ScreenToClient(&clip);
      pDC->ExcludeClipRect(&clip);
      }
      }
      pDC->GetClipBox(&clip);
      pDC->FillSolidRect(clip, GetSysColor(COLOR_BTNFACE));
      pDC->RestoreDC(-1);
      return FALSE;
      }

      This should hopefully reduce contro flicker etc. If you vote me down, my score will only get lower

      1 Reply Last reply
      0
      • R rem c

        Hello guys, i'm stuck with this problem, i wrote a class wich handles the resizing en reposition of controls when a dialog resizes, but the problem is when I resize the dialog from the top or from the bottom you see a ghost of the control. This gives the effect that the controls are shaking during a resize. The problem I think is, is that when MFC resize the dialog it updates the dialog and it's controls so you will see the controls with their previous x & y coordinates, then mfc calls my overriden onsize where i update the controls coordinates and size and repaint the dialog. So my question is how can i stop mfc from repainting the dialog when is resized so i can do this manual after mine onsize. I checked other implementations of the CResizableDlg classes articles here, but they seem to have the same problem. Anyone got some suggestions :confused: Thanks Remco

        G Offline
        G Offline
        Gary R Wheeler
        wrote on last edited by
        #3

        The problem is all of the painting that's going on as you move each control. Try looking at the DeferWindowPos[^] API function, which lets you change the position of several windows and then update the screen all at once.


        Software Zen: delete this;

        1 Reply Last reply
        0
        • R rem c

          Hello guys, i'm stuck with this problem, i wrote a class wich handles the resizing en reposition of controls when a dialog resizes, but the problem is when I resize the dialog from the top or from the bottom you see a ghost of the control. This gives the effect that the controls are shaking during a resize. The problem I think is, is that when MFC resize the dialog it updates the dialog and it's controls so you will see the controls with their previous x & y coordinates, then mfc calls my overriden onsize where i update the controls coordinates and size and repaint the dialog. So my question is how can i stop mfc from repainting the dialog when is resized so i can do this manual after mine onsize. I checked other implementations of the CResizableDlg classes articles here, but they seem to have the same problem. Anyone got some suggestions :confused: Thanks Remco

          R Offline
          R Offline
          rem c
          wrote on last edited by
          #4

          thanks for the fast replies, i will try your suggestions :)

          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