1 /////////////////////////////////////////////////////////////////////////////
\r
3 // This file is part of ResizableLib
\r
4 // http://sourceforge.net/projects/resizablelib
\r
6 // Copyright (C) 2000-2004 by Paolo Messina
\r
7 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
\r
9 // The contents of this file are subject to the Artistic License (the "License").
\r
10 // You may not use this file except in compliance with the License.
\r
11 // You may obtain a copy of the License at:
\r
12 // http://www.opensource.org/licenses/artistic-license.html
\r
14 // If you find this code useful, credits would be nice!
\r
16 /////////////////////////////////////////////////////////////////////////////
\r
20 * @brief Implementation of the CResizableState class.
\r
24 #include "ResizableState.h"
\r
28 static char THIS_FILE[]=__FILE__;
\r
29 #define new DEBUG_NEW
\r
32 //////////////////////////////////////////////////////////////////////
\r
33 // Construction/Destruction
\r
34 //////////////////////////////////////////////////////////////////////
\r
36 CResizableState::CResizableState()
\r
38 m_sStorePath = m_sDefaultStorePath;
\r
41 CResizableState::~CResizableState()
\r
46 // static intializer must be called before user code
\r
47 #pragma warning(disable:4073)
\r
48 #pragma init_seg(lib)
\r
49 CString CResizableState::m_sDefaultStorePath(_T("ResizableState"));
\r
52 * Static function to set the default path used to store state information.
\r
53 * This path is used to initialize all the instances of this class.
\r
54 * @sa GetDefaultStateStore GetStateStore SetStateStore
\r
56 * @param szPath String that specifies the new path to be set
\r
58 void CResizableState::SetDefaultStateStore(LPCTSTR szPath)
\r
60 m_sDefaultStorePath = szPath;
\r
64 * Static function to retrieve the default path used to store state
\r
66 * This path is used to initialize all the instances of this class.
\r
67 * @sa SetDefaultStateStore GetStateStore SetStateStore
\r
69 * @return The return value is a string that specifies the current path
\r
71 LPCTSTR CResizableState::GetDefaultStateStore()
\r
73 return m_sDefaultStorePath;
\r
77 * This function sets the path used to store state information by
\r
78 * the current instance of the class.
\r
79 * @sa GetStateStore GetDefaultStateStore SetDefaultStateStore
\r
81 * @param szPath String that specifies the new path to be set
\r
83 void CResizableState::SetStateStore(LPCTSTR szPath)
\r
85 m_sStorePath = szPath;
\r
89 * This function retrieves the path used to store state information by
\r
90 * the current instance of the class.
\r
91 * @sa SetStateStore GetDefaultStateStore SetDefaultStateStore
\r
93 * @return The return value is a string that specifies the current path
\r
95 LPCTSTR CResizableState::GetStateStore()
\r
97 return m_sStorePath;
\r
101 * This function writes state information and associates it with some
\r
102 * identification text for later retrieval.
\r
103 * The base implementation uses the application profile to persist state
\r
104 * information, but this function can be overridden to implement
\r
105 * different methods.
\r
107 * @param szId String that identifies the stored settings
\r
108 * @param szState String that represents the state information to store
\r
110 * @return The return value is @a TRUE if settings have been successfully
\r
111 * stored, @a FALSE otherwise.
\r
113 BOOL CResizableState::WriteState(LPCTSTR szId, LPCTSTR szState)
\r
115 return AfxGetApp()->WriteProfileString(GetStateStore(), szId, szState);
\r
119 * This function reads state information previously associated with some
\r
120 * identification text.
\r
121 * The base implementation uses the application profile to persist state
\r
122 * information, but this function can be overridden to implement
\r
123 * different methods.
\r
125 * @param szId String that identifies the stored settings
\r
126 * @param rsState String to be filled with the retrieved state information
\r
128 * @return The return value is @a TRUE if settings have been successfully
\r
129 * retrieved, @a FALSE otherwise.
\r
131 BOOL CResizableState::ReadState(LPCTSTR szId, CString &rsState)
\r
133 rsState = AfxGetApp()->GetProfileString(GetStateStore(), szId);
\r
134 return !rsState.IsEmpty();
\r