I've implemented the WM_GETMINMAXINFO and WM_SIZE again, and the first works perfectly, however repositioning child controls in WM_SIZE leaves artifacting all over the place (i.e. if I resize left-to-right and back repeatedly I can see remnants of the controls overlapping themselves) no matter how much I try to redraw the window. Here's the code I'm using, with my multiple redraw attemps highlighted in bold (none of which work):
Code:
//this works great, thanks anony
case WM_GETMINMAXINFO:
{
TITLEBARINFO tbi;
tbi.cbSize = sizeof(tbi);
GetTitleBarInfo(hwnd, &tbi);
((LPMINMAXINFO)lParam)->ptMinTrackSize.x = DEF_WIDTH_SETUPDLG;
((LPMINMAXINFO)lParam)->ptMinTrackSize.y = DEF_HEIGHT_SETUPDLG + (tbi.rcTitleBar.bottom - tbi.rcTitleBar.top);
return 0;
break;
}
//this leaves artifacting
case WM_SIZE:
{
if(wParam == SIZE_RESTORED)
{
RECT rect;
TITLEBARINFO tbi;
int origWidth = curWidth;
int origHeight = curHeight;
tbi.cbSize = sizeof(tbi);
GetTitleBarInfo(hwnd, &tbi);
GetWindowRect(hwnd, &rect);
curWidth = rect.right - rect.left;
curHeight = rect.bottom - rect.top - (tbi.rcTitleBar.bottom-tbi.rcTitleBar.top);
if(origWidth != curWidth)
{
int i;
HWND hCtrl;
RECT rcCtrl;
for(i = IDC_FIRSTCTRL; i <= IDC_LASTCTRL; ++i)
{
hCtrl = GetDlgItem(hwnd, i);
GetWindowRect(hCtrl, &rcCtrl);
POINT pt = {rcCtrl.left + (curWidth-origWidth), rcCtrl.top};
ScreenToClient(hwnd, &pt);
SetWindowPos(hCtrl, NULL, pt.x, pt.y, 0,0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
ShowWindow(hCtrl, SW_SHOW);
}
}
RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN);
UpdateWindow(hwnd);
}
return 0;
break;
}
Windows even gives an example of this in which they use MoveWindow to move the control and ShowWindow to update it in response to WM_SIZE. I've tried MoveWindow and it produces the same artifacting. I've also tried updating control positions only on response to WM_EXITSIZEMOVE, however this does not allow the user to concurrently track where the controls will end up. So what do I need to do inorder to prevent the controls from being improperly redrawn while moving them about in response to WM_SIZE?