home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / shr93.zip / PERSON.C < prev    next >
Text File  |  1993-07-12  |  23KB  |  818 lines

  1. /*
  2.  * OS/2 Work Place Shell Sample Program - ShrPerson model code
  3.  *
  4.  * Copyright (C) 1993 IBM Corporation
  5.  *
  6.  *   DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  7.  *   sample code created by IBM Corporation.  This sample code is
  8.  *   not part of any standard or IBM product and is provided to you
  9.  *   solely for the purpose of assisting you in the development of
  10.  *   your applications.  The code is provided "AS IS".  ALL
  11.  *   WARRANTIES ARE EXPRESSLY DISCLAIMED, INCLUDING THE IMPLIED
  12.  *   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13.  *   PURPOSE.  IBM shall not be liable for any damages arising out
  14.  *   of your use of the sample code, even if IBM has been advised of
  15.  *   the possibility of such damages.
  16.  */
  17.  
  18. #define SOM_NoTest
  19.  
  20. #include "share.h"
  21. #include "notify.h"
  22. #include "personv.h"
  23.  
  24. /*
  25.  * SOM generates method stubs that
  26.  * cause compiler warnings.  Suspend warnings
  27.  * (but be wary, this can mask errors in the
  28.  * emitted "passthru" sections of the CSC file).
  29.  */
  30.  
  31. #define ShrPerson_Class_Source
  32. #pragma checkout(suspend)
  33. #include "person.ih"
  34. #pragma checkout(resume)
  35.  
  36. /*
  37.  * ShrFindPersonClass() is a convenience function
  38.  * which returns a pointer to ShrPerson class.
  39.  */
  40.  
  41. extern SOMClass *ShrFindPersonClass()
  42. {
  43.   return _somFindClass(SOMClassMgrObject,
  44.       SOM_IdFromString(vszShrPersonClass), 0, 0);
  45. }
  46.  
  47. /*
  48.  * 
  49.  *  METHOD: shrQuery...                                     ( ) PRIVATE
  50.  *                                                          (X) PUBLIC
  51.  *  DESCRIPTION:
  52.  *
  53.  *    Return the requested instance variable value.
  54.  *
  55.  */
  56.  
  57. SOM_Scope ULONG SOMLINK per_shrQueryAddress
  58.     (ShrPerson *somSelf, ULONG cchAddressMax, PCHAR pchAddress)
  59. {
  60.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  61.  
  62.   return ShrQueryObjectString(somSelf, pchAddress,
  63.       &_pszAddress, vszDefaultAddress);
  64. }
  65.  
  66. SOM_Scope ULONG SOMLINK per_shrQueryCity
  67.     (ShrPerson *somSelf, ULONG cchCityMax, PCHAR pchCity)
  68. {
  69.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  70.  
  71.   return ShrQueryObjectString(somSelf, pchCity, 
  72.       &_pszCity, vszDefaultCity);
  73. }
  74.  
  75. SOM_Scope ULONG SOMLINK per_shrQueryState
  76.     (ShrPerson *somSelf, ULONG cchStateMax, PCHAR pchState)
  77. {
  78.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  79.  
  80.   return ShrQueryObjectString(somSelf, pchState,
  81.       &_pszState, vszDefaultState);
  82. }
  83.  
  84. SOM_Scope ULONG SOMLINK per_shrQueryZipCode
  85.     (ShrPerson *somSelf, ULONG cchZipCodeMax, PCHAR pchZipCode)
  86. {
  87.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  88.  
  89.   return ShrQueryObjectString(somSelf, pchZipCode,
  90.       &_pszZipCode, vszDefaultZipCode);
  91. }
  92.  
  93. SOM_Scope ULONG SOMLINK per_shrQueryPhone
  94.     (ShrPerson *somSelf, ULONG cchPhoneMax, PCHAR pchPhone)
  95. {
  96.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  97.  
  98.   return ShrQueryObjectString(somSelf, pchPhone,
  99.       &_pszPhone, vszDefaultPhone);
  100. }
  101.  
  102. /*
  103.  * 
  104.  *  METHOD: shrSet...                                       ( ) PRIVATE
  105.  *                                                          (X) PUBLIC
  106.  *  DESCRIPTION:
  107.  *
  108.  *    Set the requested instance variable value.
  109.  *
  110.  */
  111.  
  112. SOM_Scope BOOL SOMLINK per_shrSetAddress
  113.     (ShrPerson *somSelf, PSZ pszNewAddress)
  114. {
  115.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  116.  
  117.   return ShrSetObjectString(somSelf, pszNewAddress, 
  118.       &_pszAddress, SHRN_PERSONADDRESSCHANGED);
  119. }
  120.  
  121. SOM_Scope BOOL SOMLINK per_shrSetCity
  122.     (ShrPerson *somSelf, PSZ pszNewCity)
  123. {
  124.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  125.  
  126.   return ShrSetObjectString(somSelf, pszNewCity,
  127.       &_pszCity, SHRN_PERSONCITYCHANGED);
  128. }
  129.  
  130. SOM_Scope BOOL SOMLINK per_shrSetState
  131.     (ShrPerson *somSelf, PSZ pszNewState)
  132. {
  133.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  134.  
  135.   return ShrSetObjectString(somSelf, pszNewState,
  136.       &_pszState, SHRN_PERSONSTATECHANGED);
  137. }
  138.  
  139.  
  140. SOM_Scope BOOL SOMLINK per_shrSetZipCode
  141.     (ShrPerson *somSelf, PSZ pszNewZipCode)
  142. {
  143.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  144.  
  145.   return ShrSetObjectString(somSelf, pszNewZipCode,
  146.       &_pszZipCode, SHRN_PERSONZIPCODECHANGED);
  147. }
  148.  
  149.  
  150. SOM_Scope BOOL SOMLINK per_shrSetPhone
  151.     (ShrPerson *somSelf, PSZ pszNewPhone)
  152. {
  153.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  154.  
  155.   return ShrSetObjectString(somSelf, pszNewPhone,
  156.       &_pszPhone, SHRN_PERSONPHONECHANGED);
  157. }
  158.  
  159. /*
  160.  * 
  161.  *  METHOD: shrQueryNotifier                                ( ) PRIVATE
  162.  *                                                          (X) PUBLIC
  163.  *  DESCRIPTION:
  164.  * 
  165.  *    Return an instance of a ShrNotifier.  Windows (views)
  166.  *    register interest in this object with the notifier.
  167.  *    When something is changed in this object that affects
  168.  *    the view(s), they are notified.
  169.  *
  170.  *    Using this notification scheme better separates the
  171.  *    model (PERSON.C) and view (PSERONV.C) code.  It also
  172.  *    helps centralize the view code that handles updates 
  173.  *    of what the user sees when required by changes in the model.
  174.  *
  175.  *    See ShrNotifier for more details, especially the 
  176.  *    shrNotifyInterestedWindows method.  Also see the PERSON.CSC
  177.  *    file for more details about this method.
  178.  */
  179.  
  180. SOM_Scope SOMObject * SOMLINK per_shrQueryNotifier(ShrPerson *somSelf)
  181. {
  182.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  183.   BOOL bHoldingSem = FALSE;
  184.  
  185.   /*
  186.    * NOTE!  It is very important that exception handlers be coded in 
  187.    * routines that request mutex semaphores!  The exception condition
  188.    * should relinquish the semaphore if it was successfully
  189.    * requested.  Otherwise, later requestors of the semaphore could
  190.    * wait indefinitely, typically resulting in a hang of one of the
  191.    * WPS threads or the entire WPS.
  192.    *
  193.    * ShrStartTryBlock is a macro that installs an exception
  194.    * handler for this function.  See SHARE.H for more details.
  195.    */
  196.  
  197.   ShrStartTryBlock;
  198.  
  199.   bHoldingSem = !_wpRequestObjectMutexSem(somSelf, SEM_INDEFINITE_WAIT);
  200.  
  201.   if (bHoldingSem)
  202.   {
  203.     if (!_somNotifier)
  204.       _somNotifier = ShrNotifierNew();
  205.  
  206.     bHoldingSem = _wpReleaseObjectMutexSem(somSelf);
  207.   }
  208.  
  209.   ShrEndTryBlock;
  210.   return _somNotifier;
  211.  
  212.   /*
  213.    * Exception handling code for this function goes here.
  214.    */
  215.  
  216. OnException:
  217.   if (bHoldingSem)
  218.     bHoldingSem = _wpReleaseObjectMutexSem(somSelf);
  219.  
  220.   ShrEndTryBlock;
  221.   return NULL;
  222. }
  223.  
  224. /*
  225.  * 
  226.  *  METHOD: shrUnderstandsProtocol                          ( ) PRIVATE
  227.  *                                                          (X) PUBLIC
  228.  *  DESCRIPTION:
  229.  * 
  230.  *    This a more flexible method of dynamically determining an 
  231.  *    object protocol (or "type) than _somIsA.  
  232.  *
  233.  *    Developers may want to implement a new-and-improved version 
  234.  *    of this class object that is not a direct descendant of this 
  235.  *    class' superclass.  This would not be possible if client 
  236.  *    classes use _somIsA.  
  237.  *
  238.  *    But note there is a problem -- this class may have methods 
  239.  *    that are not "name lookup" methods, ie, they use the offset 
  240.  *    method, so creating a new class that is not a subclass of 
  241.  *    this class's superclass would require considerable care 
  242.  *    since it would have to be certain to have its version of 
  243.  *    this class has its methods in the same order as the method 
  244.  *    table of this class.  
  245.  *
  246.  */
  247.  
  248. SOM_Scope BOOL SOMLINK per_shrUnderstandsProtocol
  249.     (ShrPerson *somSelf, ULONG idProtocol)
  250. {
  251.   return (idProtocol == PROTOCOL_PERSON);
  252. }
  253.  
  254. /*
  255.  * 
  256.  *  OVERRIDE: wpSetTitle                                   ( ) PRIVATE
  257.  *                                                         (X) PUBLIC
  258.  *  DESCRIPTION:
  259.  * 
  260.  *    Notify interested windows that the object's title has changed.
  261.  * 
  262.  *    This is necessary to keep the "Name:" field of the "Info" page
  263.  *    on the Settings view in sync if the user uses direct edit on
  264.  *    the person icon (Alt+MB1), or modifies the "Title:" field on 
  265.  *    the "General" page of the Settings view to change the object
  266.  *    title.
  267.  */
  268.  
  269. SOM_Scope BOOL SOMLINK per_wpSetTitle
  270.     (ShrPerson *somSelf, PSZ pszNewTitle)
  271. {
  272.   BOOL bSuccess;
  273.  
  274.   bSuccess = parent_wpSetTitle(somSelf,pszNewTitle);
  275.  
  276.   if (bSuccess)
  277.     _shrNotifyInterestedWindows(_shrQueryNotifier(somSelf),
  278.         somSelf, SHRN_PERSONNAMECHANGED, somSelf, pszNewTitle);
  279.  
  280.   return bSuccess;
  281. }
  282.  
  283. /*
  284.  * 
  285.  *  OVERRIDE: wpUnInitData                                  ( ) PRIVATE
  286.  *                                                          (X) PUBLIC
  287.  *  DESCRIPTION:
  288.  * 
  289.  *    Clear up memory that was allocated on wpInitData.
  290.  * 
  291.  */
  292.  
  293. SOM_Scope void SOMLINK per_wpUnInitData(ShrPerson *somSelf)
  294. {
  295.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  296.  
  297.   if (_somNotifier)
  298.     _somFree(_somNotifier);
  299.  
  300.   if (_pszAddress)
  301.     _wpFreeMem(somSelf, _pszAddress);
  302.  
  303.   if (_pszCity)
  304.     _wpFreeMem(somSelf, _pszCity);
  305.  
  306.   if (_pszState)
  307.     _wpFreeMem(somSelf, _pszState);
  308.  
  309.   if (_pszPhone)
  310.     _wpFreeMem(somSelf, _pszPhone);
  311.  
  312.   parent_wpUnInitData(somSelf);
  313. }
  314.  
  315. /*
  316.  * 
  317.  *  OVERRIDE: wpSaveState                                   ( ) PRIVATE
  318.  *                                                          (X) PUBLIC
  319.  *  DESCRIPTION:
  320.  * 
  321.  *    Save our state variables.
  322.  * 
  323.  */
  324.  
  325. SOM_Scope BOOL SOMLINK per_wpSaveState(ShrPerson *somSelf)
  326. {
  327.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  328.  
  329.   if (_pszAddress)
  330.     _wpSaveString(somSelf, vszShrPersonClass, IDK_ADDRESS, _pszAddress);
  331.  
  332.   if (_pszCity)
  333.     _wpSaveString(somSelf, vszShrPersonClass, IDK_CITY, _pszCity);
  334.  
  335.   if (_pszState)
  336.     _wpSaveString(somSelf, vszShrPersonClass, IDK_STATE, _pszState);
  337.  
  338.   if (_pszZipCode)
  339.     _wpSaveString(somSelf, vszShrPersonClass, IDK_ZIPCODE, _pszZipCode);
  340.  
  341.   if (_pszPhone)
  342.     _wpSaveString(somSelf, vszShrPersonClass, IDK_PHONE, _pszPhone);
  343.  
  344.   return (parent_wpSaveState(somSelf));
  345. }
  346.  
  347. /*
  348.  * 
  349.  *  OVERRIDE: wpRestoreState                                ( ) PRIVATE
  350.  *                                                          (X) PUBLIC
  351.  *  DESCRIPTION:
  352.  * 
  353.  *    Retrieve our saved state variables.
  354.  * 
  355.  */
  356.  
  357. SOM_Scope BOOL SOMLINK per_wpRestoreState
  358.     (ShrPerson *somSelf, ULONG ulReserved)
  359. {
  360.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  361.   ULONG cbData;
  362.  
  363.   if (_wpRestoreString(somSelf, vszShrPersonClass, 
  364.       IDK_ADDRESS, NULL, &cbData))
  365.   {
  366.     _pszAddress = _wpAllocMem(somSelf, cbData, NULL);
  367.  
  368.     if (_pszAddress)
  369.       _wpRestoreString(somSelf, vszShrPersonClass, IDK_ADDRESS,
  370.           _pszAddress, &cbData);
  371.   }
  372.  
  373.   if (_wpRestoreString(somSelf, vszShrPersonClass, 
  374.       IDK_CITY, NULL, &cbData))
  375.   {
  376.     _pszCity = _wpAllocMem(somSelf, cbData, NULL);
  377.  
  378.     if (_pszCity)
  379.       _wpRestoreString(somSelf, vszShrPersonClass, IDK_CITY,
  380.           _pszCity, &cbData);
  381.   }
  382.  
  383.   if (_wpRestoreString(somSelf, vszShrPersonClass, 
  384.       IDK_STATE, NULL, &cbData))
  385.   {
  386.     _pszState = _wpAllocMem(somSelf, cbData, NULL);
  387.  
  388.     if (_pszState)
  389.       _wpRestoreString(somSelf, vszShrPersonClass, IDK_STATE,
  390.           _pszState, &cbData);
  391.   }
  392.  
  393.   if (_wpRestoreString(somSelf, vszShrPersonClass, 
  394.       IDK_ZIPCODE, NULL, &cbData))
  395.   {
  396.     _pszZipCode = _wpAllocMem(somSelf, cbData, NULL);
  397.  
  398.     if (_pszZipCode)
  399.       _wpRestoreString(somSelf, vszShrPersonClass, IDK_ZIPCODE,
  400.           _pszZipCode, &cbData);
  401.   }
  402.  
  403.   if (_wpRestoreString(somSelf, vszShrPersonClass, 
  404.       IDK_PHONE, NULL, &cbData))
  405.   {
  406.     _pszPhone = _wpAllocMem(somSelf, cbData, NULL);
  407.  
  408.     if (_pszPhone)
  409.       _wpRestoreString(somSelf, vszShrPersonClass, IDK_PHONE,
  410.           _pszPhone, &cbData);
  411.   }
  412.  
  413.   return (parent_wpRestoreState(somSelf,ulReserved));
  414. }
  415.  
  416. /*
  417.  * 
  418.  *  METHOD: shrclsAddPersonInfoPage                         ( ) PRIVATE
  419.  *                                                          (X) PUBLIC
  420.  *  DESCRIPTION:
  421.  * 
  422.  *    Adds the "Info" page to the Settings view notebook.
  423.  *    Also see the override of wpAddSettingsPages.
  424.  *
  425.  */
  426.  
  427. SOM_Scope BOOL SOMLINK per_shrAddPersonInfoPage
  428.     (ShrPerson *somSelf, HWND hwndNotebook)
  429. {
  430.   PAGEINFO pageinfo;
  431.  
  432.   memset(&pageinfo, 0, sizeof(PAGEINFO));
  433.   pageinfo.cb = sizeof(PAGEINFO);
  434.   pageinfo.usPageStyleFlags = BKA_MAJOR;
  435.   pageinfo.usPageInsertFlags = BKA_FIRST;
  436.   pageinfo.resid = _shrclsQueryModuleHandle(_somGetClass(somSelf));
  437.   pageinfo.pCreateParams = somSelf;
  438.  
  439.   pageinfo.pszName = vszPersonInfoTab;
  440.   pageinfo.dlgid = IDD_PERSONINFOPAGE;
  441.   pageinfo.pfnwp = ShrPersonInfoPageDlgProc;
  442.  
  443.   return _wpInsertSettingsPage(somSelf, hwndNotebook, &pageinfo);
  444. }
  445.  
  446. /*
  447.  * 
  448.  *   OVERRIDE: wpAddSettingsPages                           ( ) PRIVATE
  449.  *                                                          (X) PUBLIC
  450.  *   DESCRIPTION:
  451.  * 
  452.  *     Notification to add settings pages.
  453.  * 
  454.  */
  455.  
  456. SOM_Scope BOOL SOMLINK per_wpAddSettingsPages
  457.     (ShrPerson *somSelf, HWND hwndNotebook)
  458. {
  459.   BOOL bSuccess;
  460.  
  461.   bSuccess = parent_wpAddSettingsPages(somSelf, hwndNotebook);
  462.  
  463.   if (bSuccess)
  464.     _shrAddPersonInfoPage(somSelf, hwndNotebook);
  465.  
  466.   return bSuccess;
  467. }
  468.  
  469. /*
  470.  */
  471. /*
  472.  * 
  473.  *   OVERRIDE: wpQueryDetailsData                           ( ) PRIVATE
  474.  *                                                          (X) PUBLIC
  475.  *   DESCRIPTION:
  476.  * 
  477.  *     Return the data for displaying the person in details
  478.  *     view of a folder.
  479.  *
  480.  *     This method must return data matching the structure
  481.  *     described in the wpclsQueryDetailsInfo override.
  482.  * 
  483.  */
  484.  
  485. SOM_Scope BOOL SOMLINK per_wpQueryDetailsData
  486.     (ShrPerson *somSelf, PVOID *ppDetailsData, PULONG pcb) 
  487. {
  488.   ShrPersonData *somThis = ShrPersonGetData(somSelf);
  489.   BOOL bSuccess;
  490.   PPERSONDETAILS   pPersonDetails;
  491.   ULONG cbSuperclassDetails;
  492.  
  493.   if (!ppDetailsData) 
  494.   {                    
  495.     /*
  496.      * Only interested in the length of the details data.
  497.      */
  498.  
  499.     bSuccess = parent_wpQueryDetailsData(somSelf, NULL, pcb);
  500.     *pcb += sizeof(PERSONDETAILS);
  501.   }
  502.   else
  503.   {
  504.     bSuccess = parent_wpQueryDetailsData(somSelf, ppDetailsData, pcb);
  505.  
  506.     if (bSuccess)
  507.     {
  508.       /*
  509.        * Next see if buffer is big enough to also accomodate our   
  510.        * portion of details data.                                  
  511.        */                                                          
  512.   
  513.       parent_wpQueryDetailsData(somSelf, NULL, &cbSuperclassDetails);
  514.   
  515.       if ((cbSuperclassDetails + sizeof(PERSONDETAILS)) > *pcb)
  516.       {
  517.         bSuccess = FALSE;
  518.       }
  519.       else
  520.       {
  521.         /*
  522.          * Fill in the details for this object.
  523.          */
  524.  
  525.         pPersonDetails = (PPERSONDETAILS) *ppDetailsData;
  526.  
  527.         /*
  528.          * If nothing has been set, return the defaults.
  529.          * We could store the defaults in each object
  530.          * by setting these instance varibles in wpInitData,
  531.          * but that would waste memory and disk space.
  532.          *
  533.          * Note the Details view fields are read-only.  If
  534.          * that were to change, we would have to allocate
  535.          * space for each default field to avoid the
  536.          * global MRI variables being modified.
  537.          */
  538.  
  539.         if (_pszAddress)
  540.           pPersonDetails->pszAddress = _pszAddress;
  541.         else
  542.           pPersonDetails->pszAddress = vszDefaultAddress;
  543.  
  544.         if (_pszCity)
  545.           pPersonDetails->pszCity = _pszCity;
  546.         else
  547.           pPersonDetails->pszCity = vszDefaultCity;
  548.  
  549.         if (_pszState)
  550.           pPersonDetails->pszState = _pszState;
  551.         else
  552.           pPersonDetails->pszState = vszDefaultState;
  553.  
  554.         if (_pszZipCode)
  555.           pPersonDetails->pszZipCode = _pszZipCode;
  556.         else
  557.           pPersonDetails->pszZipCode = vszDefaultZipCode;
  558.  
  559.         if (_pszPhone)
  560.           pPersonDetails->pszPhone = _pszPhone;
  561.         else
  562.           pPersonDetails->pszPhone = vszDefaultPhone;
  563.       
  564.         *ppDetailsData = pPersonDetails+1;
  565.       }
  566.     }
  567.   }
  568.  
  569.   return bSuccess;
  570. }
  571.  
  572. /*
  573.  * Class Methods.
  574.  *
  575.  * IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT!
  576.  * IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT!
  577.  * IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT!
  578.  *
  579.  * The "undef/define" below marks the begining of the
  580.  * class methods.  SOM's macros will generate the
  581.  * wrong code if instance methods are defined after
  582.  * this point (causing strange runtime traps).
  583.  *
  584.  * Be careful when adding new INSTANCE methods to the CSC file because
  585.  * they are automatically appended to the end of the C file, but
  586.  * must appear above the "#undef SOM_CurrentClass".
  587.  */
  588.  
  589. #undef SOM_CurrentClass
  590. #define SOM_CurrentClass SOMMeta
  591.  
  592. /*
  593.  * 
  594.  *  METHOD: shrclsQueryModuleHandle                         ( ) PRIVATE
  595.  *                                                          (X) PUBLIC
  596.  *  DESCRIPTION:
  597.  * 
  598.  *    This method returns the module handle of this class.  If this is the
  599.  *    first invocation, DosQueryModuleHandle is called to save the handle
  600.  *    for future invocations.
  601.  * 
  602.  *  RETURN:
  603.  * 
  604.  *    0              Unsuccessful
  605.  *    non-zero       module handle
  606.  * 
  607.  */
  608.  
  609. SOM_Scope HMODULE SOMLINK perM_shrclsQueryModuleHandle
  610.     (M_ShrPerson *somSelf)
  611. {
  612.   M_ShrPersonData *somThis = M_ShrPersonGetData(somSelf); 
  613.   APIRET rc = 0;
  614.   PSZ pszPathName;
  615.  
  616.   if (_hmod == NULLHANDLE)
  617.   {
  618.     pszPathName = _somLocateClassFile(SOMClassMgrObject, 
  619.         SOM_IdFromString(_somGetName(somSelf)), 0, 0);
  620.     rc = DosQueryModuleHandle(pszPathName, &_hmod);
  621.   }
  622.  
  623.   return (rc ? NULLHANDLE : _hmod);
  624. }
  625.  
  626. /*
  627.  * 
  628.  *  OVERRIDE: wpclsInitData
  629.  * 
  630.  *  DESCRIPTION:
  631.  * 
  632.  *    Initalize the class data
  633.  * 
  634.  */
  635.  
  636. SOM_Scope void SOMLINK perM_wpclsInitData(M_ShrPerson *somSelf)
  637. {
  638.   M_ShrPersonData *somThis = M_ShrPersonGetData(somSelf); 
  639.   ULONG i;
  640.  
  641.   /*
  642.    * Initialize the class field info details (see
  643.    * wpclsQueryDetailsInfo for more information).
  644.    */
  645.  
  646.   memset(&_acfiPerson, 0, sizeof(_acfiPerson));
  647.  
  648.   for (i=0; i < NUM_PERSONDETAILS_FIELDS; i++)
  649.   {
  650.     /*
  651.      * The class field information for this class is 
  652.      * simple -- just strings.
  653.      */
  654.  
  655.     _acfiPerson[i].cb = sizeof(CLASSFIELDINFO);
  656.     _acfiPerson[i].flData = CFA_STRING | CFA_LEFT |
  657.         CFA_SEPARATOR | CFA_FIREADONLY;
  658.     _acfiPerson[i].flTitle = CFA_CENTER | CFA_SEPARATOR | 
  659.         CFA_HORZSEPARATOR | CFA_STRING | CFA_FITITLEREADONLY;
  660.     _acfiPerson[i].flCompare = COMPARE_SUPPORTED | SORTBY_SUPPORTED;
  661.     _acfiPerson[i].DefaultComparison = CMP_GREATER;                 
  662.     _acfiPerson[i].ulLenFieldData = sizeof(PSZ);
  663.     _acfiPerson[i].ulLenCompareValue = CCHMINSTRING;                
  664.   }
  665.  
  666.   /*
  667.    * Chain the class field information together, making certain
  668.    * the last is NULL.  The order they are chained will determine
  669.    * the order they appear in the details columns.
  670.    */
  671.  
  672.   _acfiPerson[0].pTitleData = vszPhone;
  673.   _acfiPerson[0].offFieldData = FIELDOFFSET(PERSONDETAILS, pszPhone);
  674.   _acfiPerson[0].pNextFieldInfo = &_acfiPerson[1];
  675.  
  676.   _acfiPerson[1].pTitleData = vszAddress;
  677.   _acfiPerson[1].offFieldData = FIELDOFFSET(PERSONDETAILS, pszAddress);
  678.   _acfiPerson[1].pNextFieldInfo = &_acfiPerson[2];
  679.  
  680.   _acfiPerson[2].pTitleData = vszCity;
  681.   _acfiPerson[2].offFieldData = FIELDOFFSET(PERSONDETAILS, pszCity);
  682.   _acfiPerson[2].pNextFieldInfo = &_acfiPerson[3];
  683.  
  684.   _acfiPerson[3].pTitleData = vszState;
  685.   _acfiPerson[3].offFieldData = FIELDOFFSET(PERSONDETAILS, pszState);
  686.   _acfiPerson[3].pNextFieldInfo = &_acfiPerson[4];
  687.  
  688.   _acfiPerson[4].pTitleData = vszZipCode;
  689.   _acfiPerson[4].offFieldData = FIELDOFFSET(PERSONDETAILS, pszZipCode);
  690.   _acfiPerson[4].pNextFieldInfo = NULL;
  691.  
  692.   parent_wpclsInitData(somSelf);
  693. }
  694.  
  695. SOM_Scope ULONG SOMLINK perM_wpclsQueryDetailsInfo
  696.     (M_ShrPerson *somSelf, PCLASSFIELDINFO 
  697.     *ppClassFieldInfo, PULONG pSize)
  698. {
  699.   M_ShrPersonData *somThis = M_ShrPersonGetData(somSelf); 
  700.   ULONG ulSuperclassColumns, i;
  701.   PCLASSFIELDINFO pCFI;
  702.  
  703.   ulSuperclassColumns = parent_wpclsQueryDetailsInfo(somSelf,
  704.       ppClassFieldInfo, pSize);
  705.  
  706.   /*
  707.    * If the request was for the size of the details column
  708.    * data.  Add the size needed by the person details.
  709.    */
  710.  
  711.   if (pSize)
  712.     *pSize += sizeof(PERSONDETAILS);
  713.  
  714.   /* If the request was for the chained CLASSFIELDINFO structures,
  715.    * link ShrPerson's into the chain.
  716.    *
  717.    * If the beginning of the chain is NULL, assign the address
  718.    * of ShrPerson's first CLASSFIELDINFO structure to 
  719.    * *ppClassFieldInfo.  Otherwise *ppClassFieldInfo points 
  720.    * to the first column description in the chain.  We need 
  721.    * to walk the chain and link our CLASSFIELDINFO structures 
  722.    * at the end.
  723.    */
  724.  
  725.   if (ppClassFieldInfo)
  726.   {
  727.     pCFI = *ppClassFieldInfo;
  728.   
  729.     if (pCFI)
  730.     {
  731.       for (i=0; i < ulSuperclassColumns; i++)
  732.         if (pCFI->pNextFieldInfo)
  733.           pCFI = pCFI->pNextFieldInfo;
  734.   
  735.       pCFI->pNextFieldInfo = _acfiPerson;
  736.     }
  737.     else
  738.     {
  739.       *ppClassFieldInfo = _acfiPerson;
  740.     }
  741.   }
  742.  
  743.   return ulSuperclassColumns + NUM_PERSONDETAILS_FIELDS;
  744. }
  745.  
  746. /*
  747.  * 
  748.  *  OVERRIDE: wpclsQueryTitle                              ( ) PRIVATE
  749.  *                                                         (X) PUBLIC
  750.  *  DESCRIPTION:
  751.  * 
  752.  *    Return the string "Person".
  753.  * 
  754.  */
  755.  
  756. SOM_Scope PSZ SOMLINK perM_wpclsQueryTitle(M_ShrPerson *somSelf)
  757. {
  758.   return vszPersonTitle;
  759. }
  760.  
  761. /*
  762.  * 
  763.  *  OVERRIDE: wpclsQueryIconData                           ( ) PRIVATE
  764.  *                                                         (X) PUBLIC
  765.  *  DESCRIPTION:
  766.  * 
  767.  *    Return the class icon
  768.  * 
  769.  */
  770.  
  771. SOM_Scope ULONG SOMLINK perM_wpclsQueryIconData
  772.     (M_ShrPerson *somSelf, PICONINFO pIconInfo)
  773. {
  774.   if (pIconInfo)
  775.   {
  776.      pIconInfo->fFormat = ICON_RESOURCE;
  777.      pIconInfo->hmod = _shrclsQueryModuleHandle(somSelf);
  778.      pIconInfo->resid = IDP_PERSON;
  779.   }
  780.  
  781.   return (sizeof(ICONINFO));
  782. }
  783.  
  784. /*
  785.  * 
  786.  *  OVERRIDE: wpclsQueryDefaultView                        ( ) PRIVATE
  787.  *                                                         (X) PUBLIC
  788.  *  DESCRIPTION:
  789.  * 
  790.  *    Returns the default view for a new instance of this object.
  791.  * 
  792.  */
  793.  
  794. SOM_Scope ULONG SOMLINK perM_wpclsQueryDefaultView(M_ShrPerson *somSelf)
  795. {
  796.   return OPEN_SETTINGS;
  797. }
  798.  
  799. /*
  800.  *
  801.  *  METHOD: wpclsQueryStyle                                ( ) PRIVATE
  802.  *                                                         (X) PUBLIC
  803.  *  DESCRIPTION:
  804.  *
  805.  *  REMARKS:
  806.  *
  807.  */
  808.  
  809. SOM_Scope ULONG SOMLINK perM_wpclsQueryStyle(M_ShrPerson *somSelf)
  810. {
  811.   ULONG ulStyle;
  812.  
  813.   ulStyle = parent_wpclsQueryStyle(somSelf);
  814.   ulStyle &= ~CLSSTYLE_NEVERTEMPLATE;
  815.  
  816.   return ulStyle;
  817. }
  818.