diff --git a/ResizableLib/ResizableComboBox.cpp b/ResizableLib/ResizableComboBox.cpp index ee89832..29501bc 100644 --- a/ResizableLib/ResizableComboBox.cpp +++ b/ResizableLib/ResizableComboBox.cpp @@ -28,6 +28,7 @@ static char THIS_FILE[] = __FILE__; // CResizableComboBox CResizableComboBox::CResizableComboBox() + : m_rectDropDown(), m_iExtent(0) { m_bClipMaxHeight = TRUE; m_bIntegralHeight = TRUE; @@ -49,10 +50,10 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CResizableComboBox message handlers -HBRUSH CResizableComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) +HBRUSH CResizableComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor); - + if (nCtlColor == CTLCOLOR_LISTBOX) { if (!(GetStyle() & CBS_SIMPLE) @@ -69,7 +70,7 @@ HBRUSH CResizableComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) return hbr; } -LRESULT CResizableComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CResizableComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { @@ -110,7 +111,7 @@ void CResizableComboBox::InitHorizontalExtent() CFont* pOldFont = dc.SelectObject(GetFont()); CString str; - + m_iExtent = 0; int n = GetCount(); for (int i=0; i(_tcslen(szText))).cx; if (cx > m_iExtent) { m_iExtent = cx; @@ -144,16 +145,16 @@ void CResizableComboBox::UpdateHorizontalExtent(LPCTSTR szText) dc.SelectObject(pOldFont); } -void CResizableComboBox::PreSubclassWindow() +void CResizableComboBox::PreSubclassWindow() { ASSERT(GetStyle() & CBS_NOINTEGRALHEIGHT); InitHorizontalExtent(); - + GetDroppedControlRect(&m_rectDropDown); ::MapWindowPoints(NULL, GetSafeHwnd(), (LPPOINT)&m_rectDropDown, 2); - + CComboBox::PreSubclassWindow(); } @@ -167,7 +168,7 @@ int CResizableComboBox::MakeIntegralHeight(const int height) if (!m_bIntegralHeight || n == 0) return inth; - + if (dwStyle & CBS_OWNERDRAWVARIABLE) { inth = 0; // try to reach availh by integral steps diff --git a/ResizableLib/ResizableComboLBox.cpp b/ResizableLib/ResizableComboLBox.cpp index c36eed1..1164b55 100644 --- a/ResizableLib/ResizableComboLBox.cpp +++ b/ResizableLib/ResizableComboLBox.cpp @@ -29,6 +29,7 @@ static char THIS_FILE[] = __FILE__; // CResizableComboLBox CResizableComboLBox::CResizableComboLBox() + : m_nHitTest(0), m_pOwnerCombo(NULL) { m_dwAddToStyle = WS_THICKFRAME; m_dwAddToStyleEx = 0;//WS_EX_CLIENTEDGE; @@ -56,7 +57,7 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CResizableComboLBox message handlers -void CResizableComboLBox::PreSubclassWindow() +void CResizableComboLBox::PreSubclassWindow() { CWnd::PreSubclassWindow(); @@ -90,7 +91,7 @@ void CResizableComboLBox::InitializeControl() SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE); } -void CResizableComboLBox::OnMouseMove(UINT nFlags, CPoint point) +void CResizableComboLBox::OnMouseMove(UINT nFlags, CPoint point) { CPoint pt = point; MapWindowPoints(NULL, &pt, 1); // to screen coord @@ -136,7 +137,7 @@ void CResizableComboLBox::OnMouseMove(UINT nFlags, CPoint point) SWP_NOACTIVATE|SWP_NOZORDER|nCopyFlag); } -void CResizableComboLBox::OnLButtonDown(UINT nFlags, CPoint point) +void CResizableComboLBox::OnLButtonDown(UINT nFlags, CPoint point) { CPoint pt = point; MapWindowPoints(NULL, &pt, 1); // to screen coord @@ -156,7 +157,7 @@ void CResizableComboLBox::OnLButtonDown(UINT nFlags, CPoint point) CWnd::OnLButtonDown(nFlags, point); } -void CResizableComboLBox::OnLButtonUp(UINT nFlags, CPoint point) +void CResizableComboLBox::OnLButtonUp(UINT nFlags, CPoint point) { CWnd::OnLButtonUp(nFlags, point); @@ -170,7 +171,7 @@ LRESULT CResizableComboLBox::OnNcHitTest(CPoint point) MapWindowPoints(NULL, &rcClient); // ask for default hit-test value - UINT ht = CWnd::OnNcHitTest(point); + LRESULT ht = CWnd::OnNcHitTest(point); // disable improper resizing (based on layout setting) switch (ht) @@ -217,7 +218,7 @@ LRESULT CResizableComboLBox::OnNcHitTest(CPoint point) return ht; } -void CResizableComboLBox::OnCaptureChanged(CWnd *pWnd) +void CResizableComboLBox::OnCaptureChanged(CWnd *pWnd) { EndSizing(); @@ -232,7 +233,7 @@ void CResizableComboLBox::EndSizing() m_sizeAfterSizing = rect.Size(); } -void CResizableComboLBox::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) +void CResizableComboLBox::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { if (!m_bSizing) { @@ -245,13 +246,13 @@ void CResizableComboLBox::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) CWnd::OnWindowPosChanging(lpwndpos); } -void CResizableComboLBox::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) +void CResizableComboLBox::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) { // default implementation sends a WM_SIZE message // that can change the size again to force integral height // since we do that manually during resize, we should also - // update the horizontal scrollbar + // update the horizontal scrollbar SendMessage(WM_HSCROLL, SB_ENDSCROLL, 0); GetWindowRect(&m_pOwnerCombo->m_rectDropDown); diff --git a/ResizableLib/ResizableComboLBox.h b/ResizableLib/ResizableComboLBox.h index 86fca95..3b6ca77 100644 --- a/ResizableLib/ResizableComboLBox.h +++ b/ResizableLib/ResizableComboLBox.h @@ -58,7 +58,7 @@ class CResizableComboLBox : public CWnd, public CResizableGrip CPoint m_ptBeforeSizing; // screen coords CRect m_rcBeforeSizing; // screen coords CSize m_sizeAfterSizing; // screen coords - UINT m_nHitTest; // current resize operation + LRESULT m_nHitTest; // current resize operation BOOL m_bSizing; void InitializeControl(); diff --git a/ResizableLib/ResizableDialog.h b/ResizableLib/ResizableDialog.h index 46d9026..4ff73a4 100644 --- a/ResizableLib/ResizableDialog.h +++ b/ResizableLib/ResizableDialog.h @@ -38,8 +38,8 @@ class CResizableDialog : public CDialog, public CResizableLayout, // Construction public: CResizableDialog(); - CResizableDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL); - CResizableDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL); + explicit CResizableDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL); + explicit CResizableDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL); // Attributes private: diff --git a/ResizableLib/ResizableFormView.cpp b/ResizableLib/ResizableFormView.cpp index df8a54d..e659b9e 100644 --- a/ResizableLib/ResizableFormView.cpp +++ b/ResizableLib/ResizableFormView.cpp @@ -181,7 +181,7 @@ void CResizableFormView::OnDestroy() LRESULT CResizableFormView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_INITDIALOG) - return (LRESULT)OnInitDialog(); + return static_cast(OnInitDialog()); if (message != WM_NCCALCSIZE || wParam == 0) return CFormView::WindowProc(message, wParam, lParam); @@ -198,7 +198,7 @@ BOOL CResizableFormView::OnInitDialog() { const MSG* pMsg = GetCurrentMessage(); - BOOL bRet = (BOOL)CFormView::WindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); + BOOL bRet = CFormView::WindowProc(pMsg->message, pMsg->wParam, pMsg->lParam) != 0; // we need to associate member variables with control IDs UpdateData(FALSE); @@ -213,12 +213,5 @@ BOOL CResizableFormView::OnInitDialog() BOOL CResizableFormView::OnNcCreate(LPCREATESTRUCT lpCreateStruct) { - if (!CFormView::OnNcCreate(lpCreateStruct)) - return FALSE; - - // create and init the size-grip - if (!CreateSizeGrip()) - return FALSE; - - return TRUE; + return CFormView::OnNcCreate(lpCreateStruct) && CreateSizeGrip(); // create and init the size-grip } diff --git a/ResizableLib/ResizableFormView.h b/ResizableLib/ResizableFormView.h index c8e082d..a54c26f 100644 --- a/ResizableLib/ResizableFormView.h +++ b/ResizableLib/ResizableFormView.h @@ -38,13 +38,13 @@ class CResizableFormView : public CFormView, public CResizableLayout, // Construction protected: // must derive your own class - CResizableFormView(UINT nIDTemplate); - CResizableFormView(LPCTSTR lpszTemplateName); + explicit CResizableFormView(UINT nIDTemplate); + explicit CResizableFormView(LPCTSTR lpszTemplateName); virtual ~CResizableFormView(); private: void PrivateConstruct(); - + // support for temporarily hiding the grip DWORD m_dwGripTempState; enum GripHideReason // bitmask diff --git a/ResizableLib/ResizableGrip.cpp b/ResizableLib/ResizableGrip.cpp index 744a00b..27c5d75 100644 --- a/ResizableLib/ResizableGrip.cpp +++ b/ResizableLib/ResizableGrip.cpp @@ -90,7 +90,7 @@ void CResizableGrip::HideSizeGrip(DWORD* pStatus, DWORD dwMask /*= 1*/) } } -BOOL CResizableGrip::IsSizeGripVisible() +BOOL CResizableGrip::IsSizeGripVisible() const { // NB: visibility is effective only after an update return (m_nShowCount > 0); @@ -139,7 +139,7 @@ BOOL CResizableGrip::CreateSizeGrip(BOOL bVisible /*= TRUE*/, m_wndGrip.SetTriangularShape(bTriangular); m_wndGrip.SetTransparency(bTransparent); SetSizeGripVisibility(bVisible); - + // update position UpdateSizeGrip(); } @@ -155,7 +155,7 @@ BOOL CResizableGrip::CSizeGrip::IsRTL() return GetExStyle() & WS_EX_LAYOUTRTL; } -BOOL CResizableGrip::CSizeGrip::PreCreateWindow(CREATESTRUCT& cs) +BOOL CResizableGrip::CSizeGrip::PreCreateWindow(CREATESTRUCT& cs) { // set window size m_size.cx = GetSystemMetrics(SM_CXVSCROLL); @@ -163,7 +163,7 @@ BOOL CResizableGrip::CSizeGrip::PreCreateWindow(CREATESTRUCT& cs) cs.cx = m_size.cx; cs.cy = m_size.cy; - + return CScrollBar::PreCreateWindow(cs); } @@ -184,11 +184,7 @@ LRESULT CResizableGrip::CSizeGrip::WindowProc(UINT message, case WM_NCHITTEST: // choose proper cursor shape - if (IsRTL()) - return HTBOTTOMLEFT; - else - return HTBOTTOMRIGHT; - break; + return IsRTL() ? HTBOTTOMLEFT : HTBOTTOMRIGHT; case WM_SETTINGCHANGE: { @@ -249,7 +245,7 @@ LRESULT CResizableGrip::CSizeGrip::WindowProc(UINT message, m_dcGrip.SetBkColor(m_dcGrip.GetPixel(0, 0)); m_dcMask.BitBlt(0, 0, m_size.cx, m_size.cy, &m_dcGrip, 0, 0, SRCCOPY); m_dcGrip.BitBlt(0, 0, m_size.cx, m_size.cy, &m_dcMask, 0, 0, 0x00220326); - + // draw transparently pDC->BitBlt(0, 0, m_size.cx, m_size.cy, &m_dcMask, 0, 0, SRCAND); pDC->BitBlt(0, 0, m_size.cx, m_size.cy, &m_dcGrip, 0, 0, SRCPAINT); @@ -262,7 +258,6 @@ LRESULT CResizableGrip::CSizeGrip::WindowProc(UINT message, EndPaint(&ps); return 0; } - break; } return CScrollBar::WindowProc(message, wParam, lParam); @@ -323,4 +318,4 @@ void CResizableGrip::CSizeGrip::SetTriangularShape(BOOL bEnable) { SetWindowRgn((HRGN)NULL, IsWindowVisible()); } -} +} \ No newline at end of file diff --git a/ResizableLib/ResizableGrip.h b/ResizableLib/ResizableGrip.h index 1a1181e..19c1f6a 100644 --- a/ResizableLib/ResizableGrip.h +++ b/ResizableLib/ResizableGrip.h @@ -33,13 +33,14 @@ /*! * long_description */ -class CResizableGrip +class CResizableGrip { private: class CSizeGrip : public CScrollBar { public: CSizeGrip() + : m_size() { m_bTransparent = FALSE; m_bTriangular = FALSE; @@ -73,7 +74,7 @@ class CResizableGrip BOOL CreateSizeGrip(BOOL bVisible = TRUE, BOOL bTriangular = TRUE, BOOL bTransparent = FALSE); - BOOL IsSizeGripVisible(); // TRUE if grip is set to be visible + BOOL IsSizeGripVisible() const; // TRUE if grip is set to be visible void SetSizeGripVisibility(BOOL bVisible); // set default visibility void UpdateSizeGrip(); // update the grip's visibility and position void ShowSizeGrip(DWORD* pStatus, DWORD dwMask = 1); // temp show the size grip diff --git a/ResizableLib/ResizableLayout.cpp b/ResizableLib/ResizableLayout.cpp index 8618449..2011b94 100644 --- a/ResizableLib/ResizableLayout.cpp +++ b/ResizableLib/ResizableLayout.cpp @@ -44,7 +44,7 @@ static char THIS_FILE[]=__FILE__; /*! * This function adds a new control to the layout manager and sets anchor * points for its top-left and bottom-right corners. - * + * * @param hWnd Window handle to the control to be added * @param anchorTopLeft Anchor point for the top-left corner * @param anchorBottomRight Anchor point for the bottom-right corner @@ -82,7 +82,7 @@ void CResizableLayout::AddAnchor(HWND hWnd, ANCHOR anchorTopLeft, ANCHOR anchorB marginTopLeft.cx = rectChild.left - rectParent.Width() * anchorTopLeft.cx / 100; marginTopLeft.cy = rectChild.top - rectParent.Height() * anchorTopLeft.cy / 100; - + // calculate margin for the bottom-right corner marginBottomRight.cx = rectChild.right - rectParent.Width() * anchorBottomRight.cx / 100; @@ -111,7 +111,7 @@ void CResizableLayout::AddAnchor(HWND hWnd, ANCHOR anchorTopLeft, ANCHOR anchorB /*! * This function adds all the controls not yet added to the layout manager * and sets anchor points for its top-left and bottom-right corners. - * + * * @param anchor Anchor point for the top-left and bottom-right corner * * @remarks Overlapping controls, like group boxes and the controls inside, @@ -126,7 +126,7 @@ void CResizableLayout::AddAllOtherAnchors(ANCHOR anchor) ASSERT(::IsWindow(hParent)); HWND hWnd = ::GetWindow(hParent, GW_CHILD); - while (hWnd != NULL) + while (hWnd != NULL) { POSITION pos; if (!m_mapLayout.Lookup(hWnd, pos)) @@ -148,7 +148,7 @@ void CResizableLayout::AddAllOtherAnchors(ANCHOR anchor) * * @sa AddAnchor ArrangeLayoutCallback ArrangeLayout */ -UINT CResizableLayout::AddAnchorCallback() +LRESULT CResizableLayout::AddAnchorCallback() { // one callback control cannot rely upon another callback control's // size and/or position (they're updated all together at the end) @@ -164,13 +164,13 @@ UINT CResizableLayout::AddAnchorCallback() /*! * This function is called for each placeholder added to the layout manager * and must be overridden to provide the necessary layout information. - * + * * @param layout Reference to a LAYOUTINFO structure to be filled with * layout information for the specified placeholder. * On input, nCallbackID is the identification number * returned by AddAnchorCallback. On output, anchor points and * the window handle must be set and valid. - * + * * @return The return value is @c TRUE if the layout information has been * provided successfully, @c FALSE to skip this placeholder. * @@ -183,9 +183,9 @@ UINT CResizableLayout::AddAnchorCallback() BOOL CResizableLayout::ArrangeLayoutCallback(LAYOUTINFO& layout) const { UNREFERENCED_PARAMETER(layout); - + ASSERT(FALSE); // must be overridden, if callback is used - + return FALSE; // no useful output data } @@ -197,35 +197,32 @@ BOOL CResizableLayout::ArrangeLayoutCallback(LAYOUTINFO& layout) const * once for performace reasons, so all the controls are in their * old position when AddAnchorCallback is called. * To know where a control will be placed use GetAnchorPosition. - * + * * @sa AddAnchor AddAnchorCallback ArrangeLayoutCallback GetAnchorPosition */ void CResizableLayout::ArrangeLayout() const { // common vars UINT uFlags; - LAYOUTINFO layout; CRect rectParent, rectChild; - int count = m_listLayout.GetCount(); - int countCB = m_listLayoutCB.GetCount(); + INT_PTR count = m_listLayout.GetCount() + m_listLayoutCB.GetCount(); - if (count + countCB == 0) + if (count <= 0) return; // get parent window's rect GetTotalClientRect(&rectParent); // reposition child windows - HDWP hdwp = ::BeginDeferWindowPos(count + countCB); - - POSITION pos = m_listLayout.GetHeadPosition(); - while (pos != NULL) + HDWP hdwp = ::BeginDeferWindowPos(static_cast(count)); + + for (POSITION pos = m_listLayout.GetHeadPosition(); pos != NULL;) { // get layout info - layout = m_listLayout.GetNext(pos); - + const LAYOUTINFO layout = m_listLayout.GetNext(pos); + // calculate new child's position, size and flags for SetWindowPos - CalcNewChildPosition(layout, rectParent, rectChild, uFlags); + CalcNewChildPosition(layout, rectParent, rectChild, &uFlags); // only if size or position changed if ((uFlags & (SWP_NOMOVE|SWP_NOSIZE)) != (SWP_NOMOVE|SWP_NOSIZE)) @@ -238,17 +235,16 @@ void CResizableLayout::ArrangeLayout() const // for callback items you may use GetAnchorPosition to know the // new position and size of a non-callback item after resizing - pos = m_listLayoutCB.GetHeadPosition(); - while (pos != NULL) + for (POSITION pos = m_listLayoutCB.GetHeadPosition(); pos != NULL;) { // get layout info - layout = m_listLayoutCB.GetNext(pos); + LAYOUTINFO layout = m_listLayoutCB.GetNext(pos); // request layout data if (!ArrangeLayoutCallback(layout)) continue; // calculate new child's position, size and flags for SetWindowPos - CalcNewChildPosition(layout, rectParent, rectChild, uFlags); + CalcNewChildPosition(layout, rectParent, rectChild, &uFlags); // only if size or position changed if ((uFlags & (SWP_NOMOVE|SWP_NOSIZE)) != (SWP_NOMOVE|SWP_NOSIZE)) @@ -311,7 +307,7 @@ void CResizableLayout::ClipChildWindow(const LAYOUTINFO& layout, * This function retrieves the clipping region for the current layout. * It can be used to draw directly inside the region, without applying * clipping as the ClipChildren function does. - * + * * @param pRegion Pointer to a CRegion object that holds the * calculated clipping region upon return * @@ -344,7 +340,7 @@ void CResizableLayout::GetClippingRegion(CRgn* pRegion) const { // get layout info layout = m_listLayout.GetNext(pos); - + if (::IsWindowVisible(layout.hWnd)) ClipChildWindow(layout, pRegion); } @@ -383,10 +379,10 @@ inline CWnd* GetRootParentWnd(CWnd* pWnd) * This function enables or restores clipping on the specified DC when * appropriate. It should be called whenever drawing on the window client * area to avoid flickering. - * - * @param pDC Pointer to the target device context + * + * @param pDC Pointer to the target device context * @param bUndo Flag that specifies wether to restore the clipping region - * + * * @return The return value is @c TRUE if the clipping region has been * modified, @c FALSE if clipping was not necessary. * @@ -441,7 +437,7 @@ BOOL CResizableLayout::ClipChildren(CDC* pDC, BOOL bUndo) ::SelectClipRgn(hDC, m_hOldClipRgn); else ::SelectClipRgn(hDC, NULL); - + return TRUE; } @@ -453,7 +449,7 @@ BOOL CResizableLayout::ClipChildren(CDC* pDC, BOOL bUndo) * classes too, in place of the standard GetClientRect. It can be useful * for windows with scrollbars or expanding windows, to provide the true * client area, including even those parts which are not visible. - * + * * @param lpRect Pointer to the RECT structure that holds the result * * @remarks Override this function to provide the client area the class uses @@ -469,13 +465,13 @@ void CResizableLayout::GetTotalClientRect(LPRECT lpRect) const /*! * This function is used to determine if a control needs to be painted when * it is moved or resized by the layout manager. - * + * * @param layout Reference to a @c LAYOUTINFO structure for the control * @param rectOld Reference to a @c RECT structure that holds the control * position and size before the layout update * @param rectNew Reference to a @c RECT structure that holds the control * position and size after the layout update - * + * * @return The return value is @c TRUE if the control should be freshly * painted after a layout update, @c FALSE if not necessary. * @@ -511,7 +507,7 @@ BOOL CResizableLayout::NeedsRefresh(const LAYOUTINFO& layout, // window classes that need refresh when resized if (0 == lstrcmp(layout.sWndClass, WC_STATIC)) { - DWORD style = ::GetWindowLong(layout.hWnd, GWL_STYLE); + LONG_PTR style = ::GetWindowLongPtr(layout.hWnd, GWL_STYLE); switch (style & SS_TYPEMASK) { @@ -562,10 +558,10 @@ BOOL CResizableLayout::NeedsRefresh(const LAYOUTINFO& layout, SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); info.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; - if (::GetScrollInfo(layout.hWnd, SB_HORZ, &info)) + if (::GetScrollInfo(layout.hWnd, SB_HORZ, &info) && info.nPage > 1) //fix for unsigned subtraction { // subtract the page size - info.nMax -= __max(info.nPage - 1, 0); + info.nMax -= info.nPage-1; //should not use __max() macro } // resizing will cause the text to scroll on the right @@ -584,9 +580,9 @@ BOOL CResizableLayout::NeedsRefresh(const LAYOUTINFO& layout, * This function is used to determine if a control can be safely clipped * out of the parent window client area when it is repainted, usually * after a resize operation. - * + * * @param layout Reference to a @c LAYOUTINFO structure for the control - * + * * @return The return value is @c TRUE if clipping is supported by the * control, @c FALSE otherwise. * @@ -606,7 +602,7 @@ BOOL CResizableLayout::LikesClipping(const LAYOUTINFO& layout) const return clipping.bLikesClipping; } - DWORD style = ::GetWindowLong(layout.hWnd, GWL_STYLE); + LONG_PTR style = ::GetWindowLongPtr(layout.hWnd, GWL_STYLE); // skip windows that wants background repainted if (0 == lstrcmp(layout.sWndClass, WC_BUTTON)) @@ -649,14 +645,12 @@ BOOL CResizableLayout::LikesClipping(const LAYOUTINFO& layout) const case SS_BITMAP: // bitmaps return TRUE; - break; case SS_ICON: case SS_ENHMETAFILE: if (style & SS_CENTERIMAGE) return FALSE; return TRUE; - break; default: return FALSE; @@ -673,19 +667,19 @@ BOOL CResizableLayout::LikesClipping(const LAYOUTINFO& layout) const * control in the layout and flags for @c SetWindowPos */ void CResizableLayout::CalcNewChildPosition(const LAYOUTINFO& layout, - const CRect &rectParent, CRect &rectChild, UINT& uFlags) const + const CRect &rectParent, CRect &rectChild, UINT *lpFlags) const { CWnd* pParent = GetResizableWnd(); ::GetWindowRect(layout.hWnd, &rectChild); ::MapWindowPoints(NULL, pParent->m_hWnd, (LPPOINT)&rectChild, 2); - + CRect rectNew; // calculate new top-left corner rectNew.left = layout.marginTopLeft.cx + rectParent.Width() * layout.anchorTopLeft.cx / 100; rectNew.top = layout.marginTopLeft.cy + rectParent.Height() * layout.anchorTopLeft.cy / 100; - + // calculate new bottom-right corner rectNew.right = layout.marginBottomRight.cx + rectParent.Width() * layout.anchorBottomRight.cx / 100; rectNew.bottom = layout.marginBottomRight.cy + rectParent.Height() * layout.anchorBottomRight.cy / 100; @@ -697,14 +691,16 @@ void CResizableLayout::CalcNewChildPosition(const LAYOUTINFO& layout, BOOL bRefresh = layout.properties.bAskRefresh ? NeedsRefresh(layout, rectChild, rectNew) : layout.properties.bCachedNeedsRefresh; - // set flags - uFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION; - if (bRefresh) - uFlags |= SWP_NOCOPYBITS; - if (rectNew.TopLeft() == rectChild.TopLeft()) - uFlags |= SWP_NOMOVE; - if (rectNew.Size() == rectChild.Size()) - uFlags |= SWP_NOSIZE; + // set flags + if (lpFlags) { + *lpFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION; + if (bRefresh) + *lpFlags |= SWP_NOCOPYBITS; + if (rectNew.TopLeft() == rectChild.TopLeft()) + *lpFlags |= SWP_NOMOVE; + if (rectNew.Size() == rectChild.Size()) + *lpFlags |= SWP_NOSIZE; + } // update rect rectChild = rectNew; @@ -713,11 +709,11 @@ void CResizableLayout::CalcNewChildPosition(const LAYOUTINFO& layout, /*! * This function calculates the top, left, bottom, right margins for a * given size of the specified control. - * + * * @param hWnd Window handle to a control in the layout * @param sizeChild Size of the control to use in calculations * @param rectMargins Holds the calculated margins - * + * * @return The return value is @c TRUE if successful, @c FALSE otherwise * * @remarks This function can be used to infer the parent window size @@ -752,7 +748,7 @@ BOOL CResizableLayout::GetAnchorMargins(HWND hWnd, const CSize &sizeChild, CRect * This function is used to set the initial resize properties of a control * in the layout, that are stored in the @c properties member of the * related @c LAYOUTINFO structure. - * + * * @param layout Reference to the @c LAYOUTINFO structure to be set * * @remarks The various flags are used to specify whether the resize @@ -760,7 +756,7 @@ BOOL CResizableLayout::GetAnchorMargins(HWND hWnd, const CSize &sizeChild, CRect * call to the property querying functions is needed at every * layout update, or they are static properties, and the cached * value is used whenever necessary. - * @n The default implementation sends a registered message to the + * @n The default implementation sends a registered message to the * control, giving it the opportunity to specify its resize * properties, which takes precedence if the message is supported. * It then sets the @a clipping property as static, calling @@ -794,15 +790,15 @@ void CResizableLayout::InitResizeProperties(LAYOUTINFO &layout) const /*! * This function modifies a window to enable resizing functionality. * This affects the window style, size, system menu and appearance. - * + * * @param lpCreateStruct Pointer to a @c CREATESTRUCT structure, usually * passed by the system to the window procedure in a @c WM_CREATE * or @c WM_NCCREATE - * + * * @remarks The function is intended to be called only inside a @c WM_CREATE * or @c WM_NCCREATE message handler. */ -void CResizableLayout::MakeResizable(LPCREATESTRUCT lpCreateStruct) +void CResizableLayout::MakeResizable(LPCREATESTRUCT lpCreateStruct) const { if (lpCreateStruct->style & WS_CHILD) return; @@ -838,7 +834,7 @@ void CResizableLayout::MakeResizable(LPCREATESTRUCT lpCreateStruct) /*! * This function should be called inside the parent window @c WM_NCCALCSIZE * message handler to help eliminate flickering. - * + * * @param bAfterDefault Flag that specifies wether the call is made before * or after the default handler * @param lpncsp Pointer to the @c NCCALCSIZE_PARAMS structure that is @@ -846,7 +842,7 @@ void CResizableLayout::MakeResizable(LPCREATESTRUCT lpCreateStruct) * @param lResult Reference to the result of the message handler. * It contains the default handler result on input and the value to * return from the window procedure on output. - * + * * @remarks This function fixes the annoying flickering effect that is * visible when resizing the top or left edges of the window * (at least on a "left to right" Windows localized version). diff --git a/ResizableLib/ResizableLayout.h b/ResizableLib/ResizableLayout.h index 589567c..a1901cd 100644 --- a/ResizableLib/ResizableLayout.h +++ b/ResizableLib/ResizableLayout.h @@ -21,7 +21,7 @@ #if !defined(AFX_RESIZABLELAYOUT_H__INCLUDED_) #define AFX_RESIZABLELAYOUT_H__INCLUDED_ -#include +//#include #include "ResizableMsgSupport.h" #if _MSC_VER > 1000 @@ -43,7 +43,7 @@ typedef struct tagANCHOR int cx; //!< horizontal component, in percent int cy; //!< vertical component, in percent - tagANCHOR() {} + tagANCHOR() : cx(0), cy(0) {} tagANCHOR(int x, int y) { @@ -88,7 +88,7 @@ typedef struct tagLAYOUTINFO //! Handle of the window the layout of which is being defined HWND hWnd; //! Identification number assigned to the callback slot - UINT nCallbackID; + LRESULT nCallbackID; //! Window class name to identify standard controls TCHAR sWndClass[MAX_PATH]; @@ -97,7 +97,7 @@ typedef struct tagLAYOUTINFO ANCHOR anchorTopLeft; //! Fixed distance for the top-left corner SIZE marginTopLeft; - + //! Anchor point for the bottom-right corner ANCHOR anchorBottomRight; //! Fixed distance for the bottom-right corner @@ -109,11 +109,12 @@ typedef struct tagLAYOUTINFO RESIZEPROPERTIES properties; tagLAYOUTINFO() : hWnd(NULL), nCallbackID(0), bMsgSupport(FALSE) + , marginTopLeft(), marginBottomRight() { sWndClass[0] = 0; } - tagLAYOUTINFO(HWND hwnd, ANCHOR tl_type, SIZE tl_margin, + tagLAYOUTINFO(HWND hwnd, ANCHOR tl_type, SIZE tl_margin, ANCHOR br_type, SIZE br_margin) : hWnd(hwnd), nCallbackID(0), bMsgSupport(FALSE), @@ -159,7 +160,7 @@ class CResizableLayout //! @brief Helper function to calculate new layout void CalcNewChildPosition(const LAYOUTINFO &layout, - const CRect &rectParent, CRect &rectChild, UINT& uFlags) const; + const CRect &rectParent, CRect &rectChild, UINT *lpFlags) const; protected: //! @brief Override to initialize resize properties (clipping, refresh) @@ -177,7 +178,7 @@ class CResizableLayout //! @brief Get the layout clipping region void GetClippingRegion(CRgn* pRegion) const; - + //! @brief Override for scrollable or expanding parent windows virtual void GetTotalClientRect(LPRECT lpRect) const; @@ -214,7 +215,7 @@ class CResizableLayout //@} //! @brief Add a callback slot to the layout for dynamic controls or anchor points - UINT AddAnchorCallback(); + LRESULT AddAnchorCallback(); //@{ //! @brief Get position and size of a control in the layout from the parent's client area @@ -225,9 +226,7 @@ class CResizableLayout if (!m_mapLayout.Lookup(hWnd, pos)) return FALSE; - UINT uTmpFlags; - CalcNewChildPosition(m_listLayout.GetAt(pos), rectParent, rectChild, - (lpFlags != NULL) ? (*lpFlags) : uTmpFlags); + CalcNewChildPosition(m_listLayout.GetAt(pos), rectParent, rectChild, lpFlags); return TRUE; } @@ -287,12 +286,13 @@ class CResizableLayout //! @brief Enhance anti-flickering void HandleNcCalcSize(BOOL bAfterDefault, LPNCCALCSIZE_PARAMS lpncsp, LRESULT& lResult); - + //! @brief Enable resizable style for top level parent windows - void MakeResizable(LPCREATESTRUCT lpCreateStruct); + void MakeResizable(LPCREATESTRUCT lpCreateStruct) const; public: CResizableLayout() + : m_rectClientBefore() { m_bNoRecursion = FALSE; m_hOldClipRgn = ::CreateRectRgn(0,0,0,0); diff --git a/ResizableLib/ResizableMinMax.cpp b/ResizableLib/ResizableMinMax.cpp index 4072026..12ecfd5 100644 --- a/ResizableLib/ResizableMinMax.cpp +++ b/ResizableLib/ResizableMinMax.cpp @@ -32,6 +32,7 @@ static char THIS_FILE[]=__FILE__; ////////////////////////////////////////////////////////////////////// CResizableMinMax::CResizableMinMax() + : m_ptMinTrackSize(), m_ptMaxTrackSize(), m_ptMaxPos(), m_ptMaxSize() { m_bUseMinTrack = FALSE; m_bUseMaxTrack = FALSE; @@ -43,7 +44,7 @@ CResizableMinMax::~CResizableMinMax() } -void CResizableMinMax::MinMaxInfo(LPMINMAXINFO lpMMI) +void CResizableMinMax::MinMaxInfo(LPMINMAXINFO lpMMI) const { if (m_bUseMinTrack) lpMMI->ptMinTrackSize = m_ptMinTrackSize; diff --git a/ResizableLib/ResizableMinMax.h b/ResizableLib/ResizableMinMax.h index 1c64f9c..8f7fe4f 100644 --- a/ResizableLib/ResizableMinMax.h +++ b/ResizableLib/ResizableMinMax.h @@ -52,12 +52,12 @@ class CResizableMinMax virtual ~CResizableMinMax(); protected: - void MinMaxInfo(LPMINMAXINFO lpMMI); - void ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentFrame, CWnd* pWnd); + void MinMaxInfo(LPMINMAXINFO lpMMI) const; + static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentFrame, CWnd* pWnd); - void ChainMinMaxInfo(LPMINMAXINFO lpMMI, HWND hWndChild, CSize sizeExtra); - - void ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentWnd, UINT nID, CSize sizeExtra) + static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, HWND hWndChild, CSize sizeExtra); + + static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentWnd, UINT nID, CSize sizeExtra) { ChainMinMaxInfo(lpMMI, ::GetDlgItem(pParentWnd->GetSafeHwnd(), nID), sizeExtra); diff --git a/ResizableLib/ResizableMsgSupport.h b/ResizableLib/ResizableMsgSupport.h index 06cbd31..b40c0da 100644 --- a/ResizableLib/ResizableMsgSupport.h +++ b/ResizableLib/ResizableMsgSupport.h @@ -54,7 +54,7 @@ typedef struct tagREFRESHPROPERTY RECT rcNew; // initialize with valid data - tagREFRESHPROPERTY() : bNeedsRefresh(TRUE) {} + tagREFRESHPROPERTY() : bNeedsRefresh(TRUE), rcOld(), rcNew() {} } REFRESHPROPERTY, *PREFRESHPROPERTY, *LPREFRESHPROPERTY; diff --git a/ResizableLib/ResizablePage.h b/ResizableLib/ResizablePage.h index 4c7c992..1053d35 100644 --- a/ResizableLib/ResizablePage.h +++ b/ResizableLib/ResizablePage.h @@ -36,8 +36,8 @@ class CResizablePage : public CPropertyPage, public CResizableLayout, // Construction public: CResizablePage(); - CResizablePage(UINT nIDTemplate, UINT nIDCaption = 0); - CResizablePage(LPCTSTR lpszTemplateName, UINT nIDCaption = 0); + explicit CResizablePage(UINT nIDTemplate, UINT nIDCaption = 0); + explicit CResizablePage(LPCTSTR lpszTemplateName, UINT nIDCaption = 0); // Attributes public: diff --git a/ResizableLib/ResizablePageEx.h b/ResizableLib/ResizablePageEx.h index c4240f6..25e960d 100644 --- a/ResizableLib/ResizablePageEx.h +++ b/ResizableLib/ResizablePageEx.h @@ -36,8 +36,8 @@ class CResizablePageEx : public CPropertyPageEx, public CResizableLayout, // Construction public: CResizablePageEx(); - CResizablePageEx(UINT nIDTemplate, UINT nIDCaption = 0, UINT nIDHeaderTitle = 0, UINT nIDHeaderSubTitle = 0); - CResizablePageEx(LPCTSTR lpszTemplateName, UINT nIDCaption = 0, UINT nIDHeaderTitle = 0, UINT nIDHeaderSubTitle = 0); + explicit CResizablePageEx(UINT nIDTemplate, UINT nIDCaption = 0, UINT nIDHeaderTitle = 0, UINT nIDHeaderSubTitle = 0); + explicit CResizablePageEx(LPCTSTR lpszTemplateName, UINT nIDCaption = 0, UINT nIDHeaderTitle = 0, UINT nIDHeaderSubTitle = 0); // Attributes public: diff --git a/ResizableLib/ResizableSheet.h b/ResizableLib/ResizableSheet.h index e4270c4..373b6d6 100644 --- a/ResizableLib/ResizableSheet.h +++ b/ResizableLib/ResizableSheet.h @@ -38,8 +38,8 @@ class CResizableSheet : public CPropertySheet, public CResizableLayout, // Construction public: CResizableSheet(); - CResizableSheet(UINT nIDCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0); - CResizableSheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0); + explicit CResizableSheet(UINT nIDCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0); + explicit CResizableSheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0); // Attributes private: @@ -52,7 +52,7 @@ class CResizableSheet : public CPropertySheet, public CResizableLayout, BOOL m_bSavePage; // layout vars - UINT m_nCallbackID; + LRESULT m_nCallbackID; CSize m_sizePageTL, m_sizePageBR; BOOL m_bLayoutDone; diff --git a/ResizableLib/ResizableSheetEx.cpp b/ResizableLib/ResizableSheetEx.cpp index 67eada3..898e6a4 100644 --- a/ResizableLib/ResizableSheetEx.cpp +++ b/ResizableLib/ResizableSheetEx.cpp @@ -130,7 +130,7 @@ LRESULT CResizableSheetEx::OnResizeSupport(WPARAM wParam, LPARAM lParam) // a window object must be still associated to the page handle // but MFC subclassing has been turned off to allow the system // to subclass it first, so we can catch all the messages - CWnd* pWnd = CWnd::FromHandlePermanent((HWND)lParam); + CWnd* pWnd = CWnd::FromHandle((HWND)lParam); if (pWnd == NULL) return 0; diff --git a/ResizableLib/ResizableSheetEx.h b/ResizableLib/ResizableSheetEx.h index beb7fb5..5716403 100644 --- a/ResizableLib/ResizableSheetEx.h +++ b/ResizableLib/ResizableSheetEx.h @@ -38,9 +38,9 @@ class CResizableSheetEx : public CPropertySheetEx, public CResizableLayout, // Construction public: CResizableSheetEx(); - CResizableSheetEx(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0, + explicit CResizableSheetEx(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0, HBITMAP hbmWatermark = NULL, HPALETTE hpalWatermark = NULL, HBITMAP hbmHeader = NULL); - CResizableSheetEx(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0, + explicit CResizableSheetEx(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0, HBITMAP hbmWatermark = NULL, HPALETTE hpalWatermark = NULL, HBITMAP hbmHeader = NULL); // Attributes @@ -54,7 +54,7 @@ class CResizableSheetEx : public CPropertySheetEx, public CResizableLayout, BOOL m_bSavePage; // layout vars - UINT m_nCallbackID; + LRESULT m_nCallbackID; CSize m_sizePageTL, m_sizePageBR; BOOL m_bLayoutDone; diff --git a/ResizableLib/ResizableSheetState.cpp b/ResizableLib/ResizableSheetState.cpp index 723143c..49b9ef3 100644 --- a/ResizableLib/ResizableSheetState.cpp +++ b/ResizableLib/ResizableSheetState.cpp @@ -66,9 +66,9 @@ BOOL CResizableSheetState::SavePage(LPCTSTR pszName) if (page < 0) page = pSheet->m_psh.nStartPage; - CString data, id; - _itot(page, data.GetBuffer(10), 10); - id = CString(pszName) + ACTIVEPAGE_ENT; + CString data; + _itot_s(page, data.GetBuffer(10), 10, 10); + CString id = CString(pszName) + ACTIVEPAGE_ENT; return WriteState(id, data); } diff --git a/ResizableLib/ResizableState.cpp b/ResizableLib/ResizableState.cpp index 2a8d119..e0600b7 100644 --- a/ResizableLib/ResizableState.cpp +++ b/ResizableLib/ResizableState.cpp @@ -50,7 +50,7 @@ CString CResizableState::m_sDefaultStorePath(_T("ResizableState")); * Static function to set the default path used to store state information. * This path is used to initialize all the instances of this class. * @sa GetDefaultStateStore GetStateStore SetStateStore - * + * * @param szPath String that specifies the new path to be set */ void CResizableState::SetDefaultStateStore(LPCTSTR szPath) @@ -63,7 +63,7 @@ void CResizableState::SetDefaultStateStore(LPCTSTR szPath) * information. * This path is used to initialize all the instances of this class. * @sa SetDefaultStateStore GetStateStore SetStateStore - * + * * @return The return value is a string that specifies the current path */ LPCTSTR CResizableState::GetDefaultStateStore() @@ -75,7 +75,7 @@ LPCTSTR CResizableState::GetDefaultStateStore() * This function sets the path used to store state information by * the current instance of the class. * @sa GetStateStore GetDefaultStateStore SetDefaultStateStore - * + * * @param szPath String that specifies the new path to be set */ void CResizableState::SetStateStore(LPCTSTR szPath) @@ -87,10 +87,10 @@ void CResizableState::SetStateStore(LPCTSTR szPath) * This function retrieves the path used to store state information by * the current instance of the class. * @sa SetStateStore GetDefaultStateStore SetDefaultStateStore - * + * * @return The return value is a string that specifies the current path */ -LPCTSTR CResizableState::GetStateStore() +LPCTSTR CResizableState::GetStateStore() const { return m_sStorePath; } @@ -101,10 +101,10 @@ LPCTSTR CResizableState::GetStateStore() * The base implementation uses the application profile to persist state * information, but this function can be overridden to implement * different methods. - * + * * @param szId String that identifies the stored settings * @param szState String that represents the state information to store - * + * * @return The return value is @a TRUE if settings have been successfully * stored, @a FALSE otherwise. */ @@ -119,10 +119,10 @@ BOOL CResizableState::WriteState(LPCTSTR szId, LPCTSTR szState) * The base implementation uses the application profile to persist state * information, but this function can be overridden to implement * different methods. - * + * * @param szId String that identifies the stored settings * @param rsState String to be filled with the retrieved state information - * + * * @return The return value is @a TRUE if settings have been successfully * retrieved, @a FALSE otherwise. */ diff --git a/ResizableLib/ResizableState.h b/ResizableLib/ResizableState.h index a60b340..01aeb61 100644 --- a/ResizableLib/ResizableState.h +++ b/ResizableLib/ResizableState.h @@ -36,31 +36,31 @@ * be set to either the Registry or an INI File. Other storing methods * can be implemented in derived classes. */ -class CResizableState +class CResizableState { static CString m_sDefaultStorePath; CString m_sStorePath; protected: - + //! @brief Get default path where state is stored static LPCTSTR GetDefaultStateStore(); - + //! @brief Set default path where state is stored static void SetDefaultStateStore(LPCTSTR szPath); //! @brief Get current path where state is stored - LPCTSTR GetStateStore(); - + LPCTSTR GetStateStore() const; + //! @brief Set current path where state is stored void SetStateStore(LPCTSTR szPath); //! @name Overridables //@{ - + //! @brief Read state information virtual BOOL ReadState(LPCTSTR szId, CString& rsState); - + //! @brief Write state information virtual BOOL WriteState(LPCTSTR szId, LPCTSTR szState); diff --git a/ResizableLib/ResizableWndState.cpp b/ResizableLib/ResizableWndState.cpp index d290213..404dd3c 100644 --- a/ResizableLib/ResizableWndState.cpp +++ b/ResizableLib/ResizableWndState.cpp @@ -40,7 +40,7 @@ CResizableWndState::~CResizableWndState() // depending on your application settings #define PLACEMENT_ENT _T("WindowPlacement") -#define PLACEMENT_FMT _T("%d,%d,%d,%d,%d,%d,%d,%d") +#define PLACEMENT_FMT _T("%ld,%ld,%ld,%ld,%u,%u,%ld,%ld") /*! * This function saves the current window position and size using the base @@ -49,29 +49,27 @@ CResizableWndState::~CResizableWndState() * @sa CResizableState::WriteState * @note Window coordinates are in the form used by the system functions * GetWindowPlacement and SetWindowPlacement. - * + * * @param pszName String that identifies stored settings * @param bRectOnly Flag that specifies wether to ignore min/max state - * + * * @return Returns @a TRUE if successful, @a FALSE otherwise */ BOOL CResizableWndState::SaveWindowRect(LPCTSTR pszName, BOOL bRectOnly) { CString data, id; - WINDOWPLACEMENT wp; + WINDOWPLACEMENT wp = {sizeof(WINDOWPLACEMENT)}; - ZeroMemory(&wp, sizeof(WINDOWPLACEMENT)); - wp.length = sizeof(WINDOWPLACEMENT); if (!GetResizableWnd()->GetWindowPlacement(&wp)) return FALSE; - + // use workspace coordinates RECT& rc = wp.rcNormalPosition; if (bRectOnly) // save size/pos only (normal state) { data.Format(PLACEMENT_FMT, rc.left, rc.top, - rc.right, rc.bottom, SW_SHOWNORMAL, 0, 0, 0); + rc.right, rc.bottom, SW_SHOWNORMAL, 0U, 0L, 0L); } else // save also min/max state { @@ -91,30 +89,28 @@ BOOL CResizableWndState::SaveWindowRect(LPCTSTR pszName, BOOL bRectOnly) * @sa CResizableState::WriteState * @note Window coordinates are in the form used by the system functions * GetWindowPlacement and SetWindowPlacement. - * + * * @param pszName String that identifies stored settings * @param bRectOnly Flag that specifies wether to ignore min/max state - * + * * @return Returns @a TRUE if successful, @a FALSE otherwise */ BOOL CResizableWndState::LoadWindowRect(LPCTSTR pszName, BOOL bRectOnly) { CString data, id; - WINDOWPLACEMENT wp; + WINDOWPLACEMENT wp = {sizeof(WINDOWPLACEMENT)}; id = CString(pszName) + PLACEMENT_ENT; if (!ReadState(id, data)) // never saved before return FALSE; - - ZeroMemory(&wp, sizeof(WINDOWPLACEMENT)); - wp.length = sizeof(WINDOWPLACEMENT); + if (!GetResizableWnd()->GetWindowPlacement(&wp)) return FALSE; // use workspace coordinates RECT& rc = wp.rcNormalPosition; - if (_stscanf(data, PLACEMENT_FMT, &rc.left, &rc.top, + if (_stscanf_s(data, PLACEMENT_FMT, &rc.left, &rc.top, &rc.right, &rc.bottom, &wp.showCmd, &wp.flags, &wp.ptMinPosition.x, &wp.ptMinPosition.y) == 8) { @@ -122,12 +118,9 @@ BOOL CResizableWndState::LoadWindowRect(LPCTSTR pszName, BOOL bRectOnly) { wp.showCmd = SW_SHOWNORMAL; wp.flags = 0; - return GetResizableWnd()->SetWindowPlacement(&wp); - } - else // restore also min/max state - { - return GetResizableWnd()->SetWindowPlacement(&wp); } + // restore also min/max state + return GetResizableWnd()->SetWindowPlacement(&wp); } return FALSE; -} +} \ No newline at end of file