Fix wrong contextmenu icon display position when install TSVN 1.7 at XP
[TortoiseGit.git] / ext / ResizableLib / ResizableSheetState.cpp
blobf9f28e0b1d5aae1b1731fb26eb418c643e512490
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // This file is part of ResizableLib
4 // http://sourceforge.net/projects/resizablelib
5 //
6 // Copyright (C) 2000-2004 by Paolo Messina
7 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
8 //
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 /////////////////////////////////////////////////////////////////////////////
18 /*!
19 * @file
20 * @brief Implementation of the CResizableSheetState class.
23 #include "stdafx.h"
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")
46 /*!
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());
61 if (pSheet == NULL)
62 return FALSE;
64 int page = pSheet->m_psh.nStartPage;
65 CTabCtrl *pTab = pSheet->GetTabControl();
66 if (pTab != NULL)
67 page = pTab->GetCurSel();
68 if (page < 0)
69 page = pSheet->m_psh.nStartPage;
71 CString data, id;
72 _itot(page, data.GetBuffer(10), 10);
73 id = CString(pszName) + ACTIVEPAGE_ENT;
74 return WriteState(id, data);
77 /*!
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
89 CString data, id;
90 id = CString(pszName) + ACTIVEPAGE_ENT;
91 if (!ReadState(id, data))
92 return FALSE;
94 int page = _ttoi(data);
95 CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, GetResizableWnd());
96 if (pSheet != NULL)
97 return pSheet->SetActivePage(page);
98 return FALSE;