-
Notifications
You must be signed in to change notification settings - Fork 1
/
ResizableSheetState.cpp
99 lines (83 loc) · 2.71 KB
/
ResizableSheetState.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/////////////////////////////////////////////////////////////////////////////
//
// This file is part of ResizableLib
// http://sourceforge.net/projects/resizablelib
//
// Copyright (C) 2000-2004 by Paolo Messina
// http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
//
// The contents of this file are subject to the Artistic License (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// http://www.opensource.org/licenses/artistic-license.html
//
// If you find this code useful, credits would be nice!
//
/////////////////////////////////////////////////////////////////////////////
/*!
* @file
* @brief Implementation of the CResizableSheetState class.
*/
#include "stdafx.h"
#include "ResizableSheetState.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CResizableSheetState::CResizableSheetState()
{
}
CResizableSheetState::~CResizableSheetState()
{
}
// used to save/restore active page
// either in the registry or a private .INI file
// depending on your application settings
#define ACTIVEPAGE_ENT _T("ActivePage")
/*!
* This function saves the current property sheet active page using the base
* class persist method.
* @sa CResizableState::WriteState
*
* @param pszName String that identifies stored settings
*
* @return Returns @a TRUE if successful, @a FALSE otherwise
*/
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());
if (pSheet == NULL)
return FALSE;
int page = pSheet->m_psh.nStartPage;
CTabCtrl *pTab = pSheet->GetTabControl();
if (pTab != NULL)
page = pTab->GetCurSel();
if (page < 0)
page = pSheet->m_psh.nStartPage;
CString data, id;
_itot(page, data.GetBuffer(10), 10);
id = CString(pszName) + ACTIVEPAGE_ENT;
return WriteState(id, data);
}
/*!
* This function loads the active page using the base class persist method.
* @sa CResizableState::ReadState
*
* @param pszName String that identifies stored settings
*
* @return Returns @a TRUE if successful, @a FALSE otherwise
*/
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))
return FALSE;
int page = _ttoi(data);
CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, GetResizableWnd());
if (pSheet != NULL)
return pSheet->SetActivePage(page);
return FALSE;
}