WpRestoreString: Difference between revisions
Appearance
Created page with "{{DISPLAYTITLE:wpRestoreString}} This instance method is called to allow the object to restore an ASCIIZ instance data string. ==Syntax== _wpRestoreString(somSelf, pszClass, ulKey, pszValue, pcbValue) ==Parameters== ;''somSelf'' (WPObject *) - input :Pointer to the object on which the method is being invoked. :Points to an object of class WPObject. ;''pszClass'' (PSZ) - input :Pointer to the class name. :A pointer to a zero-terminated string that contains..." |
|||
| Line 100: | Line 100: | ||
* [[wpRestoreLong]] | * [[wpRestoreLong]] | ||
* [[wpRestoreState]] | * [[wpRestoreState]] | ||
* [[wpSaveData]] | * [[wpSaveData]] | ||
* [[wpSaveDeferred]] | * [[wpSaveDeferred]] | ||
Latest revision as of 00:05, 3 September 2025
This instance method is called to allow the object to restore an ASCIIZ instance data string.
Syntax
_wpRestoreString(somSelf, pszClass, ulKey, pszValue, pcbValue)
Parameters
- somSelf (WPObject *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPObject.
- pszClass (PSZ) - input
- Pointer to the class name.
- A pointer to a zero-terminated string that contains any unique string. The class name is recommended but not enforced.
- ulKey (ULONG) - input
- Class-defined identifier.
- A class-defined identifier that correlates to a particular instance data variable.
- pszValue (PSZ) - in/out
- Address of the string to be restored.
- pcbValue (PULONG) - in/out
- Size of string to be restored.
- If pszValue is NULL, the actual size is returned in pcbValue.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE: Successful completion.
- FALSE: Error occurred.
Remarks
This method restores an ASCIIZ string that was saved by a call to wpSaveString.
Usage
This method can be called only during the processing of the wpRestoreState method.
How to Override
This method is generally not overridden.
Example Code
Declaration:
#define INCL_WINWORKPLACE #include <os2.h> WPObject somSelf; / Pointer to the object on which the method is being invoked. / PSZ pszClass; / Pointer to the class name. / ULONG ulKey; / Class-defined identifier. / PSZ pszValue; / Address of the string to be restored. / PULONG pcbValue; / Size of string to be restored. / BOOL rc; / Success indicator. */ rc = _wpRestoreString(somSelf, pszClass, ulKey, pszValue, pcbValue);
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));
}