I have several controls that need to be scaled when a window is to be resized. I am doing so using Begin/End/DeferWindowPos.
Code:
int ScaleWindowControls(HWND hwnd, int x, int y)
{
HWND chatwnd = ::GetDlgItem(hwnd, IDC_CHATTY);
HWND mainwnd = ::GetDlgItem(hwnd, IDC_MAIN);
HWND entrbtn = ::GetDlgItem(hwnd, IDC_BUTTON);
if(!chatwnd || !mainwnd || !entrbtn)
return 0;
HDWP collection = ::BeginDeferWindowPos(3);
collection = ::DeferWindowPos(collection, entrbtn, 0, x - 37,
y - 20, 36, 19, SWP_NOZORDER);
collection = ::DeferWindowPos(collection, mainwnd, 0, 1, 0, x -
2, y - 22, SWP_NOZORDER);
collection = ::DeferWindowPos(collection, chatwnd, 0, 1, y -
20, x - 40, y, SWP_NOZORDER);
if(!::EndDeferWindowPos(collection))
return 0;
return 1;
}
It has a considerable amount of flickering. I am wondering whether taking control over the messages sent, optimizations, or subclassing would help this problem.