OSDN Git Service

PATCH: [ 1208208 ] Move resizeable dialogs position in registry
authorPerry Rapp <elsapo@users.sourceforge.net>
Tue, 26 Jul 2005 14:50:10 +0000 (14:50 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Tue, 26 Jul 2005 14:50:10 +0000 (14:50 +0000)
  Src: OpenDlg.cpp SaveClosingDlg.cpp
  Src/Common: CMoveConstraint.cpp CMoveConstraint.h

Src/Common/CMoveConstraint.cpp
Src/Common/CMoveConstraint.h
Src/OpenDlg.cpp
Src/SaveClosingDlg.cpp
Src/readme.txt

index 4e93a5d..8420e22 100644 (file)
@@ -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);
index 3545d99..3d23fec 100644 (file)
@@ -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<UINT, UINT, tip, tip&> m_tips;
 };
index ca8e358..571576a 100644 (file)
@@ -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();
 
index e77886f..58c7045 100644 (file)
@@ -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
index 938610b..60cd33f 100644 (file)
@@ -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