home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / RB3774.ZIP / RECORD.ZIP / RECFLDER.C < prev    next >
Text File  |  1992-04-10  |  7KB  |  270 lines

  1.  
  2. /*************************************************************************/
  3. /*                                                                       */
  4. /* ITSC Redbook OS/2 v2.0 Sample Program                                 */
  5. /*                                                                       */
  6. /*                                                                       */
  7. /* RECORD.C  -  This is the C implementation of a WPS Folder class       */
  8. /*              with an extra context menu option to perform a           */
  9. /*              Telephone List find, by calling a method from the        */
  10. /*              Record Class.                                            */
  11. /*                                                                       */
  12. /*************************************************************************/
  13. /*
  14.  * This file was generated by the SOM Compiler.
  15.  * FileName: recflder.c.
  16.  * Generated using:
  17.  *     SOM Precompiler spc: 1.21
  18.  *     SOM Emitter emitc: 1.23
  19.  */
  20.  
  21. #define INCL_WIN
  22. #define INCL_DOS
  23. #define INCL_GPIBITMAPS
  24. #define INCL_WPCLASS
  25. #define INCL_WPFOLDER
  26. #include <os2.h>
  27.  
  28. #include <pmwp.h>  /* eventually will be #define INCL_WINWORKPLACE */
  29.  
  30. #include <string.h>
  31. #include <stdio.h>
  32. #include <memory.h>
  33. #include <stdlib.h>
  34.  
  35. #include "record.h" /* Include Record file .h so we can invoke */
  36.                     /* the Record class method to do the query */
  37.  
  38. #include "res.h"
  39.  
  40. void SendQueryToRecordClass(SOMAny *Folder, PSZ szQuery);
  41.  
  42. /* default title when created without a title */
  43. PSZ DefaultClassTitle = "Record Folder";
  44.  
  45. /* Handle to classes module */
  46. HMODULE  hmodThisClass;
  47.  
  48. #define RecordFolder_Class_Source
  49. #include "recflder.ih"
  50.  
  51. #undef SOM_CurrentClass
  52. #define SOM_CurrentClass SOMInstance
  53. /*
  54.  *
  55.  *  METHOD:   UpdateLastQuery                             PRIVATE
  56.  *
  57.  *  PURPOSE:  Saves the last query that return a result
  58.  *            from the Record class
  59.  *
  60.  */
  61.  
  62. SOM_Scope BOOL   SOMLINK recflder_UpdateLastQuery(RecordFolder *somSelf,
  63.                 PSZ szQuery)
  64. {
  65.     RecordFolderData *somThis = RecordFolderGetData(somSelf);
  66.     RecordFolderMethodDebug("RecordFolder","recflder_UpdateLastQuery");
  67.  
  68.     return (BOOL) 0;
  69. }
  70.  
  71. /*
  72.  *
  73.  *  OVERRIDE: wpInitData                                  PUBLIC
  74.  *
  75.  *  PURPOSE:  Initialize our instance variables.
  76.  *
  77.  */
  78.  
  79. SOM_Scope void   SOMLINK recflder_wpInitData(RecordFolder *somSelf)
  80. {
  81.     RecordFolderData *somThis = RecordFolderGetData(somSelf);
  82.     RecordFolderMethodDebug("RecordFolder","recflder_wpInitData");
  83.  
  84.     parent_wpInitData(somSelf);
  85. }
  86.  
  87. /*
  88.  *
  89.  *  OVERRIDE: wpModifyPopupMenu                           PUBLIC
  90.  *
  91.  *  PURPOSE:  Add the extra find option to
  92.  *            the context menu.
  93.  *
  94.  */
  95.  
  96. SOM_Scope BOOL   SOMLINK recflder_wpModifyPopupMenu(RecordFolder *somSelf,
  97.                 HWND hwndMenu,
  98.                 HWND hwndCnr,
  99.                 ULONG iPosition)
  100. {
  101.     RecordFolderData *somThis = RecordFolderGetData(somSelf);
  102.     RecordFolderMethodDebug("RecordFolder","recflder_wpModifyPopupMenu");
  103.  
  104.     _wpInsertPopupMenuItems( somSelf, hwndMenu, iPosition,
  105.                                hmodThisClass, ID_CXTMENU_RECFLDER, 0 );
  106.  
  107.     return (parent_wpModifyPopupMenu(somSelf,hwndMenu,hwndCnr,iPosition));
  108. }
  109.  
  110. /*
  111.  *
  112.  *  OVERRIDE: wpMenuItemSelected                          PUBLIC
  113.  *
  114.  *  PURPOSE:  Process input from the extra
  115.  *            menu option that we have added.
  116.  *
  117.  */
  118.  
  119. SOM_Scope void   SOMLINK recflder_wpMenuItemSelected(RecordFolder *somSelf,
  120.                 HWND hwndFrame,
  121.                 ULONG MenuId)
  122. {
  123.     RecordFolderData *somThis = RecordFolderGetData(somSelf);
  124.     RecordFolderMethodDebug("RecordFolder","recflder_wpMenuItemSelected");
  125.  
  126.     switch( MenuId )
  127.     {
  128.        case IDM_QUERY:
  129.           SendQueryToRecordClass(somSelf, "");
  130.           break;
  131.  
  132.        case IDM_RESTART_SERVER:
  133.           {
  134.              SOMAny   *RecordClass;
  135.  
  136.              /* First find the Record class */
  137.              if ( RecordClass = _somFindClass( SOMClassMgrObject, SOM_IdFromString("Record"), 1, 1 ) )
  138.              {
  139.                 _clsRestartServer(RecordClass);
  140.              }
  141.              else
  142.              {
  143.                 DebugBox("Restart Server Error", "Could not find Record class");
  144.              }
  145.           }
  146.           break;
  147.  
  148.        default:
  149.           parent_wpMenuItemSelected(somSelf, hwndFrame, MenuId);
  150.           break;
  151.     }
  152.  
  153. }
  154.  
  155. /*
  156.  *
  157.  *  OVERRIDE: wpSaveState                                 PUBLIC
  158.  *
  159.  *  PURPOSE:  Here we can store our persistent instance
  160.  *            data so that it can be restored from
  161.  *            wpRestoreState
  162.  *
  163.  */
  164.  
  165. SOM_Scope BOOL   SOMLINK recflder_wpSaveState(RecordFolder *somSelf)
  166. {
  167.     RecordFolderData *somThis = RecordFolderGetData(somSelf);
  168.     RecordFolderMethodDebug("RecordFolder","recflder_wpSaveState");
  169.  
  170.     return (parent_wpSaveState(somSelf));
  171. }
  172.  
  173. /*
  174.  *
  175.  *  OVERRIDE: wpRestoreState                              PUBLIC
  176.  *
  177.  *  PURPOSE:  Allow us to resend the last query to
  178.  *            the Record class
  179.  *
  180.  */
  181.  
  182. SOM_Scope BOOL   SOMLINK recflder_wpRestoreState(RecordFolder *somSelf,
  183.                 ULONG ulReserved)
  184. {
  185.     RecordFolderData *somThis = RecordFolderGetData(somSelf);
  186.     RecordFolderMethodDebug("RecordFolder","recflder_wpRestoreState");
  187.  
  188.     return (parent_wpRestoreState(somSelf,ulReserved));
  189. }
  190.  
  191. #undef SOM_CurrentClass
  192. #define SOM_CurrentClass SOMMeta
  193. /*
  194.  *
  195.  *  METHOD: wpclsQueryTitle                               PUBLIC
  196.  *
  197.  *  PURPOSE:
  198.  *    Return the string "Record Folder"
  199.  *
  200.  */
  201.  
  202. SOM_Scope PSZ   SOMLINK recfldercls_wpclsQueryTitle(M_RecordFolder *somSelf)
  203. {
  204.     /* M_RecordFolderData *somThis = M_RecordFolderGetData(somSelf); */
  205.     M_RecordFolderMethodDebug("M_RecordFolder","recfldercls_wpclsQueryTitle");
  206.  
  207.     return (DefaultClassTitle);
  208. }
  209.  
  210. /*
  211.  *
  212.  *  METHOD: wpclsInitData                                 PUBLIC
  213.  *
  214.  *  PURPOSE:
  215.  *    We can do class specific initialisation here
  216.  *
  217.  */
  218.  
  219. SOM_Scope void   SOMLINK recfldercls_wpclsInitData(M_RecordFolder *somSelf)
  220. {
  221.     CHAR ErrorBuffer[100];
  222.  
  223.     /* M_RecordFolderData *somThis = M_RecordFolderGetData(somSelf); */
  224.     M_RecordFolderMethodDebug("M_RecordFolder","recfldercls_wpclsInitData");
  225.  
  226.     DosLoadModule((PSZ) ErrorBuffer,
  227.                   sizeof(ErrorBuffer),
  228.                   "RECFLDER", &hmodThisClass);
  229.  
  230.     parent_wpclsInitData(somSelf);
  231. }
  232.  
  233. /*
  234.  *
  235.  *  METHOD: wpclsUnInitData                               PUBLIC
  236.  *
  237.  *  PURPOSE:
  238.  *    Here we release any class resources
  239.  *
  240.  */
  241.  
  242. SOM_Scope void   SOMLINK recfldercls_wpclsUnInitData(M_RecordFolder *somSelf)
  243. {
  244.     /* M_RecordFolderData *somThis = M_RecordFolderGetData(somSelf); */
  245.     M_RecordFolderMethodDebug("M_RecordFolder","recfldercls_wpclsUnInitData");
  246.  
  247.     DosFreeModule(hmodThisClass);
  248.  
  249.     parent_wpclsUnInitData(somSelf);
  250. }
  251.  
  252. /*********************** End of Methods Section ****************************/
  253.  
  254.  
  255.  
  256. void SendQueryToRecordClass(SOMAny *Folder, PSZ szQuery)
  257. {
  258.    SOMAny   *RecordClass;
  259.  
  260.    /* First find the Record class */
  261.    if ( RecordClass = _somFindClass( SOMClassMgrObject, SOM_IdFromString("Record"), 1, 1 ) )
  262.    {
  263.       _clsQueryDatabase(RecordClass, szQuery, Folder);
  264.    }
  265.    else
  266.    {
  267.       DebugBox("Send Query Error", "Could not find Record class");
  268.    }
  269. }
  270.