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