home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / wps / wsfile / wsfile.c < prev    next >
Text File  |  1999-05-11  |  55KB  |  1,763 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: WSFILE.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. *        wsfM_clsQueryModuleHandle
  31. *        wsfM_clsQueryDefaultFileText
  32. *
  33. *     Overridden Class Methods:
  34. *
  35. *        wsfM_wpclsInitData
  36. *        wsfM_wpclsQueryDefaultHelp
  37. *        wsfM_wpclsQueryDefaultView
  38. *        wsfM_wpclsQueryDetailsInfo
  39. *        wsfM_wpclsQueryIconData
  40. *        wsfM_wpclsQueryStyle
  41. *        wsfM_wpclsQueryTitle
  42. *        wsfM_wpclsUnInitData
  43. *
  44. *     Instance Methods:
  45. *
  46. *        wsf_AddLastWorkerPage
  47. *        wsf_soundAlarm
  48. *        wsf_queryLastWorker
  49. *        wsf_setLastWorker
  50. *
  51. *     Overridden Instance Methods:
  52. *
  53. *        wsf_wpAddSettingsPages
  54. *        wsf_wpFilterPopupMenu
  55. *        wsf_wpInitData
  56. *        wsf_wpMenuItemHelpSelected
  57. *        wsf_wpMenuItemSelected
  58. *        wsf_wpModifyPopupMenu
  59. *        wsf_wpOpen
  60. *        wsf_wpQueryDetailsData
  61. *        wsf_wpRestoreState
  62. *        wsf_wpSaveState
  63. *        wsf_wpUnInitData
  64. *        wsf_wpFormatDragItem
  65. *        wsf_wpSetup
  66. *        wsf_wpSetupOnce
  67. *
  68. *     Non-Method Functions:
  69. *
  70. *        WSFILEInit
  71. *        WSFILEWndProc
  72. *        LastWorkerDlgProc
  73. *
  74. ******************************************************************************/
  75.  
  76. #define WSFILE_Class_Source
  77. #define M_WSFILE_Class_Source
  78.  
  79. #include "wsfile.ih"
  80. /* CSC2IDL:  REMOVED after .csc -> .idl conversion:  #include "wsfile.ph" */
  81.  
  82. #include <string.h>
  83. #include <stdio.h>
  84. #include <memory.h>
  85. #include <stdlib.h>
  86.  
  87. /*
  88.  *   Non-Method function prototypes
  89.  */
  90.  
  91. HWND             WSFILEInit (WSFILE*);
  92. MRESULT EXPENTRY LastWorkerDlgProc( HWND hwnd, ULONG msg,
  93.                                    MPARAM mp1, MPARAM mp2 );
  94. MRESULT EXPENTRY WSFILEWndProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  95.  
  96.  
  97. /***************** GLOBAL/STATIC (NON-INSTANCE) DATA SECTION ******************
  98. *****                                                                     *****
  99. *****    This data shouldn't be changed by instance methods or it will    *****
  100. *****    affect all instances!  Any variables that are specific (unique   *****
  101. *****    values) for each instance of this object should be declared as   *****
  102. *****  instance data or dynamically allocated and stored as window data.  *****
  103. *****                                                                     *****
  104. *****      This global data should be declared as class instance data     *****
  105. *****    if it will change after initialization.  In this case, it will   *****
  106. *****                  be accessed through class methods.                 *****
  107. *****                                                                     *****
  108. ******************************************************************************/
  109.  
  110.  
  111.    CHAR       szWSFILEWindowClass[] =    "WSFILESAMPLE";
  112.    CHAR       szHelpLibrary[] =       "wsfile.hlp";
  113.    UCHAR      szWSFILEClassTitle[CCHMAXPATH] = "";
  114.    HMODULE    hmod = NULLHANDLE;
  115.  
  116.    /*
  117.     *   Statics required for FIELDINFO structures needed for DETAILS view are
  118.     *   handled in the three functions:
  119.     *
  120.     *   wsf_wpclsInitData, wsf_wpQueryDetailsData, wsf_wpQueryClassDetailsInfo
  121.     */
  122.  
  123.    #define NUM_WSFILE_FIELDS    1
  124.  
  125.    CLASSFIELDINFO fieldinfo[NUM_WSFILE_FIELDS];      /* structure in wsfile.h */
  126.  
  127.    PSZ apszWSFILEColTitles[] =
  128.    {
  129.       "Last Worker"           /* details column 1 */
  130.    };
  131.  
  132.  
  133. /*************************  INSTANCE METHODS SECTION  *************************
  134. *****                                                                     *****
  135. *****              Do not put any code in this section unless             *****
  136. *****                   it is an object INSTANCE method                   *****
  137. *****                                                                     *****
  138. ******************************************************************************/
  139. #undef SOM_CurrentClass
  140. #define SOM_CurrentClass SOMInstance
  141.  
  142.  
  143. /*
  144.  *
  145.  *  METHOD: queryLastWorker                                ( ) PRIVATE
  146.  *                                                         (X) PUBLIC
  147.  *  DESCRIPTION:
  148.  *
  149.  *    Query name of last person to work with wsfile
  150.  *
  151.  *  RETURN:
  152.  *
  153.  *    PSZ            name of last person to work on file
  154.  *
  155.  */
  156. SOM_Scope PSZ   SOMLINK wsf_queryLastWorker(WSFILE *somSelf)
  157. {
  158.     WSFILEData *somThis = WSFILEGetData(somSelf);
  159.     WSFILEMethodDebug("WSFILE","wsf_queryLastWorker");
  160.  
  161.     return _pszLastWorker;
  162. } /* end wsf_queryLastWorker */
  163.  
  164. /*
  165.  *
  166.  *  METHOD: setLastWorker                                  ( ) PRIVATE
  167.  *                                                         (X) PUBLIC
  168.  *  DESCRIPTION:
  169.  *
  170.  *    Set name of last person to work with wsfile
  171.  *
  172.  *  RETURN:
  173.  *
  174.  *    BOOL     Successful
  175.  *
  176.  */
  177. /*
  178.  *
  179.  * METHOD: setLastWorker                                  ( ) PRIVATE
  180.  *                                                        (X) PUBLIC
  181.  * DESCRIPTION:
  182.  *
  183.  *   Set name of last person to work with wsfile
  184.  *
  185.  * RETURN:
  186.  *
  187.  *   TRUE           Brake is on
  188.  *   FALSE          Brake is off
  189.  *
  190.  */
  191.  
  192. SOM_Scope BOOL   SOMLINK wsf_setLastWorker(WSFILE *somSelf,
  193.                 PSZ pszWorkerName)
  194. {
  195.     BOOL rc = FALSE;
  196.  
  197.     WSFILEData *somThis = WSFILEGetData(somSelf);
  198.     WSFILEMethodDebug("WSFILE","wsf_setLastWorker");
  199.  
  200.     if (pszWorkerName)
  201.     {
  202.       if (_pszLastWorker)
  203.       {
  204.          _wpFreeMem(somSelf, (PBYTE) _pszLastWorker);
  205.          _pszLastWorker = (PSZ) _wpAllocMem(somSelf, strlen(pszWorkerName)+1, NULL);
  206.          strcpy(_pszLastWorker, pszWorkerName);
  207.          _wpCnrRefreshDetails(somSelf);
  208.          rc = TRUE;
  209.       }
  210.     }
  211.     return(rc);
  212.  
  213. } /* end wsf_setLastWorker */
  214.  
  215. /*
  216.  *
  217.  *  METHOD: soundAlarm                                     ( ) PRIVATE
  218.  *                                                         (X) PUBLIC
  219.  *  DESCRIPTION:
  220.  *
  221.  *    Sound an alarm
  222.  *
  223.  *  RETURN:
  224.  *
  225.  *    TRUE           Successful
  226.  *    FALSE          Unsuccessful
  227.  *
  228.  */
  229. SOM_Scope BOOL   SOMLINK wsf_soundAlarm(WSFILE *somSelf)
  230. {
  231.     WSFILEData *somThis = WSFILEGetData(somSelf);
  232.     WSFILEMethodDebug("WSFILE","wsf_soundAlarm");
  233.  
  234.     DosBeep(100,50);
  235.     DosSleep(100);
  236.     DosBeep(100,50);
  237.     DosSleep(100);
  238.     DosBeep(100,50);
  239.     DosSleep(100);
  240.     DosBeep(100,50);
  241.     DosSleep(100);
  242.     DosBeep(100,50);
  243.     DosSleep(300);
  244.     DosBeep(100, 100);
  245.     DosSleep(100);
  246.     DosBeep(100, 100);
  247.  
  248.     return TRUE;
  249. } /* end wsf_soundAlarm */
  250.  
  251. /*
  252.  *
  253.  *  METHOD: AddLastWorkerPage                              ( ) PRIVATE
  254.  *                                                         (X) PUBLIC
  255.  *  DESCRIPTION:
  256.  *
  257.  *    This method adds the Last Worker page to the settings notebook.
  258.  *
  259.  *  RETURN:
  260.  *
  261.  *    0              Unsuccessful
  262.  *    ulPageId       Identifier for the inserted page
  263.  *
  264.  *  HOW TO OVERRIDE:
  265.  *
  266.  *    Method should always be overridden in order to replace or remove
  267.  *    the last worker page from an object which is a descendent of wsfile.
  268.  *    In most cases, an override of this method will not call the parent.
  269.  *
  270.  */
  271. SOM_Scope ULONG   SOMLINK wsf_AddLastWorkerPage(WSFILE *somSelf,
  272.                 HWND hwndNotebook)
  273. {
  274.     PAGEINFO pageinfo;
  275.     ULONG versionData[2], dlgId;
  276.  
  277.     WSFILEData *somThis = WSFILEGetData(somSelf);
  278.     WSFILEMethodDebug("WSFILE","wsf_AddLastWorkerPage");
  279.  
  280.     DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MINOR, versionData, 8);
  281.     if ( (versionData[0] <= 20 ) && (versionData[1] < 40) )
  282.        dlgId = IDD_LASTWORKER;
  283.     else
  284.        dlgId = IDD_LASTWORKER2;
  285.  
  286.     memset((PCH)&pageinfo,0,sizeof(PAGEINFO));
  287.     pageinfo.cb                 = sizeof(PAGEINFO);
  288.     pageinfo.hwndPage           = NULLHANDLE;
  289.     pageinfo.usPageStyleFlags   = BKA_MAJOR;
  290.     pageinfo.usPageInsertFlags  = BKA_FIRST;
  291.     pageinfo.pfnwp              = LastWorkerDlgProc;
  292.     pageinfo.resid              = hmod;
  293.     pageinfo.dlgid              = dlgId;
  294.     pageinfo.pszName            = "LastWorker";
  295.     pageinfo.pCreateParams      = somSelf;
  296.     pageinfo.idDefaultHelpPanel = ID_HELP_LASTWORKER;
  297.     pageinfo.pszHelpLibraryName = szHelpLibrary;
  298.  
  299.     return _wpInsertSettingsPage( somSelf, hwndNotebook, &pageinfo );
  300.  
  301. }   /* end wsf_AddLastWorkerPage() */
  302.  
  303. /*
  304.  *
  305.  *  OVERRIDE: wpInitData                                   ( ) PRIVATE
  306.  *                                                         (X) PUBLIC
  307.  *  DESCRIPTION:
  308.  *
  309.  *    Initialize our state variables. Allocate any extra memory that
  310.  *    we might need.
  311.  *
  312.  */
  313. SOM_Scope void SOMLINK wsf_wpInitData(WSFILE *somSelf)
  314. {
  315.     WSFILEData *somThis = WSFILEGetData(somSelf);
  316.     WSFILEMethodDebug("WSFILE","wsf_wpInitData");
  317.  
  318.     parent_wpInitData(somSelf);
  319.  
  320.     _pszLastWorker = (PSZ) _wpAllocMem(somSelf, CCHMAXPATH+1, NULL);
  321.     if (_pszLastWorker)
  322.     {
  323.        strcpy(_pszLastWorker, DEFAULT_LASTWORKER);
  324.     }
  325.  
  326.  
  327. }   /* end wsf_wpInitData() */
  328.  
  329. /*
  330.  *
  331.  *  OVERRIDE: wpUnInitData                                 ( ) PRIVATE
  332.  *                                                         (X) PUBLIC
  333.  *  DESCRIPTION:
  334.  *
  335.  *    Clear up memory that was allocated on wpInitData.
  336.  *
  337.  */
  338. SOM_Scope void   SOMLINK wsf_wpUnInitData(WSFILE *somSelf)
  339. {
  340.     WSFILEData *somThis = WSFILEGetData(somSelf);
  341.     WSFILEMethodDebug("WSFILE","wsf_wpUnInitData");
  342.  
  343.     if (_pszLastWorker)
  344.     {
  345.       _wpFreeMem(somSelf, (PBYTE)_pszLastWorker);
  346.     }
  347.     parent_wpUnInitData(somSelf);
  348.  
  349. }   /* end wsf_wpUnInitData() */
  350.  
  351.  
  352. /*
  353.  *
  354.  *  METHOD: wpSaveState                                    ( ) PRIVATE
  355.  *                                                         (X) PUBLIC
  356.  *  DESCRIPTION:
  357.  *
  358.  *    Save our state variables (last worker).
  359.  *
  360.  */
  361. /*
  362.  *
  363.  * METHOD: wpSaveState                                    ( ) PRIVATE
  364.  *                                                        (X) PUBLIC
  365.  * DESCRIPTION:
  366.  *
  367.  *   Save our state variables (pitch and duration).
  368.  *
  369.  */
  370.  
  371. SOM_Scope BOOL SOMLINK wsf_wpSaveState(WSFILE *somSelf)
  372. {
  373.     WSFILEData *somThis = WSFILEGetData(somSelf);
  374.     WSFILEMethodDebug("WSFILE","wsf_wpSaveState");
  375.  
  376.     _wpSaveString( somSelf, szWSFILEClassTitle,
  377.                    IDKEY_LASTWORKER, _pszLastWorker);
  378.  
  379.     return (parent_wpSaveState(somSelf));
  380.  
  381. }   /* end wsf_wpSaveState() */
  382.  
  383. /*
  384.  *
  385.  *  METHOD: wpRestoreState                                 ( ) PRIVATE
  386.  *                                                         (X) PUBLIC
  387.  *  DESCRIPTION:
  388.  *
  389.  *    Retrieve our saved state variables (last worker).
  390.  *
  391.  */
  392. /*
  393.  *
  394.  * METHOD: wpRestoreState                                 ( ) PRIVATE
  395.  *                                                        (X) PUBLIC
  396.  * DESCRIPTION:
  397.  *
  398.  *   Retrieve our saved state variables (pitch and duration).
  399.  *
  400.  */
  401.  
  402. SOM_Scope BOOL SOMLINK wsf_wpRestoreState(WSFILE *somSelf, ULONG ulReserved)
  403. {
  404.     ULONG cbString;
  405.     WSFILEData *somThis = WSFILEGetData(somSelf);
  406.     WSFILEMethodDebug("WSFILE","wsf_wpRestoreState");
  407.  
  408.     _wpRestoreString( somSelf, szWSFILEClassTitle,
  409.                       IDKEY_LASTWORKER, _pszLastWorker, &cbString );
  410.  
  411.     return (parent_wpRestoreState(somSelf,ulReserved));
  412.  
  413. }   /* wsf_wpRestoreState() */
  414.  
  415. /*
  416.  *
  417.  *  METHOD: wpAddSettingsPages                             ( ) PRIVATE
  418.  *                                                         (X) PUBLIC
  419.  *  DESCRIPTION:
  420.  *
  421.  *    Add our own settings page to let the user modify the
  422.  *    last worker's name.
  423.  *
  424.  */
  425. /*
  426.  *
  427.  * METHOD: wpAddSettingsPages                             ( ) PRIVATE
  428.  *                                                        (X) PUBLIC
  429.  * DESCRIPTION:
  430.  *
  431.  *   Add our own settings page to let the user alter the pitch
  432.  *   and duration of the wsfile's beep.
  433.  *
  434.  */
  435.  
  436. SOM_Scope BOOL SOMLINK wsf_wpAddSettingsPages(WSFILE *somSelf, HWND hwndNotebook)
  437. {
  438.     WSFILEData *somThis = WSFILEGetData(somSelf);
  439.     WSFILEMethodDebug("WSFILE","wsf_wpAddSettingsPages");
  440.  
  441.     if (parent_wpAddSettingsPages(somSelf, hwndNotebook)
  442.              && _AddLastWorkerPage(somSelf, hwndNotebook))
  443.     {
  444.         return(TRUE);
  445.     }
  446.     else
  447.     {
  448.         DebugBox("wsf_wpAddSettingsPages", " Failed to add a settings page.");
  449.         return( FALSE );
  450.     }
  451.  
  452. }   /* wsf_wpAddSettingsPages() */
  453.  
  454. /*
  455.  *
  456.  *  METHOD: wpFilterPopupMenu                              ( ) PRIVATE
  457.  *                                                         (X) PUBLIC
  458.  *  DESCRIPTION:
  459.  *
  460.  *    Filter out any options from the context that don't apply,
  461.  *    (e.g. we take out "Create Shadow")
  462.  *
  463.  *  HOW TO OVERRIDE:
  464.  *
  465.  *    No restrictions.
  466.  *
  467.  */
  468. /*
  469.  *
  470.  * METHOD: wpFilterPopupMenu                              ( ) PRIVATE
  471.  *                                                        (X) PUBLIC
  472.  * DESCRIPTION:
  473.  *
  474.  *   Filter out any options from the context that don't apply.
  475.  *
  476.  * HOW TO OVERRIDE:
  477.  *
  478.  *   No restrictions.
  479.  *
  480.  */
  481.  
  482. SOM_Scope ULONG SOMLINK wsf_wpFilterPopupMenu(WSFILE *somSelf,
  483.                 ULONG ulFlags,
  484.                 HWND hwndCnr,
  485.                 BOOL fMultiSelect)
  486. {
  487.     WSFILEData *somThis = WSFILEGetData(somSelf);
  488.     WSFILEMethodDebug("WSFILE","wsf_wpFilterPopupMenu");
  489.  
  490.     /*
  491.      *   This method allows you to filter which menus to include in the
  492.      *   popup menu.  Note: wpclsQueryStyle is overridden to disallow
  493.      *   linking (creating shadow) as well.
  494.      */
  495.     return( parent_wpFilterPopupMenu(somSelf,ulFlags,hwndCnr,
  496.                     fMultiSelect) & ~CTXT_LINK );
  497.  
  498. }   /* end wsf_wpFilterPopupMenu() */
  499.  
  500. /*
  501.  *
  502.  *  METHOD: wpModifyPopupMenu                              ( ) PRIVATE
  503.  *                                                         (X) PUBLIC
  504.  *  DESCRIPTION:
  505.  *
  506.  *    Add our extra option to the context menu
  507.  *
  508.  */
  509. /*
  510.  *
  511.  * METHOD: wpModifyPopupMenu                              ( ) PRIVATE
  512.  *                                                        (X) PUBLIC
  513.  * DESCRIPTION:
  514.  *
  515.  *   Add our extra option to the context menu to beep the horn
  516.  *
  517.  */
  518.  
  519. SOM_Scope BOOL SOMLINK wsf_wpModifyPopupMenu(WSFILE *somSelf,
  520.                 HWND hwndMenu,
  521.                 HWND hwndCnr,
  522.                 ULONG iPosition)
  523. {
  524.     WSFILEData *somThis = WSFILEGetData(somSelf);
  525.     WSFILEMethodDebug("WSFILE","wsf_wpModifyPopupMenu");
  526.  
  527.     /*
  528.      *   Put in our special "open wsfile" submenu item under the "open" menu
  529.      */
  530.     _wpInsertPopupMenuItems( somSelf, hwndMenu, 0,
  531.                                hmod, ID_OPENMENU, WPMENUID_OPEN);
  532.     /*
  533.      *   insert a "beep horn" menu item at the end of the list.
  534.      */
  535.     _wpInsertPopupMenuItems( somSelf, hwndMenu, iPosition,
  536.                                hmod, ID_ALARMMENU, 0 );
  537.  
  538.     return (parent_wpModifyPopupMenu(somSelf,hwndMenu,hwndCnr,iPosition));
  539.  
  540. }   /* end wsf_wpModifyPopupMenu() */
  541.  
  542. /*
  543.  *
  544.  *  METHOD: wpMenuItemSelected                             ( ) PRIVATE
  545.  *                                                         (X) PUBLIC
  546.  *  DESCRIPTION:
  547.  *
  548.  *    Process the extra menu options that we added.
  549.  *
  550.  */
  551. /*
  552.  *
  553.  * METHOD: wpMenuItemSelected                             ( ) PRIVATE
  554.  *                                                        (X) PUBLIC
  555.  * DESCRIPTION:
  556.  *
  557.  *   Process input from the extra menu option that we added.
  558.  *
  559.  */
  560.  
  561. SOM_Scope BOOL SOMLINK wsf_wpMenuItemSelected(WSFILE *somSelf,
  562.                 HWND hwndFrame,
  563.                 ULONG MenuId)
  564. {
  565.     WSFILEData *somThis = WSFILEGetData(somSelf);
  566.     WSFILEMethodDebug("WSFILE","wsf_wpMenuItemSelected");
  567.  
  568.     /* Which of our menu items was selected ?
  569.      */
  570.     switch( MenuId )
  571.     {
  572.        case IDM_OPENWSFILE:
  573.           /*
  574.            *   We could call wpOpen here, but, if the object is already opened,
  575.            *   the following API determines whether the object should be
  576.            *   resurfaced, or if multiple views are desired.
  577.            */
  578.           _wpViewObject(somSelf, NULLHANDLE, OPEN_WSFILE, 0);
  579.           break;
  580.  
  581.        case IDM_SOUNDALARM:
  582.           _soundAlarm(somSelf);
  583.           break;
  584.  
  585.        default:
  586.           return parent_wpMenuItemSelected(somSelf, hwndFrame, MenuId);
  587.           break;
  588.     }
  589.     return TRUE;                                          /* we processed it */
  590.  
  591. }   /* end wsf_wpMenuItemSelected() */
  592.  
  593. /*
  594.  *
  595.  *  METHOD: wpMenuItemHelpSelected                         ( ) PRIVATE
  596.  *                                                         (X) PUBLIC
  597.  *  DESCRIPTION:
  598.  *
  599.  *    Process help from the extra menu options that we added.
  600.  *
  601.  */
  602. /*
  603.  *
  604.  * METHOD: wpMenuItemHelpSelected                         ( ) PRIVATE
  605.  *                                                        (X) PUBLIC
  606.  * DESCRIPTION:
  607.  *
  608.  *   Process input from the extra menu option that we added.
  609.  *
  610.  */
  611.  
  612. SOM_Scope BOOL SOMLINK wsf_wpMenuItemHelpSelected(WSFILE *somSelf,
  613.                 ULONG MenuId)
  614. {
  615.     WSFILEData *somThis = WSFILEGetData(somSelf);
  616.     WSFILEMethodDebug("WSFILE","wsf_wpMenuItemHelpSelected");
  617.  
  618.     /* Which of our menu items was selected ?
  619.      */
  620.    switch( MenuId )
  621.    {
  622.       case IDM_SOUNDALARM:
  623.  
  624.          return(_wpDisplayHelp(somSelf,ID_HELP_SOUNDALARM,szHelpLibrary));
  625.          break;
  626.  
  627.       case IDM_OPENWSFILE:
  628.  
  629.          return(_wpDisplayHelp(somSelf,ID_HELP_OPENWSFILE,szHelpLibrary));
  630.          break;
  631.  
  632.       default:
  633.          break;
  634.    }
  635.  
  636.    return (parent_wpMenuItemHelpSelected(somSelf,MenuId));
  637.  
  638. }   /* end wsf_wpMenuItemHelpSelected() */
  639.  
  640. /*
  641.  *
  642.  *  METHOD: wpQueryDetailsData                             ( ) PRIVATE
  643.  *                                                         (X) PUBLIC
  644.  *  DESCRIPTION:
  645.  *
  646.  *    Returns the wsfile specific data for the details view of this object.
  647.  *    Sets the pointer (*ppDetailsData) to the beginning of the buffer
  648.  *    into which the data is written.
  649.  *
  650.  */
  651. SOM_Scope ULONG SOMLINK wsf_wpQueryDetailsData(WSFILE *somSelf,
  652.                 PVOID *ppDetailsData,
  653.                 PULONG pcp)
  654. {
  655.     PWSFILEDETAILS pWSFILEDetails;
  656.     PBYTE       pSize;
  657.     WSFILEData *somThis = WSFILEGetData(somSelf);
  658.     WSFILEMethodDebug("WSFILE","wsf_wpQueryDetailsData");
  659.  
  660.    parent_wpQueryDetailsData(somSelf,ppDetailsData, pcp);
  661.  
  662.    if (ppDetailsData)                                          /* query data */
  663.    {
  664.       pWSFILEDetails                  = (PWSFILEDETAILS) *ppDetailsData;
  665.       pWSFILEDetails->pszLastWorker   = _queryLastWorker(somSelf);
  666.  
  667.       /* point to buffer location after our details data */
  668.       *ppDetailsData = ((PBYTE) (*ppDetailsData)) + sizeof(*pWSFILEDetails);
  669.  
  670.    }   /* end if (ppDetailsData) */
  671.    else                                                /* query size of data */
  672.    {
  673.       *pcp += sizeof(*pWSFILEDetails);     /* caller is querying size of buffer */
  674.    }
  675.  
  676.    return(TRUE);
  677.  
  678. }   /* end wsf_wpQueryDetailsData() */
  679.  
  680. /*
  681.  *
  682.  *   METHOD: wpOpen                                         ( ) PRIVATE
  683.  *                                                          (X) PUBLIC
  684.  *   DESCRIPTION:
  685.  *
  686.  *     Opens the wsfile window.
  687.  *
  688.  */
  689. SOM_Scope HWND SOMLINK wsf_wpOpen(WSFILE *somSelf,
  690.                 HWND hwndCnr,
  691.                 ULONG ulView,
  692.                 ULONG param)
  693. {
  694.  WSFILEData *somThis = WSFILEGetData(somSelf);
  695.  WSFILEMethodDebug("WSFILE","wsf_wpOpen");
  696.  
  697.    switch (ulView)
  698.    {
  699.       case OPEN_WSFILE:
  700.  
  701.           /*
  702.            *   Create a basic Frame and Client window for this instance.
  703.            */
  704.          return WSFILEInit(somSelf);
  705.  
  706.       default:
  707.          return parent_wpOpen(somSelf,hwndCnr,ulView,param);
  708.  
  709.    }   /* end switch (ulView) */
  710.  
  711. }   /* end wsf_wpOpen() */
  712.  
  713.  
  714.  
  715. /*
  716.  *
  717.  *  METHOD: wpSetupOnce                                    ( ) PRIVATE
  718.  *                                                         (X) PUBLIC
  719.  *  DESCRIPTION:
  720.  *
  721.  *    Specify ONE TIME initialization.  This method is
  722.  *    invoked once on an object when it is initially created.
  723.  *
  724.  *    The one time initialization we're doing is to write
  725.  *    some default data to the file
  726.  */
  727. /*
  728.  *
  729.  *
  730.  *  METHOD: wpSetupOnce                                    ( ) PRIVATE
  731.  *                                                         (X) PUBLIC
  732.  *  DESCRIPTION:
  733.  *
  734.  *    Specify ONE TIME initialization.  This method is
  735.  *    invoked once on an object when it is initially created.
  736.  *
  737.  *    The one time initialization we're doing is to write
  738.  *    some default data to the file
  739.  */
  740.  
  741. SOM_Scope BOOL   SOMLINK wsf_wpSetupOnce(WSFILE *somSelf,
  742.                 PSZ pszSetupString)
  743. {
  744.     WSFILEData *somThis = WSFILEGetData(somSelf);
  745.     ULONG  cbBytesWritten;         /* pointer to variable receiving byte count */
  746.     APIRET rc;
  747.     BOOL   fSuccess;
  748.     HFILE  hf;                          /* pointer to variable for file handle */
  749.     ULONG  ulAction;                   /* pointer to variable for action taken */
  750.     CHAR   szObjectFilename[CCHMAXPATH];       /* buffer for wpQueryRealName() */
  751.     ULONG  cb  = sizeof(szObjectFilename);
  752.     PSZ    pszDefaultText;
  753.  
  754.     WSFILEMethodDebug("WSFILE","wsf_wpSetupOnce");
  755.  
  756.    /*
  757.     *   When the object is created from scratch, put some default
  758.     *   text into the file on the hard disk
  759.     */
  760.  
  761.    fSuccess =
  762.    _wpQueryRealName(                 /* query full-pathname of object's file */
  763.       somSelf,                                     /* pointer to this object */
  764.       szObjectFilename,                                     /* return buffer */
  765.       &cb,                                                  /* sizeof buffer */
  766.       TRUE);                            /* request fully qualified pathname? */
  767.  
  768.    if (fSuccess)
  769.    {
  770.       rc =
  771.       DosOpen(szObjectFilename, &hf, &ulAction,
  772.          0,                             /* file size if created or truncated */
  773.          FILE_NORMAL,                                      /* file attribute */
  774.          FILE_OPEN             /* action taken if file exists/does not exist */
  775.             | FILE_CREATE,
  776.          OPEN_ACCESS_READWRITE                          /* open mode of file */
  777.             | OPEN_SHARE_DENYNONE,
  778.          NULL);              /* pointer to structure for extended attributes */
  779.  
  780.       if (rc)
  781.       {
  782.        CHAR ach[10];
  783.  
  784.          _ltoa(rc, ach, 10);
  785.          DebugBox("wsf_wpSetup:DosOpen failed rc =", ach);
  786.       }
  787.       else
  788.       {
  789.          pszDefaultText = _clsQueryDefaultFileText(_WSFILE);
  790.          DosWrite(hf, pszDefaultText, strlen(pszDefaultText), &cbBytesWritten);
  791.          DosClose(hf);
  792.       }
  793.    }   /* end if (fSuccess) */
  794.  
  795.    return parent_wpSetupOnce(somSelf,pszSetupString);
  796.  
  797. }   /* end wsf_wpSetupOnce() */
  798.  
  799.  
  800. /*
  801.  *
  802.  *  METHOD: wpSetup                                        ( ) PRIVATE
  803.  *                                                         (X) PUBLIC
  804.  *  DESCRIPTION:
  805.  *
  806.  *    Specify Setup strings to do special one time processing
  807.  *
  808.  *  New key\value to be parsed and processed by this override:
  809.  *
  810.  *             SOUND=(YES/NO)   YES will invoke _soundAlarm method
  811.  *                              NO  will do nothing
  812.  *
  813.  */
  814. /*
  815.  *
  816.  * METHOD: wpSetup                                        ( ) PRIVATE
  817.  *                                                        (X) PUBLIC
  818.  * DESCRIPTION:
  819.  *
  820.  *   Specify Setup strings to do special setup string processing
  821.  *
  822.  *   New Key/Value to be parsed and processed by this override:
  823.  *
  824.  *             SOUND=(YES/NO)   YES will invoke _soundAlarm method
  825.  *                              NO  will do nothing
  826.  */
  827.  
  828. SOM_Scope BOOL   SOMLINK wsf_wpSetup(WSFILE *somSelf,
  829.                 PSZ pszSetupString)
  830. {
  831.     WSFILEData *somThis = WSFILEGetData(somSelf);
  832.     BOOL   rcParentCall;
  833.     CHAR   szValue[CCHMAXPATH+1];
  834.     ULONG  cbBuffer;
  835.  
  836.     WSFILEMethodDebug("WSFILE","wsf_wpSetup");
  837.  
  838.    rcParentCall = parent_wpSetup(somSelf,pszSetupString);
  839.  
  840.    cbBuffer = CCHMAXPATH;
  841.    if ( _wpScanSetupString(somSelf,pszSetupString,"SOUND",
  842.                            szValue,&cbBuffer) )
  843.    {
  844.       if ((szValue[0] == 'Y') && (szValue[1] == 'E') && (szValue[2] == 'S'))
  845.       {
  846.          _soundAlarm(somSelf);
  847.       }
  848.    }
  849.  
  850.   return rcParentCall;
  851.  
  852. }   /* end wsf_wpSetup() */
  853.  
  854.  
  855. /*
  856.  * METHOD: wpFormatDragItem                              ( ) PRIVATE
  857.  *                                                       (X) PUBLIC
  858.  * DESCRIPTION:
  859.  *
  860.  *   Specify a unique RMF that will only be understood by instances
  861.  *   of class WSFOLDER.  (see _wpDragOver and _wpDrop overrides in
  862.  *   wsfolder.c).
  863.  */
  864. /*
  865.  *
  866.  * METHOD: wpFormatDragItem                               ( ) PRIVATE
  867.  *                                                        (X) PUBLIC
  868.  * DESCRIPTION:
  869.  *
  870.  *   Specify a unique RMF that will only be understood by instances
  871.  *   of class WSFOLDER.  (see _wpDragOver and _wpDrop overrides in
  872.  *   wsfolder.c).
  873.  *
  874.  */
  875.  
  876. SOM_Scope BOOL   SOMLINK wsf_wpFormatDragItem(WSFILE *somSelf,
  877.                 PDRAGITEM pdrgItem)
  878. {
  879. /*  WSFILEData *somThis = WSFILEGetData(somSelf); */
  880.     WSFILEMethodDebug("WSFILE","wsf_wpFormatDragItem");
  881.  
  882.     parent_wpFormatDragItem(somSelf,pdrgItem);
  883.  
  884.     /* We do NOT want to really let the workplace shell render
  885.      * our object, so change the rendering mechanism and format
  886.      * to be uniquely ours.
  887.      */
  888.     DrgDeleteStrHandle(pdrgItem->hstrRMF);
  889.  
  890.     pdrgItem->hstrRMF = DrgAddStrHandle("<DRM_OUROWNSPECIAL,DRF_OBJECT>");
  891.  
  892.     return TRUE;
  893. }
  894.  
  895.  
  896. /**************************  CLASS METHODS SECTION  ***************************
  897. *****                                                                     *****
  898. *****              Do not put any code in this section unless             *****
  899. *****                     it is an object CLASS method                    *****
  900. *****                                                                     *****
  901. ******************************************************************************/
  902. #undef SOM_CurrentClass
  903. #define SOM_CurrentClass SOMMeta
  904.  
  905.  
  906. /*
  907.  *
  908.  *  METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  909.  *                                                         (X) PUBLIC
  910.  *  DESCRIPTION:
  911.  *
  912.  *    This method returns the module handle of this class.  If this is the
  913.  *    first invocation, DosQueryModuleHandle is called to save the handle
  914.  *    for future invocations.
  915.  *
  916.  *  RETURN:
  917.  *
  918.  *    0              Unsuccessful
  919.  *    non-zero       module handle
  920.  *
  921.  */
  922. SOM_Scope HMODULE   SOMLINK wsfM_clsQueryModuleHandle(M_WSFILE *somSelf)
  923. {
  924.  APIRET rc;
  925.  
  926.     /* M_WSFILEData *somThis = M_WSFILEGetData(somSelf); */
  927.     M_WSFILEMethodDebug("M_WSFILE","wsfM_clsQueryModuleHandle");
  928.  
  929.    /*
  930.     *   Make sure we already have module handle
  931.     */
  932.  
  933.     if (hmod == NULLHANDLE)
  934.     {
  935.      zString zsPathName;
  936.        /*
  937.         *   Retrieve registered pathname of our module (DLL) and query the
  938.         *   module handle.
  939.         */
  940.        zsPathName =
  941.        _somLocateClassFile( SOMClassMgrObject, SOM_IdFromString("WSFILE"),
  942.                                               WSFILE_MajorVersion, WSFILE_MinorVersion);
  943.        rc =
  944.        DosQueryModuleHandle( zsPathName, &hmod);
  945.        if (rc)
  946.        {
  947.           DebugBox("wsfM_wpclsInitData", "Failed to load module");
  948.           return;
  949.        }
  950.  
  951.     }   /* end if (hmod == NULLHANDLE) */
  952.  
  953.     return (hmod);
  954.  
  955. }   /* end wsfM_clsQueryModuleHandle() */
  956.  
  957.  
  958.  
  959. /*
  960.  *
  961.  *  METHOD: clsQueryDefaultFileText                        ( ) PRIVATE
  962.  *                                                         (X) PUBLIC
  963.  *  DESCRIPTION:
  964.  *
  965.  *    This method returns some default text to stuff in an empty WSFILE.
  966.  *
  967.  *  RETURN:
  968.  *
  969.  *    PSZ
  970.  *
  971.  */
  972. SOM_Scope PSZ   SOMLINK wsfM_clsQueryDefaultFileText(M_WSFILE *somSelf)
  973. {
  974.     /* M_WSFILEData *somThis = M_WSFILEGetData(somSelf); */
  975.     M_WSFILEMethodDebug("M_WSFILE","wsfM_clsQueryDefaultFileText");
  976.  
  977.     return (PSZ) "This is an empty file of class WSFILE";
  978. } /* end wsfM_clsQueryDefaultFileText */
  979.  
  980. /*
  981.  *
  982.  *  METHOD: wpclsQueryStyle                                ( ) PRIVATE
  983.  *                                                         (X) PUBLIC
  984.  *  DESCRIPTION:
  985.  *
  986.  *     The wpclsQueryStyle method is called to allow the class object
  987.  *     to specify the default object class style for its instances.
  988.  *
  989.  *  REMARKS:
  990.  *
  991.  *     This method can be called at any time in order to determine the
  992.  *     default style for instances of this class.
  993.  *
  994.  *     This method should be overridden in order to modify the default
  995.  *     object style for instances of this class.
  996.  *
  997.  */
  998. SOM_Scope ULONG   SOMLINK wsfM_wpclsQueryStyle(M_WSFILE *somSelf)
  999. {
  1000.     /* M_WSFILEData *somThis = M_WSFILEGetData(somSelf); */
  1001.     M_WSFILEMethodDebug("M_WSFILE","wsfM_wpclsQueryStyle");
  1002.  
  1003.     /*
  1004.      *   Modify style bits as described in programming reference.  This
  1005.      *   particular style (link) is also disabled in wpFilterPopupMenu()
  1006.      */
  1007.     return (parent_wpclsQueryStyle(somSelf) | CLSSTYLE_NEVERLINK );
  1008. }
  1009.  
  1010. /*
  1011.  *
  1012.  *  METHOD: wpclsInitData                                  ( ) PRIVATE
  1013.  *                                                         (X) PUBLIC
  1014.  *  DESCRIPTION:
  1015.  *
  1016.  *    Initalize the class data
  1017.  *
  1018.  */
  1019. /*
  1020.  *
  1021.  * METHOD: wpclsInitData
  1022.  *
  1023.  * DESCRIPTION:
  1024.  *
  1025.  *   Initalize the class data
  1026.  *
  1027.  */
  1028.  
  1029. SOM_Scope void SOMLINK wsfM_wpclsInitData(M_WSFILE *somSelf)
  1030. {
  1031.  ULONG rc, i;
  1032.  PCLASSFIELDINFO pCFI;
  1033.  
  1034.     /* M_WSFILEData *somThis  = M_WSFILEGetData(somSelf); */
  1035.     M_WSFILEMethodDebug("M_WSFILE","wsfM_wpclsInitData");
  1036.  
  1037.     /*
  1038.      *   Call the parent class method first
  1039.      */
  1040.     parent_wpclsInitData(somSelf);
  1041.  
  1042.     /*
  1043.      *   Get class title
  1044.      */
  1045.     if (!WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), _clsQueryModuleHandle(somSelf), ID_TITLE,
  1046.                          sizeof(szWSFILEClassTitle), szWSFILEClassTitle))
  1047.                               /* Load string failed: use the parent's string */
  1048.        strcpy(szWSFILEClassTitle, parent_wpclsQueryTitle(somSelf));
  1049.  
  1050.    /*
  1051.     *   Initialize everything needed for the CLASSFIELDINFO structures
  1052.     *   for the WSFILE object class
  1053.     */
  1054.  
  1055.    for (i=0, pCFI=fieldinfo; i < NUM_WSFILE_FIELDS; i++, pCFI++)
  1056.    {
  1057.       memset((PCH) pCFI, 0, sizeof(CLASSFIELDINFO));               /* zero's */
  1058.  
  1059.       pCFI->cb        = sizeof(CLASSFIELDINFO);
  1060.       pCFI->flData    = CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
  1061.       pCFI->flTitle   = CFA_CENTER | CFA_SEPARATOR | CFA_HORZSEPARATOR |
  1062.                         CFA_STRING | CFA_FITITLEREADONLY;
  1063.       pCFI->pNextFieldInfo = pCFI + 1;       /* point to next CLASSFIELDINFO */
  1064.       pCFI->pTitleData = (PVOID) apszWSFILEColTitles[i];
  1065.       pCFI->flCompare  = COMPARE_SUPPORTED | SORTBY_SUPPORTED;
  1066.  
  1067.       switch (i)
  1068.       {
  1069.          case INDEX_LASTWORKER:
  1070.  
  1071.             pCFI->flData           |= CFA_STRING;
  1072.             pCFI->offFieldData      = (ULONG)(FIELDOFFSET(WSFILEDETAILS,pszLastWorker));
  1073.             pCFI->ulLenFieldData    = sizeof(PSZ);
  1074.             pCFI->DefaultComparison = CMP_EQUAL;
  1075.  
  1076.             break;
  1077.  
  1078.       }   /* end switch(i) */
  1079.  
  1080.    }   /* end for (i=0, pCFI=fieldinfo; i < NUM_WSFILE_FIELDS; i++, pCFI++)  */
  1081.  
  1082.    fieldinfo[NUM_WSFILE_FIELDS-1].pNextFieldInfo = NULL;/* terminate linked list */
  1083.  
  1084. }   /* end wsfM_ wpclsInitData() */
  1085.  
  1086. /*
  1087.  *
  1088.  *  METHOD: wpclsUnInitData                                ( ) PRIVATE
  1089.  *                                                         (X) PUBLIC
  1090.  *  DESCRIPTION:
  1091.  *
  1092.  *    Free any class data
  1093.  *
  1094.  */
  1095. /*
  1096.  *
  1097.  * METHOD: wpclsUnInitData
  1098.  *
  1099.  * DESCRIPTION:
  1100.  *
  1101.  *   Free any class data
  1102.  *
  1103.  */
  1104.  
  1105. SOM_Scope void SOMLINK wsfM_wpclsUnInitData(M_WSFILE *somSelf)
  1106. {
  1107.     M_WSFILEMethodDebug("M_WSFILE","wsfM_wpclsUnInitData");
  1108.  
  1109.     parent_wpclsUnInitData(somSelf);
  1110.  
  1111. }   /* end wsfM_wpclsUnInitData() */
  1112.  
  1113. /*
  1114.  *
  1115.  *  METHOD: wpclsQueryTitle                                ( ) PRIVATE
  1116.  *                                                         (X) PUBLIC
  1117.  *  DESCRIPTION:
  1118.  *
  1119.  *    Return the string "wsfile".
  1120.  *
  1121.  */
  1122. /*
  1123.  *
  1124.  * METHOD: wpclsQueryTitle                                ( ) PRIVATE
  1125.  *                                                        (X) PUBLIC
  1126.  * DESCRIPTION:
  1127.  *
  1128.  *   Return the string "New MyFile".
  1129.  *
  1130.  */
  1131.  
  1132. SOM_Scope PSZ SOMLINK wsfM_wpclsQueryTitle(M_WSFILE *somSelf)
  1133. {
  1134.  /* M_WSFILEData *somThis = M_WSFILEGetData(somSelf); */
  1135.     M_WSFILEMethodDebug("M_WSFILE","wsfM_wpclsQueryTitle");
  1136.  
  1137.     /*
  1138.      *   Return the class title for a wsfile
  1139.      */
  1140.  
  1141.     if (*szWSFILEClassTitle )
  1142.        return( szWSFILEClassTitle );
  1143.     else
  1144.        return( parent_wpclsQueryTitle(somSelf));
  1145.  
  1146. }   /* end wsfM_wpclsQueryTitle() */
  1147.  
  1148. /*
  1149.  *
  1150.  *  METHOD: wpclsQueryIconDdata                            ( ) PRIVATE
  1151.  *                                                         (X) PUBLIC
  1152.  *  DESCRIPTION:
  1153.  *
  1154.  *    Return the class icon
  1155.  *
  1156.  */
  1157. SOM_Scope ULONG SOMLINK wsfM_wpclsQueryIconData(M_WSFILE *somSelf,
  1158.                   PICONINFO pIconInfo)
  1159. {
  1160.    APIRET rc;
  1161.  
  1162.    M_WSFILEMethodDebug("M_WSFILE","wsfM_wpclsQueryIconData");
  1163.  
  1164.    if (pIconInfo)
  1165.    {
  1166.       /*
  1167.        *   fill in icon information
  1168.        */
  1169.       pIconInfo->fFormat = ICON_RESOURCE;
  1170.       pIconInfo->hmod= _clsQueryModuleHandle(somSelf);
  1171.       pIconInfo->resid= ID_ICON;
  1172.    }
  1173.  
  1174.    return (sizeof(ICONINFO));
  1175.  
  1176. }   /* end wsfM_wpclsQueryIconData() */
  1177.  
  1178. /*
  1179.  *
  1180.  *  METHOD: wpclsQueryDefaultHelp                          ( ) PRIVATE
  1181.  *                                                         (X) PUBLIC
  1182.  *  DESCRIPTION:
  1183.  *
  1184.  *    Process input from the extra menu option that we added.
  1185.  *
  1186.  */
  1187. SOM_Scope BOOL SOMLINK wsfM_wpclsQueryDefaultHelp(M_WSFILE *somSelf,
  1188.                 PULONG pHelpPanelId,
  1189.                 PSZ pszHelpLibrary)
  1190. {
  1191.  /* M_WSFILEData *somThis = M_WSFILEGetData(somSelf); */
  1192.     M_WSFILEMethodDebug("M_WSFILE","wsfM_wpclsQueryDefaultHelp");
  1193.  
  1194.     if (pHelpPanelId)                           /* set default help panel id */
  1195.        *pHelpPanelId   = ID_HELP_DEFAULT;
  1196.  
  1197.     if (pszHelpLibrary)                                /* copy help filename */
  1198.        strcpy(pszHelpLibrary, szHelpLibrary);
  1199.  
  1200.     return (TRUE);
  1201.  
  1202. }   /* end wsfM_wpclsQueryDefaultHelp() */
  1203.  
  1204. /*
  1205.  *
  1206.  *  METHOD: wpclsQueryDefaultView                          ( ) PRIVATE
  1207.  *                                                         (X) PUBLIC
  1208.  *  DESCRIPTION:
  1209.  *
  1210.  *    Returns the default view for a new instance of this object.
  1211.  *
  1212.  *  REMARKS:
  1213.  *
  1214.  *    Tell the system what our default open view is...
  1215.  *
  1216.  */
  1217. SOM_Scope ULONG SOMLINK wsfM_wpclsQueryDefaultView(M_WSFILE *somSelf)
  1218. {
  1219.  /* M_WSFILEData *somThis = M_WSFILEGetData(somSelf); */
  1220.     M_WSFILEMethodDebug("M_WSFILE","wsfM_wpclsQueryDefaultView");
  1221.  
  1222.     return OPEN_WSFILE;
  1223.  
  1224. }   /* end wsfM_wpclsQueryDefaultView() */
  1225.  
  1226. /*
  1227.  *
  1228.  *  METHOD: wpclsQueryDetailsInfo                          ( ) PRIVATE
  1229.  *                                                         (X) PUBLIC
  1230.  *  DESCRIPTION:
  1231.  *
  1232.  *    Appends the wsfile specific chain of FIELDINFO structures describing the
  1233.  *    details data of this object to *ppClassFieldInfo (if ppClassFieldInfo
  1234.  *    is NON-NULL).  In this case it also sets *ppClassFieldInfo to the
  1235.  *    head of the linked list.
  1236.  *
  1237.  *    Adds the number of bytes required by the details data for wsfile to *pSize
  1238.  *    (if pSize is NON-NULL).
  1239.  *
  1240.  *  REMARKS:
  1241.  *
  1242.  *    Add details data for this object.
  1243.  *
  1244.  */
  1245. /*
  1246.  *
  1247.  * METHOD: wpclsQueryDetailsInfo                          ( ) PRIVATE
  1248.  *                                                        (X) PUBLIC
  1249.  * DESCRIPTION:
  1250.  *
  1251.  *   Appends the wsfile specific chain of FIELDINFO structures describing the
  1252.  *   details data of this object to *ppDetailsData (if ppDetailsData
  1253.  *   is NON-NULL).  In this case it also sets *ppDetailsData to the
  1254.  *   head of the linked list.
  1255.  *
  1256.  *   Adds the number of bytes required by the details data for wsfile to *pSize
  1257.  *   (if pSize is NON-NULL).
  1258.  *
  1259.  * REMARKS:
  1260.  *
  1261.  *   Add details data for this object.
  1262.  *
  1263.  * From WPFileSystem
  1264.  */
  1265.  
  1266. SOM_Scope ULONG SOMLINK wsfM_wpclsQueryDetailsInfo(M_WSFILE *somSelf,
  1267.                 PCLASSFIELDINFO *ppClassFieldInfo,
  1268.                 PULONG pSize)
  1269. {
  1270.  ULONG           cParentColumns;
  1271.  PCLASSFIELDINFO pCFI;
  1272.  ULONG           i;
  1273.  
  1274.     /* M_WSFILEData *somThis = M_WSFILEGetData(somSelf); */
  1275.     M_WSFILEMethodDebug("M_WSFILE","wsfM_wpclsQueryDetailsInfo");
  1276.  
  1277.    /*
  1278.     *   Always call the parent method first to retrieve number of details
  1279.     *   columns and parent's data already defined in details buffer.
  1280.     */
  1281.  
  1282.    cParentColumns =
  1283.    parent_wpclsQueryDetailsInfo(somSelf, ppClassFieldInfo, pSize);
  1284.  
  1285.    /*
  1286.     *   If pSize is non-NULL, we must add the size of our deatils column
  1287.     *   data structure.
  1288.     */
  1289.  
  1290.    if (pSize)
  1291.       *pSize += sizeof(WSFILEDETAILS);                           /* adjust size */
  1292.  
  1293.    /*
  1294.     *   If the request was for the chained fieldinfo structures
  1295.     *   (ppClassFieldInfo is non-NULL), link them in
  1296.     *
  1297.     *   eventually the chain will look like
  1298.     *
  1299.     *   Grandad - Dad - Me - Kid - Grandkid
  1300.     *
  1301.     *   I will be getting the pointer to the beginning of the chain
  1302.     *
  1303.     *   If the beginning of the chain is 0, I will assign the address
  1304.     *   of my first CLASSFIELDINFO structure to *ppClassFieldInfo.
  1305.     *   Otherwise *pp points to the first column description in the
  1306.     *   chain.  We need to walk the chain and link our CLASSFIELDINFO
  1307.     *   structures at the end.
  1308.     */
  1309.  
  1310.    if (ppClassFieldInfo)
  1311.    {
  1312.       /*
  1313.        *   Find the last link in the chain;  Then link our CLASSFIELDINFO
  1314.        *   structures to the chain.
  1315.        */
  1316.  
  1317.       if (*ppClassFieldInfo)
  1318.       {
  1319.          pCFI = *ppClassFieldInfo;
  1320.          for (i=0;i<cParentColumns;i++)
  1321.             pCFI = (pCFI->pNextFieldInfo) ? pCFI->pNextFieldInfo : pCFI;
  1322.  
  1323.          pCFI->pNextFieldInfo = fieldinfo;
  1324.       }
  1325.       else
  1326.          *ppClassFieldInfo = fieldinfo;
  1327.    }
  1328.    return ((ULONG) (cParentColumns + NUM_WSFILE_FIELDS));
  1329.  
  1330. }   /* end wsfM_wpclsQueryDetailsInfo() */
  1331.  
  1332.  
  1333. /**************************  ORDINARY CODE SECTION  ***************************
  1334. *****                                                                     *****
  1335. *****                  Any non-method code should go here.                *****
  1336. *****                                                                     *****
  1337. ******************************************************************************/
  1338. #undef SOM_CurrentClass
  1339.  
  1340.  
  1341. /***************************************************************************
  1342. *                                                                          *
  1343. *       ROUTINE:    WSFILEInit ( )                                            *
  1344. *                                                                          *
  1345. *       DESCRIPTION:    WSFILE Initialization                                 *
  1346. *                                                                          *
  1347. *       RETURNS:    Handle of wsfile frame window, NULL if error              *
  1348. *                                                                          *
  1349. ***************************************************************************/
  1350. HWND WSFILEInit (WSFILE* somSelf)
  1351. {
  1352.    HAB  hab;                                       /* PM anchor block handle */
  1353.    HWND hwndFrame = NULLHANDLE;                       /* Frame window handle */
  1354.    HWND hwndClient = NULLHANDLE;
  1355.    PWINDOWDATA pWindowData;
  1356.    BOOL fSuccess;
  1357.    SWCNTRL    swcEntry;                                      /* Switch Entry */
  1358.    FRAMECDATA flFrameCtlData;                              /* Frame Ctl Data */
  1359.  
  1360.    hab = WinQueryAnchorBlock(HWND_DESKTOP);
  1361.    if (!WinRegisterClass( hab , szWSFILEWindowClass, (PFNWP)WSFILEWndProc ,
  1362.                             CS_SIZEREDRAW | CS_SYNCPAINT, sizeof(pWindowData)))
  1363.    {
  1364.       DebugBox("WSFILEInit", "Failure in WinRegisterClass");
  1365.       return NULLHANDLE ;
  1366.    }
  1367.  
  1368.    /*
  1369.     *   Allocate some instance specific data in Window words of Frame window.
  1370.     *   This will ensure our window procedure can use this object's methods
  1371.     *   (our window proc isn't passed a * somSelf pointer).
  1372.     */
  1373.    pWindowData = (PWINDOWDATA) _wpAllocMem(somSelf, sizeof(*pWindowData), NULL);
  1374.  
  1375.    if (!pWindowData)
  1376.    {
  1377.       DebugBox("WSFILEInit", "wpAllocMem failed to allocate pWindowData");
  1378.       return NULLHANDLE;
  1379.    }
  1380.  
  1381.    memset((PVOID) pWindowData, 0, sizeof(*pWindowData));
  1382.    pWindowData->cb = sizeof(*pWindowData);             /* first field = size */
  1383.    pWindowData->somSelf = somSelf;
  1384.  
  1385.    /* Create a frame window
  1386.     */
  1387.    flFrameCtlData.cb            = sizeof( flFrameCtlData );
  1388.    flFrameCtlData.flCreateFlags = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_SYSMENU |
  1389.                                   FCF_MINMAX ;
  1390.    flFrameCtlData.hmodResources = hmod;
  1391.    flFrameCtlData.idResources   = ID_ICON;
  1392.  
  1393.    hwndFrame =                                        /* create frame window */
  1394.    WinCreateWindow(
  1395.       HWND_DESKTOP,               /* parent-window handle                    */
  1396.       WC_FRAME,                   /* pointer to registered class name        */
  1397.       _wpQueryTitle(somSelf),     /* pointer to window text                  */
  1398.       0,                          /* window style                            */
  1399.       0, 0, 0, 0,                 /* position of window                      */
  1400.       NULLHANDLE,                 /* owner-window handle                     */
  1401.       HWND_TOP,                   /* handle to sibling window                */
  1402.       (USHORT) ID_FRAME,          /* window identifier                       */
  1403.       (PVOID) &flFrameCtlData,    /* pointer to buffer                       */
  1404.       NULL);      ;               /* pointer to structure with pres. params. */
  1405.  
  1406.    if (!hwndFrame)
  1407.    {
  1408.       DebugBox("WSFILEInit", "Failure in WinCreateWindow");
  1409.       return NULLHANDLE;
  1410.    }
  1411.    hwndClient =         /* use WinCreateWindow so we can pass pres params */
  1412.    WinCreateWindow(
  1413.       hwndFrame,               /* parent-window handle                    */
  1414.       szWSFILEWindowClass,     /* pointer to registered class name        */
  1415.       NULL,                    /* pointer to window text                  */
  1416.       0,                       /* window style                            */
  1417.       0, 0, 0, 0,              /* position of window                      */
  1418.       hwndFrame,               /* owner-window handle                     */
  1419.       HWND_TOP,                /* handle to sibling window                */
  1420.       (USHORT)FID_CLIENT,      /* window identifier                       */
  1421.       pWindowData,             /* pointer to buffer                       */
  1422.       NULL);                   /* pointer to structure with pres. params. */
  1423.  
  1424.    if (!hwndClient)
  1425.    {
  1426.       WinDestroyWindow(hwndFrame);
  1427.       return NULLHANDLE;
  1428.    }
  1429.  
  1430.    WinSendMsg(hwndFrame,WM_SETICON,MPFROMP(_wpQueryIcon(somSelf)),NULL);
  1431.    WinSetWindowText(WinWindowFromID(hwndFrame,
  1432.                                     (USHORT)FID_TITLEBAR),
  1433.                                     _wpQueryTitle(somSelf));
  1434.  
  1435.    /*
  1436.     * Restore the Window Position
  1437.     */
  1438.    fSuccess = WinRestoreWindowPos( szWSFILEClassTitle,      /* class title */
  1439.                                    _wpQueryTitle(somSelf),  /* object title */
  1440.                                    hwndFrame);
  1441.  
  1442.    if (!fSuccess)
  1443.    {
  1444.     SWP        swp;
  1445.  
  1446.       /* Get the dimensions and the shell's suggested
  1447.        * location for the window
  1448.        */
  1449.       WinQueryTaskSizePos(hab,0,&swp);
  1450.  
  1451.       /* Set the frame window position
  1452.        */
  1453.       swp.fl = SWP_SIZE|SWP_MOVE|SWP_RESTORE|SWP_ZORDER;
  1454.       WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y,
  1455.                                            swp.cx, swp.cy, swp.fl);
  1456.    }
  1457.  
  1458.    WinShowWindow(hwndFrame,TRUE);
  1459.    return hwndFrame;                                              /* success */
  1460.  
  1461. }   /* end WSFILEInit() */
  1462.  
  1463.  
  1464. /******************************************************************************
  1465. *
  1466. *   WSFILEWndProc()
  1467. *
  1468. *   DESCRIPTION: WSFILE Window Procedure
  1469. *
  1470. ******************************************************************************/
  1471. MRESULT EXPENTRY WSFILEWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  1472. {
  1473.   PWINDOWDATA pWindowData;
  1474.   HWND     hwndFrame;
  1475.   BOOL     fSuccess;
  1476.  
  1477.    hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
  1478.  
  1479.    switch( msg )
  1480.    {
  1481.       case WM_CREATE:
  1482.  
  1483.         pWindowData = (PWINDOWDATA) mp1;
  1484.  
  1485.         if (pWindowData == NULL)
  1486.         {
  1487.            DebugBox("WSFILEWndProc:WM_CREATE", "couldn't get window words");
  1488.            return FALSE;
  1489.         }
  1490.         /*
  1491.          *   Fill in the class view/usage details and window specific data
  1492.          *   for this instance.
  1493.          */
  1494.         pWindowData->UseItem.type    = USAGE_OPENVIEW;
  1495.         pWindowData->ViewItem.view   = OPEN_WSFILE;
  1496.         pWindowData->ViewItem.handle = hwndFrame;
  1497.  
  1498.         /*
  1499.          *   Set window pointer with object pointer and instance view info.
  1500.          *   Then add view to the in-use list so wpSwitchTo works.
  1501.          */
  1502.         WinSetWindowPtr(hwnd, QWL_USER, pWindowData);
  1503.         _wpAddToObjUseList(pWindowData->somSelf,&pWindowData->UseItem);
  1504.         _wpRegisterView(pWindowData->somSelf, hwndFrame,
  1505.                         _wpQueryTitle(pWindowData->somSelf));
  1506.         WinSetFocus( HWND_DESKTOP, hwndFrame);
  1507.         break;
  1508.  
  1509.       case WM_COMMAND:
  1510.  
  1511.         break;
  1512.  
  1513.       case WM_PAINT:
  1514.          pWindowData = (PWINDOWDATA) WinQueryWindowPtr(hwnd, QWL_USER);
  1515.  
  1516.          if (pWindowData == NULL)
  1517.          {
  1518.             DebugBox("WSFILEWndProc:WM_PAINT", "couldn't get window words");
  1519.             return FALSE;
  1520.          }
  1521.          else
  1522.          {
  1523.           HPS    hps;
  1524.           RECTL  rectl;
  1525.  
  1526.            hps = WinBeginPaint( hwnd, (HPS)NULLHANDLE, &rectl);
  1527.            WinFillRect( hps, &rectl, SYSCLR_WINDOW);
  1528.            WinDrawPointer(hps, 50, 50,
  1529.                           _wpQueryIcon(pWindowData->somSelf), DP_NORMAL);
  1530.            WinEndPaint( hps );
  1531.          }
  1532.          break;
  1533.  
  1534.       case WM_CLOSE:
  1535.          {
  1536.           HAB hab;
  1537.  
  1538.             hab = WinQueryAnchorBlock(HWND_DESKTOP);
  1539.  
  1540.             pWindowData = (PWINDOWDATA) WinQueryWindowPtr(hwnd, QWL_USER);
  1541.  
  1542.             if (pWindowData == NULL)
  1543.             {
  1544.                DebugBox("WSFILEWndProc:WM_CLOSE", "couldn't get window words");
  1545.                return FALSE;
  1546.             }
  1547.             /*
  1548.              * Restore the Window Position
  1549.              */
  1550.             fSuccess = WinStoreWindowPos(szWSFILEClassTitle,
  1551.                                          _wpQueryTitle(pWindowData->somSelf),
  1552.                                          hwndFrame);
  1553.             _wpDeleteFromObjUseList(pWindowData->somSelf,&pWindowData->UseItem);
  1554.             _wpFreeMem(pWindowData->somSelf,(PBYTE)pWindowData);
  1555.  
  1556.             WinPostMsg( hwnd, WM_QUIT, 0, 0 );
  1557.             WinDestroyWindow ( hwndFrame ) ;
  1558.          }
  1559.          break;
  1560.  
  1561.       default:
  1562.          return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  1563.    }
  1564.    return FALSE;
  1565.  
  1566. }   /* end WSFILEWndProc() */
  1567.  
  1568. /******************************************************************************
  1569. *
  1570. *   LastWorkerDlgProc()
  1571. *
  1572. *   DESCRIPTION: Dialog Procedure for LastWorker settings page
  1573. *
  1574. ******************************************************************************/
  1575. MRESULT EXPENTRY LastWorkerDlgProc(HWND hwndDlg, ULONG msg,
  1576.                                   MPARAM mp1, MPARAM mp2)
  1577. {
  1578.  LASTWORKERDLGDATA * pLastWorkerDlgData;
  1579.  
  1580.    switch (msg)
  1581.    {
  1582.       case WM_INITDLG:          /* 0x003b */
  1583.       {
  1584.          PSZ       pszTemp;
  1585.  
  1586.          /*
  1587.           *   Store some instance specific data in Window words of this dialog.
  1588.           *   This will ensure our dialog procedure can access this objects
  1589.           *   data (our dialog proc isn't always passed a *somSelf pointer).
  1590.           */
  1591.          pLastWorkerDlgData =
  1592.             (PLASTWORKERDLGDATA) _wpAllocMem((WSFILE *)mp2, sizeof(*pLastWorkerDlgData), NULL);
  1593.          if (pLastWorkerDlgData)
  1594.          {
  1595.             memset((PVOID) pLastWorkerDlgData, 0, sizeof(*pLastWorkerDlgData));
  1596.             pLastWorkerDlgData->cb = sizeof(*pLastWorkerDlgData);
  1597.             pLastWorkerDlgData->somSelf = (WSFILE *) mp2;   /* pointer to this object */
  1598.             pszTemp = _queryLastWorker(pLastWorkerDlgData->somSelf);
  1599.             if (pszTemp)
  1600.             {
  1601.                pLastWorkerDlgData->PrevWorker =
  1602.                      (PSZ) _wpAllocMem(pLastWorkerDlgData->somSelf,
  1603.                                         CCHMAXPATH+1, NULL);
  1604.                if (pLastWorkerDlgData->PrevWorker)
  1605.                {
  1606.                   strcpy(pLastWorkerDlgData->PrevWorker, pszTemp);
  1607.                }
  1608.             }
  1609.  
  1610.             pLastWorkerDlgData->restorePrevWorker =
  1611.                         (PSZ) _wpAllocMem(pLastWorkerDlgData->somSelf,
  1612.                                            CCHMAXPATH+1, NULL);
  1613.             if (pLastWorkerDlgData->restorePrevWorker)
  1614.             {
  1615.                strcpy(pLastWorkerDlgData->restorePrevWorker,
  1616.                       pLastWorkerDlgData->PrevWorker);
  1617.             }
  1618.          }
  1619.          else
  1620.          {
  1621.             DebugBox("LastWorkerDlgProc:WM_INITDLG", "Couldn't allocate window words");
  1622.             break;
  1623.          }
  1624.  
  1625.          WinSetWindowPtr(hwndDlg, QWL_USER, pLastWorkerDlgData);
  1626.  
  1627.          /* set the text limit on the entry field
  1628.           */
  1629.          WinSendDlgItemMsg( hwndDlg, IDC_LASTWORKER, EM_SETTEXTLIMIT,
  1630.                             MPFROMSHORT( 0x1000-1 ), 0 );
  1631.  
  1632.          /* set the name into the entry field
  1633.           */
  1634.          WinSetWindowText( WinWindowFromID( hwndDlg, IDC_LASTWORKER ),
  1635.                            _queryLastWorker( (WSFILE *) mp2) );
  1636.  
  1637.          _wpCnrRefreshDetails( pLastWorkerDlgData->somSelf );
  1638.  
  1639.          return (MRESULT) FALSE;
  1640.       }   /* end case WM_INITDLG: */
  1641.  
  1642.       case WM_DESTROY:             /* 0x0002 */
  1643.       {
  1644.          WSFILE * pObject;
  1645.  
  1646.          pLastWorkerDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  1647.          if (pLastWorkerDlgData == NULL)
  1648.          {
  1649.             DebugBox("LastWorkerDlgProc:WM_DESTROY", "couldn't get window words");
  1650.             break;
  1651.          }
  1652.  
  1653.          if (pLastWorkerDlgData->PrevWorker)
  1654.          {
  1655.             _wpFreeMem(pLastWorkerDlgData->somSelf,
  1656.                        (PBYTE) pLastWorkerDlgData->PrevWorker);
  1657.          }
  1658.  
  1659.          if (pLastWorkerDlgData->restorePrevWorker)
  1660.          {
  1661.             _wpFreeMem(pLastWorkerDlgData->somSelf,
  1662.                        (PBYTE) pLastWorkerDlgData->restorePrevWorker);
  1663.          }
  1664.  
  1665.          pObject = pLastWorkerDlgData->somSelf;
  1666.          _wpFreeMem(pObject,(PBYTE)pLastWorkerDlgData);
  1667.          return (WinDefDlgProc(hwndDlg, msg, mp1, mp2) );
  1668.       }
  1669.  
  1670.       case WM_COMMAND:           /* 0x0020 */
  1671.  
  1672.          pLastWorkerDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  1673.          if (pLastWorkerDlgData == NULL)
  1674.          {
  1675.             DebugBox("LastWorkerDlgProc:WM_COMMAND", "couldn't get window words");
  1676.             break;
  1677.          }
  1678.  
  1679.          switch (SHORT1FROMMP(mp1))
  1680.          {
  1681.             case ID_UNDO:                   /* 0x0321 */
  1682.                if (pLastWorkerDlgData->restorePrevWorker)
  1683.                {
  1684.                   _setLastWorker(pLastWorkerDlgData->somSelf,
  1685.                                  pLastWorkerDlgData->restorePrevWorker);
  1686.  
  1687.                   if (pLastWorkerDlgData->PrevWorker)
  1688.                   {
  1689.                      strcpy(pLastWorkerDlgData->PrevWorker,
  1690.                             pLastWorkerDlgData->restorePrevWorker);
  1691.                   }
  1692.                   WinSetWindowText( WinWindowFromID( hwndDlg, IDC_LASTWORKER ),
  1693.                                     pLastWorkerDlgData->restorePrevWorker);
  1694.                }
  1695.                break;
  1696.  
  1697.             case ID_DEFAULT:             /* 0x0322 */
  1698.                /*
  1699.                 *   preserve previous values
  1700.                 */
  1701.                _setLastWorker(pLastWorkerDlgData->somSelf, DEFAULT_LASTWORKER);
  1702.  
  1703.                if (pLastWorkerDlgData->PrevWorker)
  1704.                {
  1705.                   strcpy(pLastWorkerDlgData->PrevWorker, DEFAULT_LASTWORKER);
  1706.                }
  1707.  
  1708.                WinSetWindowText( WinWindowFromID( hwndDlg, IDC_LASTWORKER ),
  1709.                                  pLastWorkerDlgData->PrevWorker);
  1710.  
  1711.                break;
  1712.  
  1713.             case ID_HELP:         /* 0x0323 */
  1714.  
  1715.                break;
  1716.  
  1717.          }   /* end switch (SHORT1FROMMP(mp1)) */
  1718.  
  1719.          return (MRESULT) TRUE;
  1720.  
  1721.       case WM_CONTROL:          /* 0x0030 */
  1722.       {
  1723.          pLastWorkerDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  1724.          if (pLastWorkerDlgData == NULL)
  1725.          {
  1726.             DebugBox("LastWorkerDlgProc:WM_CONTROL", "couldn't get window words");
  1727.             break;
  1728.          }
  1729.  
  1730.          switch (SHORT1FROMMP(mp1))
  1731.          {
  1732.          case IDC_LASTWORKER:
  1733.             if (SHORT2FROMMP(mp1) == EN_CHANGE)
  1734.             {
  1735.                CHAR newworker[CCHMAXPATH+1];
  1736.  
  1737.                WinQueryWindowText( WinWindowFromID( hwndDlg, IDC_LASTWORKER),
  1738.                                    CCHMAXPATH+1, newworker );
  1739.                _setLastWorker(pLastWorkerDlgData->somSelf, newworker);
  1740.                if (pLastWorkerDlgData->PrevWorker)
  1741.                {
  1742.                   strcpy(pLastWorkerDlgData->PrevWorker, newworker);
  1743.                }
  1744.             }
  1745.  
  1746.             return (MRESULT) TRUE;
  1747.          }
  1748.          break;
  1749.  
  1750.       }   /* end case WM_CONTROL: */
  1751.  
  1752.    }   /* end switch (msg) */
  1753.  
  1754.    return (WinDefDlgProc(hwndDlg, msg, mp1, mp2) );
  1755.  
  1756. }   /* end LastWorkerDlgProc() */
  1757.  
  1758.  
  1759. /********************************  END wsfile.c  ********************************/
  1760.  
  1761.  
  1762.  
  1763.