Jump to content

wpAddSettingsPages

From EDM2
Revision as of 20:06, 1 September 2025 by Ak120 (talk | contribs) (Returns)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This instance method is called to allow the object to add all of its Settings pages to its Settings notebook.

This method is called only by the system.

Syntax

_wpAddSettingsPages(somSelf, hwndNotebook);

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.
hwndNotebook (HWND) - input
Settings notebook handle.

Returns

rc (BOOL) - returns
Success indicator.
TRUE - Successful completion
FALSE - Error occurred

How to Override

This method is always overridden in order to add pages to or remove pages from the Settings notebook. To add a page to the Settings notebook, a call to wpInsertSettingsPage is required. To remove a page from the Settings notebook, the method that adds the page to the Settings notebook must be overridden and SETTINGS_PAGE_REMOVED is returned without calling its parent method.

When adding a page, the parent method should usually be called first. Calling the parent method first will put pages added by the overriding method at the top of the Settings notebook, above the pages added by ancestor classes. Calling the parent last will put pages added by the overriding at the bottom of the Settings notebook, below the pages added by ancestor classes.

Example Code

Definition:

#define INCL_WINWORKPLACE
#include <os2.h>

WPObject  *somSelf;       /* Pointer to the object on which the method is being invoked. */
HWND       hwndNotebook;  /* Settings notebook handle. */
BOOL       rc;            /* Success indicator. */

rc = _wpAddSettingsPages(somSelf, hwndNotebook);

This example adds a Settings notebook page to let the user modify the Last Worker's name.

SOM_Scope BOOL SOMLINK myf_wpAddSettingsPages(MYFILE *somSelf, HWND hwndNotebook)

{
    PAGEINFO pageinfo;

    MYFILEData *somThis = MYFILEGetData(somSelf);
    MYFILEMethodDebug("MYFILE","myf_wpAddSettingsPages");

    parent_wpAddSettingsPages(somSelf, hwndNotebook);

    memset((PCH)&pageinfo,0,sizeof(PAGEINFO));
    pageinfo.cb                 = sizeof(PAGEINFO);
    pageinfo.hwndPage           = NULLHANDLE;
    pageinfo.usPageStyleFlags   = BKA_MAJOR;
    pageinfo.usPageInsertFlags  = BKA_FIRST;
    pageinfo.pfnwp              = LastWorkerDlgProc;
    pageinfo.resid              = hmod;
    pageinfo.dlgid              = IDD_LASTWORKER;
    pageinfo.pszName            = "LastWorker";
    pageinfo.pCreateParams      = somSelf;
    pageinfo.idDefaultHelpPanel = ID_HELP_LASTWORKER;
    pageinfo.pszHelpLibraryName = szHelpLibrary;

    return _wpInsertSettingsPage( somSelf, hwndNotebook,&pageinfo );
}

Related Methods