#keywords C++,MFC,Dialog,Resize {{{#!gcode // 헤더 BOOL m_bSizing; RECT initClientRect; RECT prevClientRect; void OnSizeHelper(RECT rect); inline void ChildWndMove(CWnd& childWnd, RECT& diffRect, BOOL leftright = FALSE) { CRect childWndRect; childWnd.GetWindowRect(&childWndRect); ScreenToClient(&childWndRect); if (leftright) { childWndRect.bottom += diffRect.bottom; childWndRect.top += diffRect.bottom; childWndRect.left += diffRect.left; childWndRect.right += diffRect.right; } else { childWndRect.bottom += diffRect.bottom; childWndRect.top += diffRect.bottom; childWndRect.left += diffRect.right; childWndRect.right += diffRect.right; } childWnd.MoveWindow(childWndRect.left, childWndRect.top, childWndRect.Width(), childWndRect.Height()); childWnd.RedrawWindow(); } inline void ChildWndSpan(CWnd& childWnd, RECT& diffRect) { CRect childWndRect; childWnd.GetWindowRect(&childWndRect); ScreenToClient(&childWndRect); childWndRect.bottom += diffRect.bottom; childWndRect.top += diffRect.top; childWndRect.left += diffRect.left; childWndRect.right += diffRect.right; childWnd.MoveWindow(childWndRect.left, childWndRect.top, childWndRect.Width(), childWndRect.Height()); childWnd.RedrawWindow(); } // 생성자 m_bSizing = FALSE; ZeroMemory(&initClientRect, sizeof RECT); ZeroMemory(&prevClientRect, sizeof RECT); // OnInitDialog() GetWindowRect(&initClientRect); prevClientRect = initClientRect; ScreenToClient(&prevClientRect); m_bSizing = TRUE; // MESSAGE_MAP ON_WM_GETMINMAXINFO() ON_WM_SIZE() // void C____Dlg::OnSize(UINT nType, int cx, int cy) { CDialogEx::OnSize(nType, cx, cy); if (m_bSizing) { RECT rect; GetWindowRect(&rect); OnSizeHelper(rect); } void C____Dlg::OnSizeHelper(RECT rect) { ScreenToClient(&rect); RECT diffRect; diffRect.bottom = rect.bottom - prevClientRect.bottom; diffRect.top = rect.top - prevClientRect.top; diffRect.left = rect.left - prevClientRect.left; diffRect.right = rect.right - prevClientRect.right; // Child Move ChildWndMove(m_btnMenu1, diffRect); ChildWndMove(m_btnMenu2, diffRect); ChildWndMove(*GetDlgItem(IDC_BTN_RELOAD), diffRect); ChildWndMove(*GetDlgItem(IDC_BTN_DELETE), diffRect); ChildWndMove(*GetDlgItem(IDC_BTN_DELETEALL), diffRect); ChildWndMove(m_btnConfig, diffRect); ChildWndMove(m_btnHelp, diffRect); ChildWndMove(*GetDlgItem(IDC_STATIC_COPYRIGHT), diffRect, TRUE); // Child Span ChildWndSpan(m_folderList, diffRect); prevClientRect = rect; } }}} ---- {{{ }}}