wpPopulate
This instance method is called to allow the folder to populate itself.
Syntax
_wpPopulate(somSelf, ulReserved, pszPath, fFoldersOnly)
Parameters
- somSelf (WPFolder *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPFolder.
- ulReserved (ULONG) - input
- Reserved value; must be 0.
- pszPath (PSZ) - input
- Reserved value; must be NULL.
- fFoldersOnly (BOOL) - input
- Populate folder.
- The ored flag indicating the type of contents with which to populate the folder:
- TRUE: Populate with folder objects only.
- FALSE: Populate with entire contents of folder.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE: Successful completion.
- FALSE: Error occurred.
Remarks
The **wpPopulate** method sets the folder flags depending upon the value of fFoldersOnly. The folder flags indicate the current population state of the folder:
- FOI_POPULATEDWITHALL: Folder is completely populated.
- FOI_POPULATEDWITHFOLDERS: Folder is populated only with subfolders.
If the folder is re-populated when it has already been populated (as determined by inspecting the folder flags), no action is taken on this message apart from sending the notification message back. This method locks each object it instantiates as a result of the call.
Usage
This method is generally called only by the system when the folder is opened.
How to Override
This method can be overridden to alter the contents of a folder. To filter contents added by ancestor classes, it is important to call the parent method first.
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. It couldn't be deleted then, because it */ /* was needed at the top of the loop for this iteration. */ if (LastFoundObj) { _wpDelete(LastFoundObj,0); LastFoundObj = NULL; } /* endif */ /* 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 folder, set the global flag */ if (_queryFirstViewHandle(somSelf) == NULLHANDLE) { _setFirstViewHandle(somSelf, hwndFromParentOpen); } /* endif */ return(hwndFromParentOpen); }