This example demonstrates an override of wpRestoreState method to save string data.
SOM_Scope BOOL SOMLINK wpRestoreState(nbk *somSelf,
ULONG ulReserved)
{
BOOL fSuccess; /* Success flag */
ULONG ulCount; /* Length of title string */
UCHAR uchName[40]; /* Buffer for title */
nbkData *somThis = nbkGetData(somSelf);
nbkMethodDebug("nbk","wpRestoreState");
ulCount = 40L; /* Size of input buffer */
fSuccess = _wpRestoreString ( somSelf /* Self pointer */
, (PSZ) "nbk" /* Class name */
, WPNBK_KEY /* Key for data */
, &uchName /* String to receive data */
, &ulCount ); /* Amount of data returned */
if ( !fSuccess ) { /* First time object is being restored */
// initialize string to NULL
strcpy ( uchName, "" );
// save initial string to ini file
_wpSaveString ( somSelf /* Self pointer */
, (PSZ) "nbk" /* Class name */
, WPNBK_KEY /* Key of data */
, uchName ); /* String to write */
}
_UserSetTitle ( somSelf, uchName ); /* Set an instance variable */
return (parent_wpRestoreState(somSelf,ulReserved));
}