wpSaveImmediate
Appearance
This instance method is called to save the current state of an object synchronously.
Syntax
_wpSaveImmediate(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
This method is called automatically for all objects that are flagged as needing to save their data by wpSaveDeferred; however, an object can call this method on itself at any time when a critical instance variable is changed. It is recommended that wpSaveDeferred be used in most cases. If you do choose to use this method, you should not call it from your user-interface thread; instead, you should use a background thread. This method will cause the wpSaveState method to be called.
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. / BOOL rc; / Success indicator. */ rc = _wpSaveImmediate(somSelf);
MRESULT EXPENTRY MyDialogProc ( HWND hwndDlg, ULONG msg , MPARAM mp1, MPARAM mp2 ) { SOMAny somSelf; / Temporary ptr to object instance / PWINDATA pwin; / Window data / PSZ psz; / User title to manipulate / HWND hwndEntry; / Window handle / CHAR buf[30]; / Buffer */ switch( msg ) { case WM_INITDLG: somSelf = (SOMAny *) mp2; /* obtain creation parms */ pwin = (PWINDATA) _wpAllocMem ( somSelf, sizeof (WINDATA), NULL ); WinSetWindowPtr (hwndDlg, QWL_USER, pwin ); /* Initialize the windata structure */ pwin->somSelf = somSelf; pwin->somClassObj = _somGetClass ( pwin->somSelf ); /* query title string from instance data, and fill */ /* entryfield with the string */ psz = _UserGetTitle ( pwin->somSelf ); hwndEntry = WinWindowFromID ( hwndDlg, DLG_ENTRYFIELD ); WinSetWindowText ( hwndEntry, psz ); WinSetFocus ( HWND_DESKTOP, hwndEntry ); /* return TRUE to tell PM that we changed focus */ return (MRESULT) TRUE ; case WM_DESTROY: pwin = (PWINDATA) WinQueryWindowPtr ( hwndDlg, QWL_USER ); /* Save entryfield data to instance fields */ hwndEntry = WinWindowFromID ( hwndDlg, DLG_ENTRYFIELD); WinQueryWindowText ( hwndEntry, sizeof (buf), (PCH) &buf ); /* Save entryfield data to instance data */ _UserSetTitle ( pwin->somSelf, (PSZ) &buf ); /* Save instance data to OS2.INI file *now* */ _wpSaveImmediate ( pwin -> somSelf ); _wpFreeMem( pwin->somSelf,(PBYTE) pwin ); return ( WinDefDlgProc( hwndDlg, msg, mp1, mp2 ) ); } return ( WinDefDlgProc( hwndDlg, msg, mp1, mp2 ) ); }