void CDlgResizer::DoResize(int width, int height) { UpdateGripPos(); if (m_controls.empty()) return; InvalidateRect(m_hDlg, NULL, true); HDWP hdwp = BeginDeferWindowPos((int)m_controls.size()); for (size_t i=0; i<m_controls.size(); ++i) { RECT newpos = m_controls[i].origSize; switch (m_controls[i].resizeType) { case RESIZER_TOPLEFT: break; // do nothing - the original position is fine case RESIZER_TOPRIGHT: newpos.left += (width - m_dlgRect.right); newpos.right += (width - m_dlgRect.right); break; case RESIZER_TOPLEFTRIGHT: newpos.right += (width - m_dlgRect.right); break; case RESIZER_TOPLEFTBOTTOMRIGHT: newpos.right += (width - m_dlgRect.right); newpos.bottom += (height - m_dlgRect.bottom); break; case RESIZER_BOTTOMLEFT: newpos.top += (height - m_dlgRect.bottom); newpos.bottom += (height - m_dlgRect.bottom); break; case RESIZER_BOTTOMRIGHT: newpos.top += (height - m_dlgRect.bottom); newpos.bottom += (height - m_dlgRect.bottom); newpos.left += (width - m_dlgRect.right); newpos.right += (width - m_dlgRect.right); break; case RESIZER_BOTTOMLEFTRIGHT: newpos.top += (height - m_dlgRect.bottom); newpos.bottom += (height - m_dlgRect.bottom); newpos.right += (width - m_dlgRect.right); break; } hdwp = DeferWindowPos(hdwp, m_controls[i].hWnd, NULL, newpos.left, newpos.top, newpos.right-newpos.left, newpos.bottom-newpos.top, SWP_NOZORDER); } EndDeferWindowPos(hdwp); UpdateGripPos(); }
BOOL MBMessageBoxImpl::InitGrip() { CRect rect(0 , 0, m_sizeGrip.cx, m_sizeGrip.cy); BOOL bRet = m_wndGrip.Create(WS_CHILD | WS_CLIPSIBLINGS | SBS_SIZEGRIP, rect, this, 0); if (bRet) { // set a triangular window region CRgn rgnGrip, rgn; rgn.CreateRectRgn(0,0,1,1); rgnGrip.CreateRectRgnIndirect(&rect); for (int y=0; y<m_sizeGrip.cy; y++) { rgn.SetRectRgn(0, y, m_sizeGrip.cx-y, y+1); rgnGrip.CombineRgn(&rgnGrip, &rgn, RGN_DIFF); } m_wndGrip.SetWindowRgn((HRGN)rgnGrip.Detach(), FALSE); // subclass control ::SetProp(m_wndGrip, RSZ_GRIP_OBJ, (HANDLE)::GetWindowLong(m_wndGrip, GWL_WNDPROC)); ::SetWindowLong(m_wndGrip, GWL_WNDPROC, (LONG)GripWindowProc); // update pos UpdateGripPos(); ShowSizeGrip(); } return bRet; }
void MBMessageBoxImpl::OnSizing(UINT fwSide, LPRECT pRect) { if (!::IsWindow(m_hWnd)) { return; } int left,right,top,bottom; left = pRect->left; right = pRect->right; top = pRect->top; bottom = pRect->bottom; if ((fwSide == 7 || fwSide == 1 || fwSide == 4) && (left > right - m_MinWidth)) left = right - m_MinWidth; if ((fwSide == 4 || fwSide == 3 || fwSide == 5) && (top > bottom - m_MinHeight)) top = bottom - m_MinHeight; if ((fwSide == 5 || fwSide == 2 || fwSide == 8) && (right < left + m_MinWidth)) right = left + m_MinWidth; if ((fwSide == 7 || fwSide == 6 || fwSide == 8) && (bottom < top + m_MinHeight)) bottom = top + m_MinHeight; pRect->left = left; pRect->right = right; pRect->top = top; pRect->bottom = bottom; CDialog::OnSizing(fwSide, pRect); UpdateGripPos(); }
void MBMessageBoxImpl::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); if (!::IsWindow(m_hWnd)) { return; } resizeControls(); UpdateGripPos(); }
void CFileAndFolder::OnSizing(UINT fwSide, LPRECT pRect) { int left,right,top,bottom; left = pRect->left; right = pRect->right; top = pRect->top; bottom = pRect->bottom; if ((fwSide == 7 || fwSide == 1 || fwSide == 4) && (left > right - MBCFAF_MIN_WIDTH)) left = right - MBCFAF_MIN_WIDTH; if ((fwSide == 4 || fwSide == 3 || fwSide == 5) && (top > bottom - MBCFAF_MIN_HEIGHT)) top = bottom - MBCFAF_MIN_HEIGHT; if ((fwSide == 5 || fwSide == 2 || fwSide == 8) && (right < left + MBCFAF_MIN_WIDTH)) right = left + MBCFAF_MIN_WIDTH; if ((fwSide == 7 || fwSide == 6 || fwSide == 8) && (bottom < top + MBCFAF_MIN_HEIGHT)) bottom = top + MBCFAF_MIN_HEIGHT; pRect->left = left; pRect->right = right; pRect->top = top; pRect->bottom = bottom; CDialog::OnSizing(fwSide, pRect); UpdateGripPos(); }
void CResizableDialog::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); if (nType == SIZE_MAXHIDE || nType == SIZE_MAXSHOW) return; // arrangement not needed if (m_bInitDone) { // update size-grip UpdateGripPos(); ArrangeLayout(); } }
BOOL CResizableGrip::InitGrip(HWND hParent) { m_hParent = hParent; RECT rect = { 0 , 0, m_sizeGrip.cx, m_sizeGrip.cy }; m_wndGrip = ::CreateWindowEx(0, _T("SCROLLBAR"), (LPTSTR)NULL, WS_CHILD | WS_CLIPSIBLINGS | SBS_SIZEGRIP, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, hParent, (HMENU)0, NULL, NULL); if (m_wndGrip) { // set a triangular window region HRGN rgnGrip, rgn; rgn = ::CreateRectRgn(0,0,1,1); rgnGrip = ::CreateRectRgnIndirect(&rect); for (int y=0; y<m_sizeGrip.cy; y++) { ::SetRectRgn(rgn, 0, y, m_sizeGrip.cx-y, y+1); ::CombineRgn(rgnGrip, rgnGrip, rgn, RGN_DIFF); } ::SetWindowRgn(m_wndGrip, rgnGrip, FALSE); // subclass control ::SetProp(m_wndGrip, RSZ_GRIP_OBJ, (HANDLE)::GetWindowLong(m_wndGrip, GWL_WNDPROC)); ::SetWindowLong(m_wndGrip, GWL_WNDPROC, (LONG)GripWindowProc); // force dialog styles (RESIZABLE BORDER, NO FLICKERING) ::SetWindowLong(hParent, GWL_STYLE, ::GetWindowLong(hParent, GWL_STYLE) | WS_THICKFRAME | WS_CLIPCHILDREN); // update pos UpdateGripPos(); ShowSizeGrip(); } return m_wndGrip!=NULL; }
BOOL CResizableDialog::OnInitDialog() { CDialog::OnInitDialog(); // gets the template size as the min track size CRect rc; GetWindowRect(&rc); SetMinTrackSize(rc.Size()); // init UpdateGripPos(); m_bInitDone = TRUE; return TRUE; // return TRUE unless you set the focus to a control }
void CDlgResizer::Init(HWND hWndDlg) { m_hDlg = hWndDlg; GetClientRect(hWndDlg, &m_dlgRect); GetWindowRect(hWndDlg, &m_dlgRectScreen); OffsetRect(&m_dlgRectScreen, -m_dlgRectScreen.left, -m_dlgRectScreen.top); m_sizeGrip.cx = GetSystemMetrics(SM_CXVSCROLL); m_sizeGrip.cy = GetSystemMetrics(SM_CYHSCROLL); RECT rect = { 0 , 0, m_sizeGrip.cx, m_sizeGrip.cy }; m_wndGrip = ::CreateWindowEx(0, _T("SCROLLBAR"), (LPCTSTR)NULL, WS_CHILD | WS_CLIPSIBLINGS | SBS_SIZEGRIP, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, m_hDlg, (HMENU)0, NULL, NULL); if (m_wndGrip) { // set a triangular window region HRGN rgnGrip, rgn; rgn = ::CreateRectRgn(0,0,1,1); rgnGrip = ::CreateRectRgnIndirect(&rect); for (int y=0; y<m_sizeGrip.cy; y++) { ::SetRectRgn(rgn, 0, y, m_sizeGrip.cx-y, y+1); ::CombineRgn(rgnGrip, rgnGrip, rgn, RGN_DIFF); } ::SetWindowRgn(m_wndGrip, rgnGrip, FALSE); // update pos UpdateGripPos(); ShowSizeGrip(); } }
BOOL CResizableSheet::OnInitDialog() { BOOL bResult = CPropertySheet::OnInitDialog(); // set the initial size as the min track size CRect rc; GetWindowRect(&rc); SetMinTrackSize(rc.Size()); // init UpdateGripPos(); PresetLayout(); // prevent flickering // GetTabControl()->ModifyStyle(0, WS_CLIPSIBLINGS); m_bInitDone = TRUE; return bResult; }