Jump to content

wpOpen

From EDM2

This instance method is called to open a view to the object.

Syntax

_wpOpen(somSelf, hwndCnr, ulView, param)

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.
hwndCnr (HWND) - input
Handle of the container window from which the object is opened. This value may be set to NULLHANDLE.
ulView (ULONG) - input
Specifies which view to open.
OPEN_CONTENTS Open contents view.
OPEN_DEFAULT Open default view (same as double-click).
OPEN_DETAILS Open details view.
OPEN_HELP Display HelpPanel.
OPEN_PALETTE Open palette object.
OPEN_PROMPTDLG Open prompt dialog.
OPEN_RUNNING Execute object.
OPEN_SETTINGS Open Settings notebook.
OPEN_TREE Open tree view.
OPEN_USER Class-specific views have a greater value than this.
param (ULONG) - input
Open view parameter. This value is (reserved = NULL) for views supported by the WPObject class.

Returns

rc (HWND) - returns
Success indicator.
NULLHANDLE: Error occurred.
Other: Handle to either window created or program executed.

Remarks

In general, wpViewObject should be used instead of this method because wpViewObject takes into consideration the setting in the Object Open Behavior field on the Window page of the Settings notebook for the object. If a view of the object is already open, wpViewObject will, depending on the setting of the Object Open Behavior field, either display the existing window for the object or create a new object. In contrast, **wpOpen** always opens a new view of the object. Under certain circumstances this might be called for; however, under most circumstances, wpViewObject should be called instead.

Usage

This method can be called at any time in order to open a view of an object.

How to Override

This method should be overridden in order to process class-specific open views. This method can also be overridden in order to modify the behavior defined by an ancestor class. When wpOpen is overridden to implement a user-defined view, it should call wpAddToObjUseList and wpRegisterView to ensure that the new view is registered by the Workplace Shell as a view of the object.

Example Code

This example performs special processing upon first opening a folder.

SOM_Scope HWND   SOMLINK myfold_wpOpen(MYFOLDER *somSelf,
                                 HWND hwndCnr,
                                 ULONG ulView,
                                 ULONG param)

{
    HWND         hwndFromParentOpen = NULLHANDLE;
    MYFOLDERData *somThis = MYFOLDERGetData(somSelf);
    MYFOLDERMethodDebug("MYFOLDER","myfold_wpOpen");

    if (_queryFirstViewHandle(somSelf) == NULLHANDLE)
    {
             /* ONLY do this on FIRST open of the folder. */

       if (_wpPopulate(somSelf, NULLHANDLE, NULL, FALSE))

        {
            WPObject *Obj;
            WPObject *LastFoundObj = NULL;

            /* Check contents of folder and see which are instances of
             * WPFolder, we'll delete any WPFolders as a cleanup step */

            for ( Obj = _wpQueryContent(somSelf,NULL,(ULONG)QC_First);
                  Obj;
                  Obj = _wpQueryContent(somSelf, Obj, (ULONG) QC_Next ))

            {
              /* delete the last object found on the previous iteration
               * of the loop (we couldn't delete it then, because we
               * needed it at the top of the loop for this iteration)
               */
              if (LastFoundObj) {
                  _wpDelete(LastFoundObj,0);
                  LastFoundObj = NULL;
              } /* endif */

              /* we want to make sure that all previously
               * existing folders are deleted */

              if (_somIsA(Obj, _WPFolder)) {
                  LastFoundObj = Obj;
              }  /* endif */

            }  /* endfor */

            /* if there is still one object left to delete, do it now */


            if (LastFoundObj) {
              _wpDelete(LastFoundObj,0);
              LastFoundObj = NULL;
            } /* endif */
        } /* end if populate */
    } /* end if first open */

              /* Show the opened folder */

    hwndFromParentOpen = parent_wpOpen(somSelf, hwndCnr, ulView, param);

              /* If this is the first open, set our global flag */

    if (_queryFirstViewHandle(somSelf) == NULLHANDLE)  {
        _setFirstViewHandle(somSelf, hwndFromParentOpen);
    } /* endif */

    return( hwndFromParentOpen );
}

Related Methods