From ae62e78c83e06e1401b3bab5ae956c46cff5051b Mon Sep 17 00:00:00 2001 From: irwir Date: Sat, 16 Dec 2017 22:10:02 +0300 Subject: [PATCH] Pass objects by constant reference instead of passing by value. Local variables: reduce scope, eliminate intermediates, add 'const' qualifiers. Reorder statements in case of an early return. Use CString.Format instead of conversion function. Minor cleaning in .vcxpoj file: default settings for CResizable(L)Box.* --- ResizableLib/ResizableComboBox.cpp | 64 +++++++++++++-------------- ResizableLib/ResizableFormView.cpp | 7 ++- ResizableLib/ResizableLayout.cpp | 38 +++++++--------- ResizableLib/ResizableLib.vcxproj | 44 ++---------------- ResizableLib/ResizableMinMax.cpp | 8 ++-- ResizableLib/ResizableMinMax.h | 8 ++-- ResizableLib/ResizableSheet.cpp | 15 +++---- ResizableLib/ResizableSheet.h | 2 +- ResizableLib/ResizableSheetEx.cpp | 19 ++++---- ResizableLib/ResizableSheetEx.h | 2 +- ResizableLib/ResizableSheetState.cpp | 21 ++++----- ResizableLib/ResizableSplitterWnd.cpp | 8 ++-- ResizableLib/ResizableWndState.cpp | 12 +++-- 13 files changed, 97 insertions(+), 151 deletions(-) diff --git a/ResizableLib/ResizableComboBox.cpp b/ResizableLib/ResizableComboBox.cpp index 29501bc..19c5c59 100644 --- a/ResizableLib/ResizableComboBox.cpp +++ b/ResizableLib/ResizableComboBox.cpp @@ -113,11 +113,11 @@ void CResizableComboBox::InitHorizontalExtent() CString str; m_iExtent = 0; - int n = GetCount(); + const int n = GetCount(); for (int i=0; i m_iExtent) m_iExtent = cx; } @@ -133,7 +133,7 @@ void CResizableComboBox::UpdateHorizontalExtent(LPCTSTR szText) CClientDC dc(this); CFont* pOldFont = dc.SelectObject(GetFont()); - int cx = dc.GetTextExtent(szText, static_cast(_tcslen(szText))).cx; + const int cx = dc.GetTextExtent(szText, static_cast(_tcslen(szText))).cx; if (cx > m_iExtent) { m_iExtent = cx; @@ -160,23 +160,20 @@ void CResizableComboBox::PreSubclassWindow() int CResizableComboBox::MakeIntegralHeight(const int height) { - int inth = height; // integral height (result) - int availh = height; // available height - int n = GetCount(); - - DWORD dwStyle = GetStyle(); + const int n = GetCount(); - if (!m_bIntegralHeight || n == 0) - return inth; + if (!m_bIntegralHeight || n <= 0) + return height; - if (dwStyle & CBS_OWNERDRAWVARIABLE) + int availh = height; // available height + if (GetStyle() & CBS_OWNERDRAWVARIABLE) { - inth = 0; // try to reach availh by integral steps + int inth = 0; // try to reach availh by integral steps int i; // use items below the first visible for (i=GetTopIndex(); availh>0 && i0 && i>=0; i--) { - int h = GetItemHeight(i); + const int h = GetItemHeight(i); if (h == CB_ERR) break; @@ -199,29 +196,28 @@ int CResizableComboBox::MakeIntegralHeight(const int height) if (!m_bClipMaxHeight) // it can be higher than all the items { // to fill the remaining height, use last item - int h = GetItemHeight(n-1); - if (h != CB_ERR) - { + const int h = GetItemHeight(n-1); + if (h > 0) inth += availh - availh % h; - } } + + return inth; } - else + + // every item has the same height (take the first) + int h = GetItemHeight(0); + if (h > 0) { - // every item has the same height (take the first) - int h = GetItemHeight(0); - if (h != CB_ERR && n != CB_ERR) - { - int rows = availh / h; - // can't be higher than all the items - if (m_bClipMaxHeight && rows > n) - rows = n; - inth = rows * h; - // scroll into view - if (n - rows < GetTopIndex()) - SetTopIndex(n-rows); - } + int rows = availh / h; + // can't be higher than all the items + if (m_bClipMaxHeight && rows > n) + rows = n; + // scroll into view + if (n - rows < GetTopIndex()) + SetTopIndex(n-rows); + + return rows * h; } - return inth; -} + return height; +} \ No newline at end of file diff --git a/ResizableLib/ResizableFormView.cpp b/ResizableLib/ResizableFormView.cpp index e659b9e..3be9f67 100644 --- a/ResizableLib/ResizableFormView.cpp +++ b/ResizableLib/ResizableFormView.cpp @@ -83,7 +83,7 @@ void CResizableFormView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); - CWnd* pParent = GetParentFrame(); + const CWnd* pParent = GetParentFrame(); // hide size grip when parent is maximized if (pParent->IsZoomed()) @@ -92,7 +92,7 @@ void CResizableFormView::OnSize(UINT nType, int cx, int cy) ShowSizeGrip(&m_dwGripTempState, GHR_MAXIMIZED); // hide size grip when there are scrollbars - CSize size = GetTotalSize(); + const CSize size = GetTotalSize(); if ((cx < size.cx || cy < size.cy) && (m_nMapMode >= 0)) HideSizeGrip(&m_dwGripTempState, GHR_SCROLLBAR); else @@ -100,7 +100,6 @@ void CResizableFormView::OnSize(UINT nType, int cx, int cy) // hide size grip when the parent frame window is not resizable // or the form is not bottom-right aligned (e.g. there's a statusbar) - DWORD dwStyle = pParent->GetStyle(); CRect rect, rectChild; GetWindowRect(rect); @@ -116,7 +115,7 @@ void CResizableFormView::OnSize(UINT nType, int cx, int cy) break; } } - if ((dwStyle & WS_THICKFRAME) && bCanResize) + if ((pParent->GetStyle() & WS_THICKFRAME) && bCanResize) ShowSizeGrip(&m_dwGripTempState, GHR_ALIGNMENT); else HideSizeGrip(&m_dwGripTempState, GHR_ALIGNMENT); diff --git a/ResizableLib/ResizableLayout.cpp b/ResizableLib/ResizableLayout.cpp index 9a70b67..f861ea3 100644 --- a/ResizableLib/ResizableLayout.cpp +++ b/ResizableLib/ResizableLayout.cpp @@ -205,7 +205,7 @@ void CResizableLayout::ArrangeLayout() const // common vars UINT uFlags; CRect rectParent, rectChild; - INT_PTR count = m_listLayout.GetCount() + m_listLayoutCB.GetCount(); + const INT_PTR count = m_listLayout.GetCount() + m_listLayoutCB.GetCount(); if (count <= 0) return; @@ -293,7 +293,7 @@ void CResizableLayout::ClipChildWindow(const LAYOUTINFO& layout, } // get the clipping property - BOOL bClipping = layout.properties.bAskClipping ? + const BOOL bClipping = layout.properties.bAskClipping ? LikesClipping(layout) : layout.properties.bCachedLikesClipping; // modify region accordingly @@ -317,7 +317,7 @@ void CResizableLayout::ClipChildWindow(const LAYOUTINFO& layout, */ void CResizableLayout::GetClippingRegion(CRgn* pRegion) const { - CWnd* pWnd = GetResizableWnd(); + const CWnd* pWnd = GetResizableWnd(); // System's default clipping area is screen's size, // not enough for max track size, for example: @@ -334,26 +334,22 @@ void CResizableLayout::GetClippingRegion(CRgn* pRegion) const pRegion->CreateRectRgnIndirect(&rect); // clip only anchored controls - LAYOUTINFO layout; - POSITION pos = m_listLayout.GetHeadPosition(); - while (pos != NULL) + + for (POSITION pos = m_listLayout.GetHeadPosition(); pos != NULL;) { // get layout info - layout = m_listLayout.GetNext(pos); + LAYOUTINFO layout = m_listLayout.GetNext(pos); if (::IsWindowVisible(layout.hWnd)) ClipChildWindow(layout, pRegion); } - 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 data - if (!ArrangeLayoutCallback(layout)) - continue; - - if (::IsWindowVisible(layout.hWnd)) + if (ArrangeLayoutCallback(layout) && ::IsWindowVisible(layout.hWnd)) ClipChildWindow(layout, pRegion); } //! @todo Has XP changed this??? It doesn't seem correct anymore! @@ -405,8 +401,8 @@ BOOL CResizableLayout::ClipChildren(const CDC* pDC, BOOL bUndo) } #endif - HDC hDC = pDC->GetSafeHdc(); - HWND hWnd = GetResizableWnd()->GetSafeHwnd(); + const HDC hDC = pDC->GetSafeHdc(); + const HWND hWnd = GetResizableWnd()->GetSafeHwnd(); // Some controls (such as transparent toolbars and standard controls // with XP theme enabled) send a WM_ERASEBKGND msg to the parent @@ -490,8 +486,8 @@ BOOL CResizableLayout::NeedsRefresh(const LAYOUTINFO& layout, return refresh.bNeedsRefresh; } - int nDiffWidth = (rectNew.Width() - rectOld.Width()); - int nDiffHeight = (rectNew.Height() - rectOld.Height()); + const int nDiffWidth = (rectNew.Width() - rectOld.Width()); + const int nDiffHeight = (rectNew.Height() - rectOld.Height()); // is the same size? if (nDiffWidth == 0 && nDiffHeight == 0) @@ -543,9 +539,7 @@ BOOL CResizableLayout::NeedsRefresh(const LAYOUTINFO& layout, // window classes that don't redraw client area correctly // when the hor scroll pos changes due to a resizing - BOOL bHScroll = FALSE; - if (0 == lstrcmp(layout.sWndClass, WC_LISTBOX)) - bHScroll = TRUE; + const BOOL bHScroll = (0 == lstrcmp(layout.sWndClass, WC_LISTBOX)); // fix for horizontally scrollable windows, if wider if (bHScroll && (nDiffWidth > 0)) @@ -665,7 +659,7 @@ BOOL CResizableLayout::LikesClipping(const LAYOUTINFO& layout) const void CResizableLayout::CalcNewChildPosition(const LAYOUTINFO& layout, const CRect &rectParent, CRect &rectChild, UINT *lpFlags) const { - CWnd* pParent = GetResizableWnd(); + const CWnd* pParent = GetResizableWnd(); ::GetWindowRect(layout.hWnd, &rectChild); ::MapWindowPoints(NULL, pParent->m_hWnd, (LPPOINT)&rectChild, 2); diff --git a/ResizableLib/ResizableLib.vcxproj b/ResizableLib/ResizableLib.vcxproj index 4d31899..ba1a072 100644 --- a/ResizableLib/ResizableLib.vcxproj +++ b/ResizableLib/ResizableLib.vcxproj @@ -400,26 +400,8 @@ - - false - false - false - false - false - false - false - false - - - false - false - false - false - false - false - false - false - + + @@ -451,26 +433,8 @@ - - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - + + diff --git a/ResizableLib/ResizableMinMax.cpp b/ResizableLib/ResizableMinMax.cpp index 12ecfd5..9cbc33c 100644 --- a/ResizableLib/ResizableMinMax.cpp +++ b/ResizableLib/ResizableMinMax.cpp @@ -59,7 +59,7 @@ void CResizableMinMax::MinMaxInfo(LPMINMAXINFO lpMMI) const } } -void CResizableMinMax::ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentFrame, CWnd* pWnd) +void CResizableMinMax::ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentFrame, const CWnd* pWnd) { // get the extra size from child to parent CRect rectClient, rectWnd; @@ -69,12 +69,12 @@ void CResizableMinMax::ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentFrame, C pParentFrame->GetWindowRect(rectWnd); pParentFrame->RepositionBars(0, 0xFFFF, AFX_IDW_PANE_FIRST, CWnd::reposQuery, rectClient); - CSize sizeExtra = rectWnd.Size() - rectClient.Size(); + const CSize sizeExtra = rectWnd.Size() - rectClient.Size(); ChainMinMaxInfo(lpMMI, pWnd->GetSafeHwnd(), sizeExtra); } -void CResizableMinMax::ChainMinMaxInfo(LPMINMAXINFO lpMMI, HWND hWndChild, CSize sizeExtra) +void CResizableMinMax::ChainMinMaxInfo(LPMINMAXINFO lpMMI, HWND hWndChild, const CSize& sizeExtra) { // ask the child window for track size MINMAXINFO mmiChild = *lpMMI; @@ -106,7 +106,7 @@ void CResizableMinMax::ChainMinMaxInfo(LPMINMAXINFO lpMMI, HWND hWndChild, CSize } } -BOOL CResizableMinMax::CalcSizeExtra(HWND /*hWndChild*/, CSize /*sizeChild*/, CSize& /*sizeExtra*/) +BOOL CResizableMinMax::CalcSizeExtra(HWND /*hWndChild*/, const CSize& /*sizeChild*/, CSize& /*sizeExtra*/) { // should be overridden if you use ChainMinMaxInfoCB ASSERT(FALSE); diff --git a/ResizableLib/ResizableMinMax.h b/ResizableLib/ResizableMinMax.h index 8f7fe4f..75598d8 100644 --- a/ResizableLib/ResizableMinMax.h +++ b/ResizableLib/ResizableMinMax.h @@ -53,18 +53,18 @@ class CResizableMinMax protected: void MinMaxInfo(LPMINMAXINFO lpMMI) const; - static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentFrame, CWnd* pWnd); + static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentFrame, const CWnd* pWnd); - static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, HWND hWndChild, CSize sizeExtra); + static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, HWND hWndChild, const CSize& sizeExtra); - static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, CWnd* pParentWnd, UINT nID, CSize sizeExtra) + static void ChainMinMaxInfo(LPMINMAXINFO lpMMI, const CWnd* pParentWnd, UINT nID, const CSize& sizeExtra) { ChainMinMaxInfo(lpMMI, ::GetDlgItem(pParentWnd->GetSafeHwnd(), nID), sizeExtra); } void ChainMinMaxInfoCB(LPMINMAXINFO lpMMI, HWND hWndChild); - virtual BOOL CalcSizeExtra(HWND hWndChild, CSize sizeChild, CSize& sizeExtra); + virtual BOOL CalcSizeExtra(HWND hWndChild, const CSize& sizeChild, CSize& sizeExtra); void ResetAllRects(); diff --git a/ResizableLib/ResizableSheet.cpp b/ResizableLib/ResizableSheet.cpp index f5761a2..81489c6 100644 --- a/ResizableLib/ResizableSheet.cpp +++ b/ResizableLib/ResizableSheet.cpp @@ -323,7 +323,7 @@ BOOL CResizableSheet::OnEraseBkgnd(CDC* pDC) return bRet; } -BOOL CResizableSheet::CalcSizeExtra(HWND /*hWndChild*/, CSize sizeChild, CSize &sizeExtra) +BOOL CResizableSheet::CalcSizeExtra(HWND /*hWndChild*/, const CSize& sizeChild, CSize& sizeExtra) { CTabCtrl* pTab = GetTabControl(); if (!pTab) @@ -368,11 +368,10 @@ void CResizableSheet::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { MinMaxInfo(lpMMI); - CTabCtrl* pTab = GetTabControl(); - if (!pTab) + if (!GetTabControl()) return; - int nCount = GetPageCount(); + const int nCount = GetPageCount(); for (int idx = 0; idx < nCount; ++idx) { if (IsWizard()) // wizard mode @@ -402,7 +401,7 @@ int CResizableSheet::GetMinWidth() // search for leftmost and rightmost button margins for (int i = 0; i < 7; i++) { - CWnd* pWnd = GetDlgItem(_propButtons[i]); + const CWnd* pWnd = GetDlgItem(_propButtons[i]); // exclude not present or hidden buttons if (pWnd == NULL || !(pWnd->GetStyle() & WS_VISIBLE)) continue; @@ -411,8 +410,8 @@ int CResizableSheet::GetMinWidth() // of the parent window (negative value) pWnd->GetWindowRect(&rectWnd); ::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectWnd, 2); - int left = rectSheet.right - rectWnd.left; - int right = rectSheet.right - rectWnd.right; + const int left = rectSheet.right - rectWnd.left; + const int right = rectSheet.right - rectWnd.right; if (left > max) max = left; @@ -421,7 +420,7 @@ int CResizableSheet::GetMinWidth() } // sizing border width - int border = GetSystemMetrics(SM_CXSIZEFRAME); + const int border = GetSystemMetrics(SM_CXSIZEFRAME); // compute total width return max + min + 2*border; diff --git a/ResizableLib/ResizableSheet.h b/ResizableLib/ResizableSheet.h index 373b6d6..cba590b 100644 --- a/ResizableLib/ResizableSheet.h +++ b/ResizableLib/ResizableSheet.h @@ -101,7 +101,7 @@ class CResizableSheet : public CPropertySheet, public CResizableLayout, // Generated message map functions protected: - virtual BOOL CalcSizeExtra(HWND hWndChild, CSize sizeChild, CSize& sizeExtra); + virtual BOOL CalcSizeExtra(HWND hWndChild, const CSize& sizeChild, CSize& sizeExtra); virtual BOOL ArrangeLayoutCallback(LAYOUTINFO& layout) const; //{{AFX_MSG(CResizableSheet) afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); diff --git a/ResizableLib/ResizableSheetEx.cpp b/ResizableLib/ResizableSheetEx.cpp index 898e6a4..2f89738 100644 --- a/ResizableLib/ResizableSheetEx.cpp +++ b/ResizableLib/ResizableSheetEx.cpp @@ -112,7 +112,7 @@ BOOL CResizableSheetEx::OnNcCreate(LPCREATESTRUCT lpCreateStruct) BOOL CResizableSheetEx::OnInitDialog() { - BOOL bResult = CPropertySheetEx::OnInitDialog(); + const BOOL bResult = CPropertySheetEx::OnInitDialog(); // initialize layout PresetLayout(); @@ -410,7 +410,7 @@ BOOL CResizableSheetEx::OnEraseBkgnd(CDC* pDC) return bRet; } -BOOL CResizableSheetEx::CalcSizeExtra(HWND /*hWndChild*/, CSize sizeChild, CSize &sizeExtra) +BOOL CResizableSheetEx::CalcSizeExtra(HWND /*hWndChild*/, const CSize& sizeChild, CSize& sizeExtra) { CTabCtrl* pTab = GetTabControl(); if (!pTab) @@ -455,11 +455,10 @@ void CResizableSheetEx::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { MinMaxInfo(lpMMI); - CTabCtrl* pTab = GetTabControl(); - if (!pTab) + if (!GetTabControl()) return; - int nCount = GetPageCount(); + const int nCount = GetPageCount(); for (int idx = 0; idx < nCount; ++idx) { if (IsWizard()) // wizard mode @@ -501,7 +500,7 @@ void CResizableSheetEx::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) void CResizableSheetEx::GetHeaderRect(LPRECT lpRect) { - CWnd* pWizLineHdr = GetDlgItem(ID_WIZLINEHDR); + const CWnd* pWizLineHdr = GetDlgItem(ID_WIZLINEHDR); if (pWizLineHdr != NULL && pWizLineHdr->IsWindowVisible()) { pWizLineHdr->GetWindowRect(lpRect); @@ -523,7 +522,7 @@ int CResizableSheetEx::GetMinWidth() // search for leftmost and rightmost button margins for (int i = 0; i < 7; i++) { - CWnd* pWnd = GetDlgItem(_propButtons[i]); + const CWnd* pWnd = GetDlgItem(_propButtons[i]); // exclude not present or hidden buttons if (pWnd == NULL || !(pWnd->GetStyle() & WS_VISIBLE)) continue; @@ -532,8 +531,8 @@ int CResizableSheetEx::GetMinWidth() // of the parent window (negative value) pWnd->GetWindowRect(&rectWnd); ::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectWnd, 2); - int left = rectSheet.right - rectWnd.left; - int right = rectSheet.right - rectWnd.right; + const int left = rectSheet.right - rectWnd.left; + const int right = rectSheet.right - rectWnd.right; if (left > max) max = left; @@ -542,7 +541,7 @@ int CResizableSheetEx::GetMinWidth() } // sizing border width - int border = GetSystemMetrics(SM_CXSIZEFRAME); + const int border = GetSystemMetrics(SM_CXSIZEFRAME); // compute total width return max + min + 2*border; diff --git a/ResizableLib/ResizableSheetEx.h b/ResizableLib/ResizableSheetEx.h index 5716403..84dcd67 100644 --- a/ResizableLib/ResizableSheetEx.h +++ b/ResizableLib/ResizableSheetEx.h @@ -109,7 +109,7 @@ class CResizableSheetEx : public CPropertySheetEx, public CResizableLayout, // Generated message map functions protected: void GetHeaderRect(LPRECT lpRect); - virtual BOOL CalcSizeExtra(HWND hWndChild, CSize sizeChild, CSize& sizeExtra); + virtual BOOL CalcSizeExtra(HWND hWndChild, const CSize& sizeChild, CSize& sizeExtra); virtual BOOL ArrangeLayoutCallback(LAYOUTINFO& layout) const; //{{AFX_MSG(CResizableSheetEx) afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); diff --git a/ResizableLib/ResizableSheetState.cpp b/ResizableLib/ResizableSheetState.cpp index 49b9ef3..21736e7 100644 --- a/ResizableLib/ResizableSheetState.cpp +++ b/ResizableLib/ResizableSheetState.cpp @@ -55,21 +55,21 @@ BOOL CResizableSheetState::SavePage(LPCTSTR pszName) // saves active page index, or the initial page if problems // cannot use GetActivePage, because it always fails - CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, GetResizableWnd()); + const CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, GetResizableWnd()); if (pSheet == NULL) return FALSE; int page = pSheet->m_psh.nStartPage; - CTabCtrl *pTab = pSheet->GetTabControl(); + const CTabCtrl *pTab = pSheet->GetTabControl(); if (pTab != NULL) page = pTab->GetCurSel(); if (page < 0) page = pSheet->m_psh.nStartPage; CString data; - _itot_s(page, data.GetBuffer(10), 10, 10); - CString id = CString(pszName) + ACTIVEPAGE_ENT; - return WriteState(id, data); + data.Format(_T("%i"), page); + + return WriteState(CString(pszName) + ACTIVEPAGE_ENT, data); } /*! @@ -84,14 +84,11 @@ BOOL CResizableSheetState::LoadPage(LPCTSTR pszName) { // restore active page, zero (the first) if not found - CString data, id; - id = CString(pszName) + ACTIVEPAGE_ENT; - if (!ReadState(id, data)) + CString data; + if (!ReadState(CString(pszName) + ACTIVEPAGE_ENT, data)) return FALSE; - int page = _ttoi(data); CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, GetResizableWnd()); - if (pSheet != NULL) - return pSheet->SetActivePage(page); - return FALSE; + + return (pSheet != NULL) && pSheet->SetActivePage(_ttoi(data)); } diff --git a/ResizableLib/ResizableSplitterWnd.cpp b/ResizableLib/ResizableSplitterWnd.cpp index 0674023..3341d30 100644 --- a/ResizableLib/ResizableSplitterWnd.cpp +++ b/ResizableLib/ResizableSplitterWnd.cpp @@ -51,14 +51,14 @@ void CResizableSplitterWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) if ((GetStyle() & SPLS_DYNAMIC_SPLIT) && GetRowCount() == 1 && GetColumnCount() == 1) { - CWnd* pPane = GetActivePane(); + const CWnd* pPane = GetActivePane(); if (pPane != NULL) { // get the extra size from child to parent CRect rectClient, rectWnd; GetWindowRect(rectWnd); pPane->GetWindowRect(rectClient); - CSize sizeExtra = rectWnd.Size() - rectClient.Size(); + const CSize sizeExtra = rectWnd.Size() - rectClient.Size(); ChainMinMaxInfo(lpMMI, pPane->m_hWnd, sizeExtra); } @@ -75,7 +75,7 @@ void CResizableSplitterWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) int max = LONG_MAX; for (int row = 0; row < m_nRows; ++row) { - CWnd* pWnd = GetPane(row, col); + const CWnd* pWnd = GetPane(row, col); // ask the child window for track size MINMAXINFO mmiChild = *lpMMI; mmiChild.ptMinTrackSize.x = 0; @@ -98,7 +98,7 @@ void CResizableSplitterWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) int max = LONG_MAX; for (int col = 0; col < m_nCols; ++col) { - CWnd* pWnd = GetPane(row, col); + const CWnd* pWnd = GetPane(row, col); // ask the child window for track size MINMAXINFO mmiChild = *lpMMI; mmiChild.ptMinTrackSize.y = 0; diff --git a/ResizableLib/ResizableWndState.cpp b/ResizableLib/ResizableWndState.cpp index 404dd3c..2f26b91 100644 --- a/ResizableLib/ResizableWndState.cpp +++ b/ResizableLib/ResizableWndState.cpp @@ -57,15 +57,15 @@ CResizableWndState::~CResizableWndState() */ BOOL CResizableWndState::SaveWindowRect(LPCTSTR pszName, BOOL bRectOnly) { - CString data, id; WINDOWPLACEMENT wp = {sizeof(WINDOWPLACEMENT)}; if (!GetResizableWnd()->GetWindowPlacement(&wp)) return FALSE; // use workspace coordinates - RECT& rc = wp.rcNormalPosition; + const RECT& rc = wp.rcNormalPosition; + CString data; if (bRectOnly) // save size/pos only (normal state) { data.Format(PLACEMENT_FMT, rc.left, rc.top, @@ -78,8 +78,7 @@ BOOL CResizableWndState::SaveWindowRect(LPCTSTR pszName, BOOL bRectOnly) wp.ptMinPosition.x, wp.ptMinPosition.y); } - id = CString(pszName) + PLACEMENT_ENT; - return WriteState(id, data); + return WriteState(CString(pszName) + PLACEMENT_ENT, data); } /*! @@ -97,11 +96,10 @@ BOOL CResizableWndState::SaveWindowRect(LPCTSTR pszName, BOOL bRectOnly) */ BOOL CResizableWndState::LoadWindowRect(LPCTSTR pszName, BOOL bRectOnly) { - CString data, id; + CString data; WINDOWPLACEMENT wp = {sizeof(WINDOWPLACEMENT)}; - id = CString(pszName) + PLACEMENT_ENT; - if (!ReadState(id, data)) // never saved before + if (!ReadState(CString(pszName) + PLACEMENT_ENT, data)) // never saved before return FALSE; if (!GetResizableWnd()->GetWindowPlacement(&wp))