wpRestoreState
This method restores the state of the object which was saved during the processing of the wpSaveState method.
Syntax
_wpRestoreState(somSelf, ulReserved);
Parameters
- somSelf (WPObject *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPObject.
- ulReserved (ULONG) - input
- Reserved value; must be 0.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE: Successful completion.
- FALSE: Error occurred.
Remarks
This method restores the state of the object that was saved during the processing of the wpSaveState method.
Usage
This method is generally called only by the system while it is processing the wpInitData method.
How to Override
This method should be overridden by all classes that provide settings that can be saved. An override of the wpSaveState method is a prerequisite if persistent instance data is desired. Override processing of this method typically includes a series of calls to any combination of the restore state methods: wpRestoreData, wpRestoreLong, wpRestoreString.
Example Code
Declaration:
#define INCL_WINWORKPLACE #include <os2.h> WPObject somSelf; / Pointer to the object on which the method is being invoked. / ULONG ulReserved; / Reserved value; must be 0. / BOOL rc; / Success indicator. */ rc = _wpRestoreState(somSelf, ulReserved);
In this example, wpRestoreState is overridden to restore data from the OS2.INI file.
SOM_Scope void SOMLINK UserSetTitle(nbk *somSelf, PSZ pszNewTitle) { nbkData *somThis = nbkGetData(somSelf); nbkMethodDebug("nbk","UserSetTitle"); strcpy ( _title, pszNewTitle ); } /* Override of wpRestoreState method to restore our data from the OS2.INI file. */ SOM_Scope BOOL SOMLINK wpRestoreState(nbk *somSelf, ULONG ulReserved) { BOOL fSuccess; ULONG ulCount; CHAR buf[40]; nbkData *somThis = nbkGetData(somSelf); nbkMethodDebug("nbk","wpRestoreState"); ulCount = 40; /* Length of data buffer / fSuccess = _wpRestoreData ( somSelf / Our pointer / , (PSZ) "nbk" / Name of class / , WPNBK_KEY / Key of data requested / , (PBYTE) &buf / Where to put data / , &ulCount ); / Length of data returned */ if ( !fSuccess ) { /* first time the object is being restored */ /* initialize string to NULL */ strcpy ( buf, "" ); /* Save initial string to OS2.INI file */ _wpSaveData ( somSelf /* Pointer to ourself */ , (PSZ) "nbk" /* Class name */ , WPNBK_KEY /* Key of data */ , (PBYTE) buf /* Pointer to data */ , 40 ); /* Length of data to write */ } /* endif */ _UserSetTitle ( somSelf, buf ); return (parent_wpRestoreState(somSelf,ulReserved)); }