1 /////////////////////////////////////////////////////////////////////////////
3 // This file is part of ResizableLib
4 // http://sourceforge.net/projects/resizablelib
6 // Copyright (C) 2000-2004 by Paolo Messina
7 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
9 // The contents of this file are subject to the Artistic License (the "License").
10 // You may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at:
12 // http://www.opensource.org/licenses/artistic-license.html
14 // If you find this code useful, credits would be nice!
16 /////////////////////////////////////////////////////////////////////////////
20 * @brief Implementation of the CResizableSheetState class.
24 #include "ResizableSheetState.h"
26 //////////////////////////////////////////////////////////////////////
27 // Construction/Destruction
28 //////////////////////////////////////////////////////////////////////
30 CResizableSheetState::CResizableSheetState()
35 CResizableSheetState::~CResizableSheetState()
40 // used to save/restore active page
41 // either in the registry or a private .INI file
42 // depending on your application settings
44 #define ACTIVEPAGE_ENT _T("ActivePage")
47 * This function saves the current property sheet active page using the base
48 * class persist method.
49 * @sa CResizableState::WriteState
51 * @param pszName String that identifies stored settings
53 * @return Returns @a TRUE if successful, @a FALSE otherwise
55 BOOL
CResizableSheetState::SavePage(LPCTSTR pszName
)
57 // saves active page index, or the initial page if problems
58 // cannot use GetActivePage, because it always fails
60 CPropertySheet
* pSheet
= DYNAMIC_DOWNCAST(CPropertySheet
, GetResizableWnd());
64 int page
= pSheet
->m_psh
.nStartPage
;
65 CTabCtrl
*pTab
= pSheet
->GetTabControl();
67 page
= pTab
->GetCurSel();
69 page
= pSheet
->m_psh
.nStartPage
;
72 _itot(page
, data
.GetBuffer(10), 10);
73 id
= CString(pszName
) + ACTIVEPAGE_ENT
;
74 return WriteState(id
, data
);
78 * This function loads the active page using the base class persist method.
79 * @sa CResizableState::ReadState
81 * @param pszName String that identifies stored settings
83 * @return Returns @a TRUE if successful, @a FALSE otherwise
85 BOOL
CResizableSheetState::LoadPage(LPCTSTR pszName
)
87 // restore active page, zero (the first) if not found
90 id
= CString(pszName
) + ACTIVEPAGE_ENT
;
91 if (!ReadState(id
, data
))
94 int page
= _ttoi(data
);
95 CPropertySheet
* pSheet
= DYNAMIC_DOWNCAST(CPropertySheet
, GetResizableWnd());
97 return pSheet
->SetActivePage(page
);