From 8f4c90ed5dc27eb4351b8e92843f3c7ecf7c5e12 Mon Sep 17 00:00:00 2001 From: Perry Rapp Date: Tue, 26 Jul 2005 14:50:10 +0000 Subject: [PATCH] PATCH: [ 1208208 ] Move resizeable dialogs position in registry Src: OpenDlg.cpp SaveClosingDlg.cpp Src/Common: CMoveConstraint.cpp CMoveConstraint.h --- Src/Common/CMoveConstraint.cpp | 27 ++++++++++++++++++++------- Src/Common/CMoveConstraint.h | 9 ++++++--- Src/OpenDlg.cpp | 2 +- Src/SaveClosingDlg.cpp | 2 +- Src/readme.txt | 4 ++++ 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Src/Common/CMoveConstraint.cpp b/Src/Common/CMoveConstraint.cpp index 4e93a5de5..8420e2263 100644 --- a/Src/Common/CMoveConstraint.cpp +++ b/Src/Common/CMoveConstraint.cpp @@ -2,7 +2,7 @@ \file CMoveConstraint.cpp \author Perry Rapp, Creator, 1998-2004 \date Created: 1998 - \date Edited: 2004/04/22 Perry Rapp + \date Edited: 2005-07-26 (Perry Rapp) \brief Implementation of CMoveConstraint @@ -90,7 +90,8 @@ CMoveConstraint::Constraint::Init() CMoveConstraint::CMoveConstraint() { m_bSubclassed = false; - m_sKey = _T("UnnamedWindow"); + m_sRegistryValueName = _T("UnnamedWindow"); + m_sRegistrySubkey = _T("LastWindowPos"); ClearMostData(); } @@ -698,11 +699,23 @@ CMoveConstraint::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, L return false; } +/** + * Save size (& optionally position) in registry + */ +void +CMoveConstraint::LoadPosition(LPCTSTR szKeyName, LPCTSTR szValueName, bool position) +{ + m_sRegistrySubkey = szKeyName; + LoadPosition(szValueName, position); +} +/** + * Save size (& optionally position) in registry + */ void -CMoveConstraint::LoadPosition(LPCTSTR szName, bool position) +CMoveConstraint::LoadPosition(LPCTSTR szValueName, bool position) { - m_sKey = szName; + m_sRegistryValueName = szValueName; m_bPersistent=true; Persist(false, position); } @@ -710,7 +723,7 @@ CMoveConstraint::LoadPosition(LPCTSTR szName, bool position) void CMoveConstraint::Persist(bool saving, bool position) { - LPCTSTR szSection = _T("LastWindowPos"); + LPCTSTR szSection = m_sRegistrySubkey; WINDOWPLACEMENT wp; wp.length=sizeof(wp); if (saving) @@ -719,11 +732,11 @@ CMoveConstraint::Persist(bool saving, bool position) GetWindowPlacement(m_hwndDlg, &wp); RECT & rc = wp.rcNormalPosition; str.Format(_T("%d,%d,%d,%d"), rc.left, rc.top, rc.right, rc.bottom); - AfxGetApp()->WriteProfileString(szSection, m_sKey, str); + AfxGetApp()->WriteProfileString(szSection, m_sRegistryValueName, str); } else { - CString str = AfxGetApp()->GetProfileString(szSection, m_sKey); + CString str = AfxGetApp()->GetProfileString(szSection, m_sRegistryValueName); GetWindowPlacement(m_hwndDlg, &wp); CRect rc; int ct=_stscanf(str, _T("%d,%d,%d,%d"), &rc.left, &rc.top, &rc.right, &rc.bottom); diff --git a/Src/Common/CMoveConstraint.h b/Src/Common/CMoveConstraint.h index 3545d99e1..3d23fecb5 100644 --- a/Src/Common/CMoveConstraint.h +++ b/Src/Common/CMoveConstraint.h @@ -2,7 +2,7 @@ \file CMoveConstraint.h \author Perry Rapp, Creator, 1998-2004 \date Created: 1998 - \date Edited: 2004/04/22 PR + \date Edited: 2005-07-26 (Perry Rapp) \brief Declaration of CMoveConstraint @@ -150,7 +150,9 @@ public: bool UnSubclassWnd(); // call after all constraints established - void LoadPosition(LPCTSTR szName, bool position); // always loads size, may also set position + // always loads size, may also set position + void LoadPosition(LPCTSTR szKeyName, LPCTSTR szValueName, bool position); + void LoadPosition(LPCTSTR szValueName, bool position); // for use when children hadn't been created yet at initialization time // so their constraints had to be buffered to be initialized later @@ -248,7 +250,8 @@ private: ConstraintList m_ConstraintList; bool m_bConstrainNonChildren; bool m_bPersistent; // whether to save position to registry - CString m_sKey; + CString m_sRegistrySubkey; // defaults to _T("LastWindowPos") + CString m_sRegistryValueName; // should be name of window // tooltips CMap m_tips; }; diff --git a/Src/OpenDlg.cpp b/Src/OpenDlg.cpp index ca8e35803..571576ad1 100644 --- a/Src/OpenDlg.cpp +++ b/Src/OpenDlg.cpp @@ -282,7 +282,7 @@ BOOL COpenDlg::OnInitDialog() m_constraint.ConstrainItem(IDCANCEL, 1, 0, 0, 0); // slides right m_constraint.DisallowHeightGrowth(); m_constraint.SubclassWnd(); // install subclassing - m_constraint.LoadPosition(_T("OpenDlg"), false); // persist size via registry + m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("OpenDlg"), false); // persist size via registry CenterToMainFrame(); diff --git a/Src/SaveClosingDlg.cpp b/Src/SaveClosingDlg.cpp index e77886f51..58c704553 100644 --- a/Src/SaveClosingDlg.cpp +++ b/Src/SaveClosingDlg.cpp @@ -115,7 +115,7 @@ BOOL SaveClosingDlg::OnInitDialog() m_constraint.ConstrainItem(IDCANCEL, 1, 0, 0, 0); // slides right m_constraint.DisallowHeightGrowth(); m_constraint.SubclassWnd(); // install subclassing - m_constraint.LoadPosition(_T("SaveClosingDlg"), false); // persist size via registry + m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("SaveClosingDlg"), false); // persist size via registry return FALSE; // return TRUE unless you set the focus to a control diff --git a/Src/readme.txt b/Src/readme.txt index 938610bde..60cd33fb4 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -2,6 +2,10 @@ PATCH: [ 1242008 ] Update status to binary if open fails because binary Src: DiffItem.h DiffItemList.cpp DiffItemList.h DirDoc.h DirView.cpp MainFrm.cpp MainFrm.h MergeDoc.cpp MergeDoc.h + PATCH: [ 1208208 ] Move resizeable dialogs position in registry + Src: OpenDlg.cpp SaveClosingDlg.cpp + Src/Common: CMoveConstraint.cpp CMoveConstraint.h + 2005-07-26 Kimmo PATCH: [ 1244804 ] Add hourglass for report creating -- 2.11.0