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 CResizableState class.
24 #include "ResizableState.h"
28 static char THIS_FILE
[]=__FILE__
;
32 //////////////////////////////////////////////////////////////////////
33 // Construction/Destruction
34 //////////////////////////////////////////////////////////////////////
36 CResizableState::CResizableState()
38 m_sStorePath
= m_sDefaultStorePath
;
41 CResizableState::~CResizableState()
46 // static intializer must be called before user code
47 #pragma warning(disable:4073)
49 CString
CResizableState::m_sDefaultStorePath(_T("ResizableState"));
52 * Static function to set the default path used to store state information.
53 * This path is used to initialize all the instances of this class.
54 * @sa GetDefaultStateStore GetStateStore SetStateStore
56 * @param szPath String that specifies the new path to be set
58 void CResizableState::SetDefaultStateStore(LPCTSTR szPath
)
60 m_sDefaultStorePath
= szPath
;
64 * Static function to retrieve the default path used to store state
66 * This path is used to initialize all the instances of this class.
67 * @sa SetDefaultStateStore GetStateStore SetStateStore
69 * @return The return value is a string that specifies the current path
71 LPCTSTR
CResizableState::GetDefaultStateStore()
73 return m_sDefaultStorePath
;
77 * This function sets the path used to store state information by
78 * the current instance of the class.
79 * @sa GetStateStore GetDefaultStateStore SetDefaultStateStore
81 * @param szPath String that specifies the new path to be set
83 void CResizableState::SetStateStore(LPCTSTR szPath
)
85 m_sStorePath
= szPath
;
89 * This function retrieves the path used to store state information by
90 * the current instance of the class.
91 * @sa SetStateStore GetDefaultStateStore SetDefaultStateStore
93 * @return The return value is a string that specifies the current path
95 LPCTSTR
CResizableState::GetStateStore()
101 * This function writes state information and associates it with some
102 * identification text for later retrieval.
103 * The base implementation uses the application profile to persist state
104 * information, but this function can be overridden to implement
107 * @param szId String that identifies the stored settings
108 * @param szState String that represents the state information to store
110 * @return The return value is @a TRUE if settings have been successfully
111 * stored, @a FALSE otherwise.
113 BOOL
CResizableState::WriteState(LPCTSTR szId
, LPCTSTR szState
)
115 return AfxGetApp()->WriteProfileString(GetStateStore(), szId
, szState
);
119 * This function reads state information previously associated with some
120 * identification text.
121 * The base implementation uses the application profile to persist state
122 * information, but this function can be overridden to implement
125 * @param szId String that identifies the stored settings
126 * @param rsState String to be filled with the retrieved state information
128 * @return The return value is @a TRUE if settings have been successfully
129 * retrieved, @a FALSE otherwise.
131 BOOL
CResizableState::ReadState(LPCTSTR szId
, CString
&rsState
)
133 rsState
= AfxGetApp()->GetProfileString(GetStateStore(), szId
);
134 return !rsState
.IsEmpty();