CWndResizer
lastmod 2026-11-10created 2016-11-163 edits
CWndResizer is a helper class that automatically adjusts the position and size of child controls when an MFC dialog is resized. It is a library published on CodeProject: after attaching it to the dialog with Hook() in OnInitDialog() and specifying with SetAnchor() which edges (top, bottom, left, right) each control is anchored to, it takes over WM_SIZE handling. It also can group controls into panels and add splitter bars, and is used to implement responsive layouts that the MFC resource editor does not support.
Example
BOOL CLiveDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// ...
m_Resizer.Hook(this);
m_Resizer.SetAnchor(IDC_EDIT_LOG, ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_BOTTOM);
}
See also
Favorite site
References
-
MFC_Helper_Class_for_Window_Resizing_-_CodeProject.pdf ↩