void CSnapView::OnSize(UINT nType, int cx, int cy) { if (nType != SIZE_MINIMIZED && cx != 0 && cy != 0 && m_pPropSheet != NULL) { if (m_bSizedBefore == FALSE) { m_bSizedBefore = TRUE; // get the size of the property sheet CRect rectSized; m_pPropSheet->GetWindowRect(rectSized); // calculate the size of the frame CFrameWnd* pFrame = GetParentFrame(); if (pFrame != NULL) { pFrame->CalcWindowRect(rectSized); CWnd* pParent = pFrame->GetParent(); if (pParent != NULL) pParent->ScreenToClient(rectSized); // resize and reposition the frame pFrame->MoveWindow(rectSized); } } } }
BOOL CSnapView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { ENSURE(pParentWnd != NULL); ASSERT_KINDOF(CFrameWnd, pParentWnd); if (!CWnd::Create(lpszClassName, lpszWindowName, dwStyle | WS_CLIPCHILDREN, rect, pParentWnd, nID, pContext)) { return FALSE; } // add your pages here! m_pPageBkfst = new CBkfstPage; m_pPageLunch = new CLunchPage; m_pPageDinner = new CDinnerPage; // create the window object m_pPropSheet = new CSnapPropertySheet; m_pPropSheet->AddPage(m_pPageBkfst); m_pPropSheet->AddPage(m_pPageLunch); m_pPropSheet->AddPage(m_pPageDinner); // create a modeless property page if (!m_pPropSheet->Create(this, DS_CONTEXTHELP | DS_SETFONT | WS_CHILD | WS_VISIBLE)) { DestroyWindow(); return FALSE; } m_pPropSheet->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE); // we use the style from the template - but make sure that // the WS_BORDER bit is correct. // the WS_BORDER bit will be whatever is in dwRequestedStyle m_pPropSheet->ModifyStyle(WS_BORDER|WS_CAPTION, dwStyle & (WS_BORDER|WS_CAPTION)); // Force the size requested. // Fake a call to OnSize()--it would have been called automatically // if this were using the base class implementation of Create(). CFrameWnd* pParentFrame = GetParentFrame(); CRect rectSize; m_pPropSheet->GetWindowRect(rectSize); pParentFrame->CalcWindowRect(rectSize); OnSize(SIZE_RESTORED, rectSize.Width(), rectSize.Height()); return TRUE; }
void CMFCMDIPlayerView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); if (cy && cx) { // calculate the size of the frame CFrameWnd* pFrame = GetParentFrame(); if (pFrame != NULL) { CRect rectSized(0, 0, cx, cy); pFrame->CalcWindowRect(rectSized); pFrame->SetWindowPos(this,0,0,rectSized.Width() + 4,rectSized.Height()+ 4, SWP_NOZORDER | SWP_NOMOVE ); } } }
LONG CMCIWndDemoView::OnNotifySize(UINT wParam, LONG lParam) { CRect rcMCI; CFrameWnd* pParent = GetParentFrame(); if(m_hMCIWnd) { ::GetWindowRect(m_hMCIWnd, rcMCI); pParent->CalcWindowRect(rcMCI, CWnd::adjustBorder); CSize size(rcMCI.Width(), rcMCI.Height()); if(GetExStyle() & WS_EX_CLIENTEDGE) { size.cx += 4; size.cy += 44; } pParent->SetWindowPos(NULL, 0, 0, size.cx, size.cy, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); } else { pParent->SetWindowPos(NULL, 0, 0, 320, 160, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); } return 1L; }