home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / wps / wsfile / wsfolder.c < prev    next >
C/C++ Source or Header  |  1999-05-12  |  27KB  |  926 lines

  1.  
  2. /*
  3.  *  This file was generated by the SOM Compiler.
  4.  *  Generated using:
  5.  *     SOM incremental update: 2.43
  6.  */
  7.  
  8.  
  9. /******************************************************************************
  10. *
  11. *  Module Name: WSFOLDER.C
  12. *
  13. *  OS/2 Work Place Shell Sample Program
  14. *
  15. *  Copyright (C) 1994, 1995 IBM Corporation
  16. *
  17. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  18. *      sample code created by IBM Corporation. This sample code is not
  19. *      part of any standard or IBM product and is provided to you solely
  20. *      for  the purpose of assisting you in the development of your
  21. *      applications.  The code is provided "AS IS", without
  22. *      warranty of any kind.  IBM shall not be liable for any damages
  23. *      arising out of your use of the sample code, even if they have been
  24. *      advised of the possibility of such damages.
  25. *
  26. *  Entry Points:
  27. *
  28. *     Class Methods:
  29. *
  30. *        wsfoldM_clsQueryModuleHandle
  31. *
  32. *     Overridden Class Methods:
  33. *
  34. *        wsfoldM_wpclsInitData
  35. *        wsfoldM_wpclsQueryTitle
  36. *        wsfoldM_wpclsQueryIconData
  37. *        wsfoldM_wpclsQueryIconDataN
  38. *        wsfoldM_wpclsQueryDefaultView
  39. *        wsfoldM_wpclsQueryDefaultHelp
  40. *        wsfoldM_wpclsQueryStyle
  41. *
  42. *     Instance Methods:
  43. *
  44. *        wsfold_closeViews
  45. *        wsfold_queryFirstViewHandle
  46. *        wsfold_setFirstViewHandle
  47. *
  48. *     Overridden Instance Methods:
  49. *
  50. *        wsfold_wpOpen
  51. *        wsfold_wpClose
  52. *        wsfold_wpMenuItemHelpSelected
  53. *        wsfold_wpMenuItemSelected
  54. *        wsfold_wpModifyPopupMenu
  55. *        wsfold_wpDragOver
  56. *        wsfold_wpDrop
  57. *        wsfold_wpDeleteFromObjUseList
  58. *        wsfold_wpQueryConcurrentView
  59. *        wsfold_wpInitData
  60. *        wsfold_wpPrintObject
  61. *        wsfold_wpAddToContent
  62. *        wsfold_wpDeleteFromContent
  63. *
  64. *     Non-Method Functions:
  65. *
  66. *
  67. ******************************************************************************/
  68.  
  69. #define INCL_DOS
  70. #define INCL_PM
  71. #include <os2.h>
  72. #include <string.h>
  73.  
  74. #define WSFOLDER_Class_Source
  75. #define M_WSFOLDER_Class_Source
  76. #include "wsfolder.ih"
  77. /* CSC2IDL:  REMOVED after .csc -> .idl conversion:   #include "wsfolder.ph" */
  78.  
  79. /***************** GLOBAL/STATIC (NON-INSTANCE) DATA SECTION ******************
  80. *****                                                                     *****
  81. *****    This data shouldn't be changed by instance methods or it will    *****
  82. *****    effect all instances!  Any variables that are specific (unique   *****
  83. *****    values) for each instance of this object should be declared as   *****
  84. *****  instance data or dynamically allocated and stored as window data.  *****
  85. *****                                                                     *****
  86. *****      This global data should be declared as class instance data     *****
  87. *****    if it will change after initialization.  In this case, it will   *****
  88. *****                  be accessed through class methods.                 *****
  89. *****                                                                     *****
  90. ******************************************************************************/
  91.  
  92.    UCHAR      szWSFOLDERClassTitle[CCHMAXPATH] = "";
  93.    CHAR       szHelpLibrary[] =          "wsfolder.hlp";
  94.    HMODULE    hmod = NULLHANDLE;
  95.  
  96. /*
  97.  *  METHOD: closeViews                                     ( ) PRIVATE
  98.  *                                                         (X) PUBLIC
  99.  *  DESCRIPTION:
  100.  *
  101.  *    Close all but the first of the currently open views of a wsfolder object.
  102.  *
  103.  *  NOTE: There is a "Close Views" option on the context menu, that will
  104.  *         call this method
  105.  */
  106. SOM_Scope void   SOMLINK wsfold_closeViews(WSFOLDER *somSelf)
  107. {
  108.     PUSEITEM  pUseItem, pUseItemNext;
  109.     PVIEWITEM pViewItem;
  110.     HWND      hwndView;
  111.     typedef struct _HANDLENODE
  112.     {
  113.        LHANDLE handle;
  114.        struct _HANDLENODE * pNextHandle;
  115.     } HANDLENODE;
  116.     HANDLENODE *pHandles = NULL;
  117.     HANDLENODE *pTemp = NULL;
  118.  
  119.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  120.     WSFOLDERMethodDebug("WSFOLDER","wsfold_closeViews");
  121.  
  122.  
  123.     /* go through use list looking for OPENVIEW use items, as you
  124.      * find one, add view item's handle to a list
  125.      */
  126.     for ( pUseItem = _wpFindUseItem(somSelf , USAGE_OPENVIEW, NULL);
  127.           pUseItem;
  128.           pUseItem = _wpFindUseItem(somSelf , USAGE_OPENVIEW, pUseItem) )
  129.     {
  130.        if (pTemp = (HANDLENODE*)_wpAllocMem(somSelf,sizeof(HANDLENODE),NULL))
  131.        {
  132.           pViewItem = (PVIEWITEM)(pUseItem + 1);
  133.           pTemp->handle = pViewItem->handle;       /* hwnd of view */
  134.           pTemp->pNextHandle = pHandles;
  135.           pHandles = pTemp;
  136.        }
  137.     }
  138.  
  139.     /* go through list of handles we just found and close any
  140.      * views other than the first one
  141.      */
  142.     pTemp = pHandles;
  143.     while (pTemp)
  144.     {
  145.        if (_queryFirstViewHandle(somSelf) != (HWND)pTemp->handle )
  146.        {
  147.           WinSendMsg( (HWND)pTemp->handle, WM_CLOSE, 0, 0);
  148.        }
  149.        pTemp = pTemp->pNextHandle;
  150.     }
  151.  
  152.     /* free our list */
  153.     while (pHandles)
  154.     {
  155.        pTemp = pHandles;
  156.        pHandles = pTemp->pNextHandle;
  157.        _wpFreeMem(somSelf,(PBYTE)pTemp);
  158.     }
  159.  
  160. }
  161.  
  162. /*
  163.  *
  164.  *   METHOD: queryFirstViewHandle                           ( ) PRIVATE
  165.  *                                                          (X) PUBLIC
  166.  *   DESCRIPTION:
  167.  *
  168.  *     return the handle of the view that was opened first of the
  169.  *     currently open views of this wsfolder object.
  170.  *
  171.  */
  172. SOM_Scope HWND   SOMLINK wsfold_queryFirstViewHandle(WSFOLDER *somSelf)
  173. {
  174.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  175.     WSFOLDERMethodDebug("WSFOLDER","wsfold_queryFirstViewHandle");
  176.  
  177.     return _hwndFirstView;
  178. }
  179.  
  180. /*
  181.  *
  182.  *   METHOD: setFirstViewHandle                             ( ) PRIVATE
  183.  *                                                          (X) PUBLIC
  184.  *   DESCRIPTION:
  185.  *
  186.  *     Do special processing on first open of folder
  187.  *
  188.  *   PARAMETERS:
  189.  *
  190.  *      HWND - hwnd of the first of multiple currently opened
  191.  *             views of this object
  192.  *
  193.  *   RETURNS:
  194.  *
  195.  *      TRUE - hwnd set successfully
  196.  *      FALSE - first hwnd wasn't set successfully
  197.  *
  198.  */
  199. SOM_Scope BOOL   SOMLINK wsfold_setFirstViewHandle(WSFOLDER *somSelf,
  200.                 HWND hwndView)
  201. {
  202.     BOOL rc = TRUE;
  203.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  204.     WSFOLDERMethodDebug("WSFOLDER","wsfold_setFirstViewHandle");
  205.  
  206.     if (hwndView != NULLHANDLE)
  207.     {
  208.       if (_hwndFirstView == NULLHANDLE)  /* no current first view */
  209.       {
  210.          _hwndFirstView = hwndView;     /* setting to a first view handle */
  211.       }
  212.       else
  213.       {
  214.          /* a non-null _hwndFirstView can only be wiped out by resetting it
  215.           * to NULLHANDLE, not to another handle.  This prevents a
  216.           * misuse of this method
  217.           */
  218.          rc = FALSE;
  219.       }
  220.  
  221.     }
  222.     else      /* wiping out first view handle */
  223.     {
  224.        _hwndFirstView = NULLHANDLE;
  225.     }
  226.  
  227.     return rc;
  228. }
  229.  
  230. /*
  231.  *  METHOD: wpOpen                                         ( ) PRIVATE
  232.  *                                                         (X) PUBLIC
  233.  *  DESCRIPTION:
  234.  *
  235.  *    Do special processing on first open of folder
  236.  */
  237. SOM_Scope HWND   SOMLINK wsfold_wpOpen(WSFOLDER *somSelf,
  238.                 HWND hwndCnr,
  239.                 ULONG ulView,
  240.                 ULONG param)
  241. {
  242.     HWND        hwndFromParentOpen = NULLHANDLE;
  243.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  244.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpOpen");
  245.  
  246.     if (_queryFirstViewHandle(somSelf) == NULLHANDLE)
  247.     {
  248.  
  249.        /* we ONLY want to do this on the FIRST open of the folder.
  250.         */
  251.        if (_wpPopulate(somSelf, NULLHANDLE, NULL, FALSE))
  252.         {
  253.            WPObject *Obj;
  254.            WPObject *LastFoundObj = NULL;
  255.  
  256.            /* loop through the contents of the folder, checking each to
  257.             * see if it is an instance of a WPFolder, we'll delete any
  258.             * WPFolders as a cleanup step
  259.             */
  260.            for ( Obj = _wpQueryContent(somSelf,NULL,(ULONG)QC_First);
  261.                  Obj;
  262.                  Obj = _wpQueryContent(somSelf, Obj, (ULONG) QC_Next ))
  263.            {
  264.               /* delete the last object found on the previous iteration
  265.                * of the loop (we couldn't delete it then, because we
  266.                * needed it at the top of the loop for this iteration)
  267.                */
  268.               if (LastFoundObj)
  269.               {
  270.                  _wpDelete(LastFoundObj,0);
  271.                  LastFoundObj = NULL;
  272.               }
  273.  
  274.               /* we want to make sure that all previously
  275.                * existing folders are deleted
  276.                */
  277.               if (_somIsA(Obj, _WPFolder))
  278.               {
  279.                  LastFoundObj = Obj;
  280.               }
  281.  
  282.            }  /* end for */
  283.  
  284.  
  285.            /* if there is still one object left to delete, do it now
  286.             */
  287.            if (LastFoundObj)
  288.            {
  289.               _wpDelete(LastFoundObj,0);
  290.               LastFoundObj = NULL;
  291.            }
  292.        } /* end if populate */
  293.     } /* end if first open */
  294.  
  295.     /* now, show the opened folder */
  296.     hwndFromParentOpen = parent_wpOpen(somSelf, hwndCnr, ulView, param);
  297.  
  298.     /* if this is the first open, set our global flag
  299.      */
  300.     if (_queryFirstViewHandle(somSelf) == NULLHANDLE)
  301.     {
  302.         _setFirstViewHandle(somSelf, hwndFromParentOpen);
  303.     }
  304.  
  305.     return hwndFromParentOpen;
  306. }
  307.  
  308. /*
  309.  *
  310.  *   METHOD: wpInitData                                     ( ) PRIVATE
  311.  *                                                          (X) PUBLIC
  312.  *   DESCRIPTION:
  313.  *
  314.  *     Set object's detail class to be WSFILE
  315.  *
  316.  */
  317.  
  318. SOM_Scope VOID   SOMLINK wsfold_wpInitData(WSFOLDER *somSelf)
  319. {
  320.     SOMClass * pClass;
  321.     somId      ClassId;
  322.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  323.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpInitData");
  324.  
  325.     parent_wpInitData(somSelf);
  326.     ClassId = SOM_IdFromString( "WSFILE" );
  327.     pClass = _somFindClass( SOMClassMgrObject, ClassId, 1, 1);
  328.     SOMFree(ClassId);         /* always free somIds */
  329.     _wpSetFldrDetailsClass(somSelf, pClass);
  330.     _wpSetFldrSortClass(somSelf, pClass);
  331. }
  332. /*
  333.  * METHOD: wpModifyPopupMenu                              ( ) PRIVATE
  334.  *                                                        (X) PUBLIC
  335.  * DESCRIPTION:
  336.  *
  337.  *   Add our extra option to the context menu to close all but first view
  338.  */
  339. SOM_Scope BOOL   SOMLINK wsfold_wpModifyPopupMenu(WSFOLDER *somSelf,
  340.                 HWND hwndMenu,
  341.                 HWND hwndCnr,
  342.                 ULONG iPosition)
  343. {
  344.     HMODULE    hmod = NULLHANDLE;
  345.     zString    zsPathName;
  346.  
  347.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  348.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpModifyPopupMenu");
  349.  
  350.     hmod = _clsQueryModuleHandle(_WSFOLDER);
  351.     if (hmod)
  352.     {
  353.        _wpInsertPopupMenuItems( somSelf, hwndMenu, 0, hmod, ID_CLOSEVIEWSMENU, 0);
  354.     }
  355.  
  356.     return (parent_wpModifyPopupMenu(somSelf,hwndMenu,hwndCnr,iPosition));
  357.  
  358. }
  359.  
  360. /*
  361.  * METHOD: wpMenuItemSelected                             ( ) PRIVATE
  362.  *                                                        (X) PUBLIC
  363.  * DESCRIPTION:
  364.  *
  365.  *   Process extra menu option that we added.
  366.  */
  367. SOM_Scope BOOL   SOMLINK wsfold_wpMenuItemSelected(WSFOLDER *somSelf,
  368.                 HWND hwndFrame,
  369.                 ULONG ulMenuId)
  370. {
  371.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  372.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpMenuItemSelected");
  373.  
  374.     if (ulMenuId == IDM_CLOSEVIEWS)
  375.     {
  376.        _closeViews(somSelf);
  377.        return(TRUE);
  378.     }
  379.     else
  380.     {
  381.        return (parent_wpMenuItemSelected(somSelf,hwndFrame,ulMenuId));
  382.     }
  383. }
  384.  
  385.  
  386. /*
  387.  *
  388.  *  METHOD: wpMenuItemHelpSelected                         ( ) PRIVATE
  389.  *                                                         (X) PUBLIC
  390.  *  DESCRIPTION:
  391.  *
  392.  *    Process help for the extra menu option that we added.
  393.  *
  394.  */
  395. SOM_Scope BOOL   SOMLINK wsfold_wpMenuItemHelpSelected(WSFOLDER *somSelf,
  396.                 ULONG MenuId)
  397. {
  398.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  399.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpMenuItemHelpSelected");
  400.  
  401.     switch( MenuId )
  402.     {
  403.        case IDM_CLOSEVIEWS:
  404.  
  405.           return(_wpDisplayHelp(somSelf,ID_HELP_CLOSEVIEWS,szHelpLibrary));
  406.           break;
  407.  
  408.        default:
  409.           break;
  410.     }
  411.  
  412.      return (parent_wpMenuItemHelpSelected(somSelf,MenuId));
  413. }
  414.  
  415. /*
  416.  *
  417.  *  METHOD: wpClose                                        ( ) PRIVATE
  418.  *                                                         (X) PUBLIC
  419.  *  DESCRIPTION:
  420.  *
  421.  *    When a folder object is closed, we will zero out its first view
  422.  *    instance variable, so that the next time it has a first view opened,
  423.  *    we can keep track of that.
  424.  *
  425.  */
  426. SOM_Scope BOOL   SOMLINK wsfold_wpClose(WSFOLDER *somSelf)
  427. {
  428.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  429.     BOOL          rcParentClose;
  430.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpClose");
  431.  
  432.     rcParentClose = parent_wpClose(somSelf);
  433.     _setFirstViewHandle(somSelf, NULLHANDLE);
  434.     return(rcParentClose);
  435. }
  436.  
  437. /*
  438.  * METHOD: wpDragOver                                     ( ) PRIVATE
  439.  *                                                        (X) PUBLIC
  440.  * DESCRIPTION:
  441.  *
  442.  *   Instances of class WSFOLDER are the only folders that accept a drop
  443.  *   of a WSFILE object.  This override returns DOR_DROP when a WSFILE
  444.  *   object is dragged over a WSFOLDER object.  The default meaning of
  445.  *   a drag will be changed to perform a COPY (instead of the default
  446.  *   being to MOVE the object)
  447.  */
  448. SOM_Scope MRESULT   SOMLINK wsfold_wpDragOver(WSFOLDER *somSelf,
  449.                 HWND hwndCnr,
  450.                 PDRAGINFO pdrgInfo)
  451. {
  452.     MRESULT   mr;
  453.     PDRAGITEM pDragItem;
  454.     ULONG     i;
  455.     ULONG     ulOurs = 0;
  456.  
  457.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  458.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpDragOver");
  459.  
  460.     for (i = 0; i < pdrgInfo->cditem ; i++)
  461.     {
  462.        pDragItem = DrgQueryDragitemPtr(pdrgInfo,i);
  463.  
  464.        if (DrgVerifyRMF(pDragItem,"DRM_OUROWNSPECIAL","DRF_OBJECT"))
  465.        {
  466.           ulOurs++;
  467.        }
  468.     }
  469.  
  470.     if (ulOurs == 0)
  471.     {
  472.        mr = (parent_wpDragOver(somSelf,hwndCnr,pdrgInfo));
  473.     }
  474.     else
  475.     {
  476.        if (ulOurs == pdrgInfo->cditem)
  477.        {
  478.           mr = MRFROM2SHORT(DOR_DROP,
  479.                            (SHORT)((pdrgInfo->usOperation == DO_DEFAULT)
  480.                                    ? DO_COPY : pdrgInfo->usOperation));
  481.        }
  482.        else
  483.        {
  484.           mr = MRFROM2SHORT(DOR_NEVERDROP,DO_DEFAULT);
  485.        }
  486.     }
  487.     return mr;
  488. }
  489.  
  490. /*
  491.  * METHOD: wpDrop                                         ( ) PRIVATE
  492.  *                                                        (X) PUBLIC
  493.  * DESCRIPTION:
  494.  *
  495.  *   This override will be called after a drop of a WSFILE object, so that
  496.  *   the drop can actually be processed.
  497.  */
  498. SOM_Scope MRESULT   SOMLINK wsfold_wpDrop(WSFOLDER *somSelf,
  499.                 HWND hwndCnr,
  500.                 PDRAGINFO pdrgInfo,
  501.                 PDRAGITEM pdrgItem)
  502. {
  503.     ULONG     i;
  504.     PDRAGITEM pDragItem;
  505.  
  506.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  507.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpDrop");
  508.  
  509.     for (i = 0; i < pdrgInfo->cditem ; i++)
  510.     {
  511.        pDragItem = DrgQueryDragitemPtr(pdrgInfo,i);
  512.  
  513.        if (DrgVerifyRMF(pDragItem,"DRM_OUROWNSPECIAL","DRF_OBJECT"))
  514.        {
  515.           DrgDeleteStrHandle(pDragItem->hstrRMF);
  516.           pDragItem->hstrRMF = DrgAddStrHandle("<DRM_OBJECT,DRF_OBJECT>");
  517.        }
  518.     }
  519.  
  520.     return (parent_wpDrop(somSelf,hwndCnr,pdrgInfo,pdrgItem));
  521. }
  522.  
  523. /*
  524.  * METHOD: wpDeleteFromObjUseList                         ( ) PRIVATE
  525.  *                                                        (X) PUBLIC
  526.  * DESCRIPTION:
  527.  *
  528.  *   When a the last view of a WSFOLDER object is closed, we will zero out
  529.  *   its "first view" instance variable, so that the next time it has a first
  530.  *   view opened, we can keep track of that.
  531.  */
  532. SOM_Scope BOOL  SOMLINK wsfold_wpDeleteFromObjUseList(WSFOLDER *somSelf,
  533.                        PUSEITEM  pUseItem )
  534. {
  535.    WSFOLDERData *somThis   = WSFOLDERGetData(somSelf);
  536.    PUSEITEM      pItem;
  537.    BOOL          rcParentCall;
  538.    WSFOLDERMethodDebug("WSFOLDER","wsfold_wpDeleteFromObjUseList");
  539.  
  540.    rcParentCall = parent_wpDeleteFromObjUseList(somSelf, pUseItem);
  541.  
  542.    pItem = _wpFindUseItem(somSelf, USAGE_OPENVIEW, NULL);
  543.    if (!pItem)
  544.    {
  545.       _setFirstViewHandle(somSelf, NULLHANDLE);
  546.    }
  547.    return(rcParentCall);
  548. }
  549.  
  550. /*
  551.  * METHOD: wpQueryConcurrentView                          ( ) PRIVATE
  552.  *                                                        (X) PUBLIC
  553.  * DESCRIPTION:
  554.  *
  555.  *   Objects of WSFOLDER class have concurrent views set to ON
  556.  *   by default
  557.  */
  558. SOM_Scope ULONG  SOMLINK wsfold_wpQueryConcurrentView(WSFOLDER *somSelf )
  559. {
  560. /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  561.    WSFOLDERMethodDebug("WSFOLDER","wsfold_wpQueryConcurrentView");
  562.  
  563.    return CCVIEW_ON;
  564. }
  565.  
  566. /*
  567.  *  METHOD: wpPrintObject                                  ( ) PRIVATE
  568.  *                                                         (X) PUBLIC
  569.  *  DESCRIPTION:
  570.  *
  571.  *    We will simply beep when a WSFOLDER object is "printed"
  572.  */
  573. SOM_Scope BOOL   SOMLINK wsfold_wpPrintObject(WSFOLDER *somSelf,
  574.                 PPRINTDEST pPrintDest,
  575.                 ULONG ulReserved)
  576. {
  577.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  578.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpPrintObject");
  579.  
  580.     WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  581.                    (PSZ) "(just pretend!)",
  582.                    (PSZ) "Folder Contents Printing",
  583.                     20,
  584.                     MB_OK | MB_INFORMATION | MB_MOVEABLE);
  585.  
  586.     return TRUE;
  587. }
  588.  
  589. /*
  590.  * METHOD: wpAddToContent                                 ( ) PRIVATE
  591.  *                                                        (X) PUBLIC
  592.  * DESCRIPTION:
  593.  *
  594.  *   We will put up a dialog containing the title of
  595.  *   the newly added object whenever one is added to a WSFOLDER
  596.  *   object
  597.  */
  598. SOM_Scope BOOL   SOMLINK wsfold_wpAddToContent(WSFOLDER *somSelf,
  599.                                                WPObject *pObject)
  600. {
  601.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  602.     BOOL  rc = FALSE;
  603.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpAddToContent");
  604.  
  605.     rc = parent_wpAddToContent(somSelf, pObject);
  606.     if (rc)
  607.     {
  608.        WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  609.                       (PSZ) _wpQueryTitle(pObject),
  610.                       (PSZ) "Notification of added object",
  611.                        20,
  612.                        MB_OK | MB_INFORMATION | MB_MOVEABLE);
  613.     }
  614.     return(rc);
  615.  
  616. }
  617.  
  618. /*
  619.  * METHOD: wpDeleteFromContent                            ( ) PRIVATE
  620.  *                                                        (X) PUBLIC
  621.  * DESCRIPTION:
  622.  *
  623.  *   We will put up a dialog containing the title of
  624.  *   the newly removed object whenever one is removed from a WSFOLDER
  625.  *   object
  626.  */
  627. SOM_Scope BOOL   SOMLINK wsfold_wpDeleteFromContent(WSFOLDER *somSelf,
  628.                                                     WPObject *pObject)
  629. {
  630.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  631.     BOOL rc = FALSE;
  632.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpDeleteFromContent");
  633.  
  634.     rc = parent_wpDeleteFromContent(somSelf, pObject);
  635.     if (rc)
  636.     {
  637.        WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  638.                       (PSZ) _wpQueryTitle(pObject),
  639.                       (PSZ) "Notification of removed object",
  640.                        20,
  641.                        MB_OK | MB_INFORMATION | MB_MOVEABLE);
  642.     }
  643.     return(rc);
  644.  
  645. }
  646.  
  647. #undef SOM_CurrentClass
  648. #define SOM_CurrentClass SOMMeta
  649.  
  650. /*
  651.  *
  652.  *  METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  653.  *                                                         (X) PUBLIC
  654.  *  DESCRIPTION:
  655.  *
  656.  *    This method returns the module handle of this class.  If this is the
  657.  *    first invocation, DosQueryModuleHandle is called to save the handle
  658.  *    for future invocations.
  659.  *
  660.  *  RETURN:
  661.  *
  662.  *    0              Unsuccessful
  663.  *    non-zero       module handle
  664.  *
  665.  */
  666. SOM_Scope HMODULE   SOMLINK wsfoldM_clsQueryModuleHandle(M_WSFOLDER *somSelf)
  667. {
  668.  
  669.     /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  670.     APIRET rc;
  671.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_clsQueryModuleHandle");
  672.  
  673.    /*
  674.     *   Make sure we already have module handle
  675.     */
  676.  
  677.     if (hmod == NULLHANDLE)
  678.     {
  679.      zString zsPathName;
  680.        /*
  681.         *   Retrieve registered pathname of our module (DLL) and query the
  682.         *   module handle.
  683.         */
  684.        zsPathName =
  685.        _somLocateClassFile( SOMClassMgrObject, SOM_IdFromString("WSFOLDER"),
  686.                             WSFOLDER_MajorVersion, WSFOLDER_MinorVersion);
  687.        rc = DosQueryModuleHandle( zsPathName, &hmod);
  688.        if (rc)
  689.        {
  690.           DebugBox("wsfoldM_wpclsInitData", "Failed to load module");
  691.           return;
  692.        }
  693.  
  694.     }   /* end if (hmod == NULLHANDLE) */
  695.  
  696.     return (hmod);
  697.  
  698. }
  699.  
  700. /*
  701.  *
  702.  *  METHOD: wpclsInitData
  703.  *
  704.  *  DESCRIPTION:
  705.  *
  706.  *    Initalize the class data
  707.  *
  708.  */
  709.  
  710. /*
  711.  * SOM_Scope void   SOMLINK wsfoldM_wpclsInitData(WSFOLDER *somSelf)
  712.  */
  713.  
  714. /*
  715.  * The prototype for wsfoldM_wpclsInitData was replaced by the following prototype:
  716.  */
  717. SOM_Scope void  SOMLINK wsfoldM_wpclsInitData(M_WSFOLDER *somSelf)
  718. {
  719. /*    WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  720.     WSFOLDERMethodDebug("WSFOLDER","wsfoldM_wpclsInitData");
  721.  
  722.     parent_wpclsInitData(somSelf);
  723.  
  724.     /*
  725.      *   Get class title
  726.      */
  727.     if (!WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), _clsQueryModuleHandle(somSelf), ID_TITLE,
  728.                          sizeof(szWSFOLDERClassTitle), szWSFOLDERClassTitle))
  729.                               /* Load string failed: use the parent's string */
  730.        strcpy(szWSFOLDERClassTitle, parent_wpclsQueryTitle(somSelf));
  731.  
  732. }
  733.  
  734. /*
  735.  *
  736.  *  METHOD: wpclsQueryDefaultHelp                          ( ) PRIVATE
  737.  *                                                         (X) PUBLIC
  738.  *  DESCRIPTION:
  739.  *
  740.  *    Define help for objects of our class.
  741.  *
  742.  */
  743. /*
  744.  *
  745.  * METHOD: wpclsQueryDefaultHelp                          ( ) PRIVATE
  746.  *                                                        (X) PUBLIC
  747.  * DESCRIPTION:
  748.  *
  749.  *   Define help for objects of our class
  750.  *
  751.  */
  752.  
  753. SOM_Scope BOOL SOMLINK wsfoldM_wpclsQueryDefaultHelp(M_WSFOLDER *somSelf,
  754.                 PULONG pHelpPanelId,
  755.                 PSZ pszHelpLibrary)
  756. {
  757.  /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  758.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryDefaultHelp");
  759.  
  760.     if (pHelpPanelId)                           /* set default help panel id */
  761.        *pHelpPanelId   = ID_HELP_DEFAULT;
  762.  
  763.     if (pszHelpLibrary)                                /* copy help filename */
  764.        strcpy(pszHelpLibrary, szHelpLibrary);
  765.  
  766.     return (TRUE);
  767.  
  768. }
  769.  
  770. /*
  771.  *
  772.  *  METHOD: wpclsQueryDefaultView                          ( ) PRIVATE
  773.  *                                                         (X) PUBLIC
  774.  *  DESCRIPTION:
  775.  *
  776.  *    WSFOLDER objects open in OPEN_DETAILS by default
  777.  *
  778.  */
  779. /*
  780.  *
  781.  * METHOD: wpclsQueryDefaultView                          ( ) PRIVATE
  782.  *                                                        (X) PUBLIC
  783.  * DESCRIPTION:
  784.  *
  785.  *   WSFOLDER objects will default to details view
  786.  *
  787.  */
  788.  
  789. SOM_Scope ULONG SOMLINK wsfoldM_wpclsQueryDefaultView(M_WSFOLDER *somSelf)
  790. {
  791.  /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  792.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryDefaultView");
  793.  
  794.     return OPEN_DETAILS;
  795.  
  796. }
  797.  
  798. /*
  799.  *
  800.  *  METHOD: wpclsQueryTitle
  801.  *
  802.  *  DESCRIPTION:
  803.  *
  804.  *    Return class title for WSFOLDER class
  805.  *
  806.  */
  807. SOM_Scope PSZ   SOMLINK wsfoldM_wpclsQueryTitle(M_WSFOLDER *somSelf)
  808. {
  809.     /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  810.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryTitle");
  811.  
  812.     if (*szWSFOLDERClassTitle )
  813.        return( szWSFOLDERClassTitle );
  814.     else
  815.        return( parent_wpclsQueryTitle(somSelf));
  816. }
  817.  
  818. /*
  819.  *
  820.  *  METHOD: wpclsQueryIconData                            ( ) PRIVATE
  821.  *                                                         (X) PUBLIC
  822.  *  DESCRIPTION:
  823.  *
  824.  *    Return the class icon
  825.  *
  826.  */
  827. SOM_Scope ULONG SOMLINK wsfoldM_wpclsQueryIconData(M_WSFOLDER *somSelf,
  828.                   PICONINFO pIconInfo)
  829. {
  830.    APIRET rc;
  831.    M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryIconData");
  832.  
  833.    if (pIconInfo)
  834.    {
  835.       /*
  836.        *   fill in icon information
  837.        */
  838.       pIconInfo->fFormat = ICON_RESOURCE;
  839.       pIconInfo->hmod= _clsQueryModuleHandle(somSelf);
  840.       pIconInfo->resid= ID_ICON;
  841.    }
  842.  
  843.    return (sizeof(ICONINFO));
  844.  
  845. }
  846.  
  847. /*
  848.  *
  849.  *  METHOD: wpclsQueryIconDataN                            ( ) PRIVATE
  850.  *                                                         (X) PUBLIC
  851.  *  DESCRIPTION:
  852.  *
  853.  *    Return the class open icon
  854.  *
  855.  */
  856.  
  857. /*
  858.  * SOM_Scope ULONG SOMLINK wsfoldM_wpclsQueryIconDataN(M_WSFOLDER *somSelf,
  859.  *                   PICONINFO pIconInfo, ULONG ulIconIndex)
  860.  */
  861.  
  862. /*
  863.  * The prototype for wsfoldM_wpclsQueryIconDataN was replaced by the following prototype:
  864.  */
  865. SOM_Scope ULONG  SOMLINK wsfoldM_wpclsQueryIconDataN(M_WSFOLDER *somSelf, 
  866.                                                      ICONINFO* pIconInfo, 
  867.                                                      ULONG ulIconIndex)
  868. {
  869.    APIRET rc;
  870.  
  871.    M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryIconDataN");
  872.  
  873.    if (pIconInfo)
  874.    {
  875.       if (ulIconIndex == 1)
  876.       {
  877.          /*
  878.           *   fill in open icon information
  879.           */
  880.          pIconInfo->fFormat = ICON_RESOURCE;
  881.          pIconInfo->hmod= _clsQueryModuleHandle(somSelf);
  882.          pIconInfo->resid= ID_OPENICON;
  883.  
  884.       }
  885.       else
  886.          return parent_wpclsQueryIconDataN(somSelf, pIconInfo, ulIconIndex);
  887.    }
  888.  
  889.    return (sizeof(ICONINFO));
  890.  
  891. }
  892.  
  893. /*
  894.  *  METHOD: wpclsQueryStyle                                ( ) PRIVATE
  895.  *                                                         (X) PUBLIC
  896.  *  DESCRIPTION:
  897.  *
  898.  *    Change default class style so that WSFOLDER objects have can
  899.  *    be "printed" (we'll just beep), and so that this class is not
  900.  *    templated.
  901.  */
  902.  
  903. /*
  904.  *
  905.  * METHOD: wpclsQueryDefaultView                          ( ) PRIVATE
  906.  *                                                        (X) PUBLIC
  907.  * DESCRIPTION:
  908.  *
  909.  *   Change default class style so that WSFOLDER objects can be
  910.  *   "printed" (we'll just beep), ans so that this class is not
  911.  *   templatable.
  912.  *
  913.  */
  914.  
  915. SOM_Scope ULONG   SOMLINK wsfoldM_wpclsQueryStyle(M_WSFOLDER *somSelf)
  916. {
  917.     /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  918.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryStyle");
  919.  
  920.     return ((parent_wpclsQueryStyle(somSelf) & ~CLSSTYLE_NEVERPRINT)
  921.             | CLSSTYLE_PRIVATE);
  922. }
  923.  
  924.  
  925.  
  926.