wpSaveData - 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 */
}


[Back: wpSaveData - Related Methods]
[Next: wpSaveData - Topics]