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); }