wpSaveState
This instance method is called to allow the object to save its state.
Syntax
_wpSaveState(somSelf)
Parameters
- somSelf (WPObject *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPObject.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE: Successful completion.
- FALSE: Error occurred.
Remarks
The saved state of the object is restored during the processing of the wpRestoreState method.
Usage
This method is generally called by the system while it is processing either the wpClose or wpSaveImmediate methods. If an immediate save is required, the wpSaveImmediate method can be called, but it is not recommended. wpSaveDeferred should be used.
How to Override
This method should be overridden by all classes that provide savable settings. An override of the wpRestoreState method is a prerequisite. Override processing of this method typically includes a series of calls to any combination of the save state methods:
Example Code
In this example, wpSaveState is overridden to save instance data from the OS2.INI file.
#define WPNBK_KEY 1 /* Instance method to return title information */ SOM_Scope PSZ SOMLINK UserGetTitle(nbk *somSelf) { nbkData *somThis = nbkGetData(somSelf); nbkMethodDebug("nbk","UserGetTitle"); return (PSZ) _title; } /* Override of wpSaveState to save our instance data in OS2.INI */ SOM_Scope BOOL SOMLINK wpSaveState(nbk *somSelf) { PSZ psz; nbkData *somThis = nbkGetData(somSelf); nbkMethodDebug("nbk","wpSaveState"); psz = _UserGetTitle ( somSelf ); /* Get data to be saved */ /* Save our data to the OS2.INI file */ _wpSaveData ( somSelf /* Pointer to us */ , "nbk" /* Class name */ , WPNBK_KEY /* Key for data */ , psz /* Pointer to data */ , 40 ); /* Length of data */ return (parent_wpSaveState(somSelf)); /* Let parent store data */ }