home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / utils / wpprg / wpprgext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-28  |  26.7 KB  |  876 lines

  1. /*************************************************************************
  2.  *
  3.  * This file was generated by the SOM Compiler.
  4.  * FileName: wpprgext.c.
  5.  * Generated using:
  6.  *     SOM Precompiler spc: 1.22
  7.  *     SOM Emitter emitc: 1.24
  8.  *
  9.  *************************************************************************/
  10.  
  11. /*************************************************************************
  12.  * 
  13.  * 
  14.  *   Module Name : WPPRGEXT
  15.  * 
  16.  *   Description : OS/2 Workplace Shell WPProgram Object Extension.
  17.  *                 This extension adds the option to close the folder
  18.  *                 to which the launching program belongs.
  19.  * 
  20.  *   Programmer  : Yong D. Lee
  21.  *   Date        : Nov 21, 1993
  22.  * 
  23.  *   Disclaimer of warranties:
  24.  *       The code is provided "AS IS", without warranty of any kind.  I shall
  25.  *       not be liable for any damages arising out of your use of this code.
  26.  * 
  27.  *************************************************************************/
  28.  
  29. #define WPPrgExt_Class_Source
  30. #define M_WPPrgExt_Class_Source
  31.  
  32. #include "wpprgext.ih"
  33. #include "wpprgext.ph"
  34.  
  35. #include <string.h>
  36. #include <stdio.h>
  37. #include <memory.h>
  38. #include <stdlib.h>
  39.  
  40. /*************************************************************************/
  41. /*                                                                       */
  42. /*                     Non-method function prototype                     */
  43. /*                                                                       */
  44. /*************************************************************************/
  45.  
  46. MRESULT EXPENTRY FolderDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  47. MRESULT EXPENTRY CloseKeyDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2);
  48.  
  49. /*************************************************************************/
  50. /*                                                                       */
  51. /*               Global/Static (Non-Instance) Data Section               */
  52. /*                                                                       */
  53. /*************************************************************************/
  54.  
  55. UCHAR szWPPrgExtClassTitle[CCHMAXPATH] = "";
  56. HMODULE hmod = NULLHANDLE;
  57. LONG virtualKey;
  58.  
  59. /*************************************************************************/
  60. /*                                                                       */
  61. /*                         Method Implementation                         */
  62. /*                                                                       */
  63. /*************************************************************************/
  64.  
  65. /*************************************************************************
  66.  * 
  67.  *  METHOD: QueryFolderClose                               ( ) PRIVATE
  68.  *                                                         (X) PUBLIC
  69.  *  DESCRIPTION:
  70.  * 
  71.  *    Query state of folder close flag
  72.  * 
  73.  *  RETURN:
  74.  * 
  75.  *    ULONG - folder closing option
  76.  * 
  77.  *************************************************************************/
  78.  
  79. SOM_Scope ULONG   SOMLINK wpprgext_QueryFolderClose(WPPrgExt *somSelf)
  80. {
  81.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  82.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_QueryFolderClose");
  83.  
  84.     return (ULONG) _folderClose;
  85. }
  86.  
  87. /*************************************************************************
  88.  *
  89.  *  METHOD: SetFolderClose                                 ( ) PRIVATE
  90.  *                                                         (X) PUBLIC
  91.  *  DESCRIPTION:
  92.  *
  93.  *    Set state of folder close flag
  94.  *
  95.  *************************************************************************/
  96.  
  97. SOM_Scope VOID   SOMLINK wpprgext_SetFolderClose(WPPrgExt *somSelf, ULONG flag)
  98. {
  99.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  100.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_SetFolderClose");
  101.  
  102.     _folderClose = flag;
  103. }
  104.  
  105. /*************************************************************************
  106.  * 
  107.  *  METHOD: AddFolderOptionPage                            ( ) PRIVATE
  108.  *                                                         (X) PUBLIC
  109.  *  DESCRIPTION:
  110.  * 
  111.  *    Add the folder page to the settings notebook
  112.  * 
  113.  *  RETURN:
  114.  * 
  115.  *    0              Unsuccessful
  116.  *    ulPageId       Identifier for the inserted page
  117.  * 
  118.  * 
  119.  *    Methods from the WPObject class
  120.  * 
  121.  *************************************************************************/
  122.  
  123. SOM_Scope ULONG   SOMLINK wpprgext_AddFolderOptionPage(WPPrgExt *somSelf, HWND hwndNotebook)
  124. {
  125.     PAGEINFO pageinfo;
  126.     ULONG pageId;
  127.  
  128.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  129.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_AddFolderOptionPage");
  130.  
  131.     memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  132.     pageinfo.cb = sizeof(PAGEINFO);
  133.     pageinfo.hwndPage = NULLHANDLE;
  134.     pageinfo.usPageStyleFlags = BKA_MAJOR;
  135.     pageinfo.usPageInsertFlags = BKA_LAST;
  136.     pageinfo.pfnwp = FolderDlgProc;
  137.     pageinfo.resid = hmod;
  138.     pageinfo.dlgid = IDD_FOLDER;
  139.     pageinfo.pszName = "Folder";
  140.     pageinfo.pCreateParams = somSelf;
  141.  
  142.     /*
  143.      * Insert folder key page
  144.      */
  145.     pageId = _wpInsertSettingsPage(somSelf, hwndNotebook, &pageinfo);
  146.  
  147.     /*
  148.      * Insert status line text
  149.      */
  150.     WinSendMsg(hwndNotebook, BKM_SETSTATUSLINETEXT, (MPARAM)pageId, MPFROMP("Folder - Page 1 of 2 "));
  151.  
  152.     return pageId;
  153.  
  154. }
  155.  
  156. /*************************************************************************
  157.  *
  158.  *  METHOD: AddFolderKeyPage                               ( ) PRIVATE
  159.  *                                                         (X) PUBLIC
  160.  *  DESCRIPTION:
  161.  *
  162.  *    Add the folder key selection page to the settings notebook
  163.  *
  164.  *  RETURN:
  165.  *
  166.  *    0              Unsuccessful
  167.  *    ulPageId       Identifier for the inserted page
  168.  *
  169.  *************************************************************************/
  170.  
  171. SOM_Scope ULONG   SOMLINK wpprgext_AddFolderKeyPage(WPPrgExt *somSelf, HWND hwndNotebook)
  172. {
  173.     PAGEINFO pageinfo;
  174.     ULONG pageId;
  175.  
  176.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  177.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_AddFolderKeyPage");
  178.  
  179.     memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  180.     pageinfo.cb = sizeof(PAGEINFO);
  181.     pageinfo.hwndPage = NULLHANDLE;
  182.     pageinfo.usPageStyleFlags = BKA_STATUSTEXTON;
  183.     pageinfo.usPageInsertFlags = BKA_LAST;
  184.     pageinfo.pfnwp = CloseKeyDlgProc;
  185.     pageinfo.resid = hmod;
  186.     pageinfo.dlgid = IDD_FOLDERKEY;
  187.     pageinfo.pCreateParams = somSelf;
  188.  
  189.     /*
  190.      * Insert folder key page
  191.      */
  192.     pageId = _wpInsertSettingsPage(somSelf, hwndNotebook, &pageinfo);
  193.  
  194.     /*
  195.      * Insert status line text
  196.      */
  197.     WinSendMsg(hwndNotebook, BKM_SETSTATUSLINETEXT, (MPARAM)pageId, MPFROMP("Folder - Page 2 of 2 "));
  198.  
  199.     return pageId;
  200. }
  201.  
  202. /*************************************************************************
  203.  *
  204.  *  METHOD: FindKeyFromScancode                            ( ) PRIVATE
  205.  *                                                         (X) PUBLIC
  206.  *  DESCRIPTION:
  207.  *
  208.  *    Find key name from scancode
  209.  *
  210.  *************************************************************************/
  211.  
  212. SOM_Scope VOID SOMLINK wpprgext_FindKeyFromScancode(WPPrgExt *somSelf, LONG scanCode, CHAR *str)
  213. {
  214.     SHORT keyID;
  215.  
  216.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  217.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_FindKeyFromScancode");
  218.  
  219.     switch (scanCode) {
  220.         case VK_SHIFT:
  221.             keyID = IDSC_SHIFT;
  222.             break;
  223.  
  224.         case VK_F1:
  225.             keyID = IDSC_F1;
  226.             break;
  227.  
  228.         case VK_F2:
  229.             keyID = IDSC_F2;
  230.             break;
  231.  
  232.         case VK_F3:
  233.             keyID = IDSC_F3;
  234.             break;
  235.  
  236.         case VK_F4:
  237.             keyID = IDSC_F4;
  238.             break;
  239.  
  240.         case VK_F5:
  241.             keyID = IDSC_F5;
  242.             break;
  243.  
  244.         case VK_F6:
  245.             keyID = IDSC_F6;
  246.             break;
  247.  
  248.         case VK_F7:
  249.             keyID = IDSC_F7;
  250.             break;
  251.  
  252.         case VK_F8:
  253.             keyID = IDSC_F8;
  254.             break;
  255.  
  256.         case VK_F9:
  257.             keyID = IDSC_F9;
  258.             break;
  259.  
  260.         case VK_F10:
  261.             keyID = IDSC_F10;
  262.             break;
  263.  
  264.         case VK_F11:
  265.             keyID = IDSC_F11;
  266.             break;
  267.  
  268.         case VK_F12:
  269.             keyID = IDSC_F12;
  270.             break;
  271.  
  272.     }
  273.  
  274.     WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), _clsQueryModuleHandle((M_WPPrgExt *)_somGetClass(somSelf)), (ULONG)keyID, CCHMAXPATH, str);
  275. }
  276.  
  277. /*************************************************************************
  278.  *
  279.  *  METHOD: FindScancodeFromKey                            ( ) PRIVATE
  280.  *                                                         (X) PUBLIC
  281.  *  DESCRIPTION:
  282.  *
  283.  *    Find scancode from keyname
  284.  *
  285.  *  RETURN
  286.  *    key scancode
  287.  *
  288.  *************************************************************************/
  289.  
  290. SOM_Scope ULONG   SOMLINK wpprgext_FindScancodeFromKey(WPPrgExt *somSelf, CHAR *str)
  291. {
  292.     SHORT sCount;
  293.     CHAR keyStr[CCHMAXPATH];
  294.  
  295.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  296.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_FindScancodeFromKey");
  297.  
  298.     for (sCount = 0; sCount < MAXKEY; sCount++) {
  299.         WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), _clsQueryModuleHandle((M_WPPrgExt *)_somGetClass(somSelf)), (ULONG)(IDSC_SHIFT + sCount), CCHMAXPATH, keyStr);
  300.  
  301.         if (strcmp(str, keyStr) == 0)
  302.             break;
  303.  
  304.     }
  305.  
  306.     switch (IDSC_SHIFT + sCount) {
  307.         case IDSC_SHIFT:
  308.             return VK_SHIFT;
  309.  
  310.         case IDSC_F1:
  311.             return VK_F1;
  312.  
  313.         case IDSC_F2:
  314.             return VK_F2;
  315.  
  316.         case IDSC_F3:
  317.             return VK_F3;
  318.  
  319.         case IDSC_F4:
  320.             return VK_F4;
  321.  
  322.         case IDSC_F5:
  323.             return VK_F5;
  324.  
  325.         case IDSC_F6:
  326.             return VK_F6;
  327.  
  328.         case IDSC_F7:
  329.             return VK_F7;
  330.  
  331.         case IDSC_F8:
  332.             return VK_F8;
  333.  
  334.         case IDSC_F9:
  335.             return VK_F9;
  336.  
  337.         case IDSC_F10:
  338.             return VK_F10;
  339.  
  340.         case IDSC_F11:
  341.             return VK_F11;
  342.  
  343.         case IDSC_F12:
  344.             return VK_F12;
  345.  
  346.     }
  347.  
  348.     return 0;
  349. }
  350.  
  351. /*************************************************************************/
  352. /*                                                                       */
  353. /*                     Override Method Implementation                    */
  354. /*                                                                       */
  355. /*************************************************************************/
  356.  
  357. /*************************************************************************
  358.  * 
  359.  *  OVERRIDE: wpInitData
  360.  * 
  361.  *  DESCRIPTION:
  362.  * 
  363.  *    Initialize the state variables and allocate any extra memory
  364.  *    that might be needed
  365.  * 
  366.  *************************************************************************/
  367.  
  368. SOM_Scope void   SOMLINK wpprgext_wpInitData(WPPrgExt *somSelf)
  369. {
  370.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  371.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_wpInitData");
  372.  
  373.     memset((PVOID)somThis, 0, sizeof(WPPrgExtData));
  374.     _folderClose = DONOTCLOSE;
  375.  
  376.     parent_wpInitData(somSelf);
  377. }
  378.  
  379. /*************************************************************************
  380.  * 
  381.  *  OVERRIDE: wpUnInitData
  382.  * 
  383.  *  DESCRIPTION:
  384.  * 
  385.  *    Clear up memory that was allocated on wpInitData
  386.  * 
  387.  *************************************************************************/
  388.  
  389. SOM_Scope void   SOMLINK wpprgext_wpUnInitData(WPPrgExt *somSelf)
  390. {
  391.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  392.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_wpUnInitData");
  393.  
  394.     parent_wpUnInitData(somSelf);
  395. }
  396.  
  397. /*************************************************************************
  398.  * 
  399.  *  OVERRIDE: wpSaveState
  400.  * 
  401.  *  DESCRIPTION:
  402.  * 
  403.  *    Save state variable (folder close flag)
  404.  * 
  405.  *************************************************************************/
  406.  
  407. SOM_Scope BOOL   SOMLINK wpprgext_wpSaveState(WPPrgExt *somSelf)
  408. {
  409.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  410.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_wpSaveState");
  411.  
  412.     _wpSaveLong(somSelf, szWPPrgExtClassTitle, IDKEY_FOLDER, _folderClose);
  413.  
  414.     return (parent_wpSaveState(somSelf));
  415. }
  416.  
  417. /*************************************************************************
  418.  * 
  419.  *  OVERRIDE: wpRestoreState
  420.  * 
  421.  *  DESCRIPTION:
  422.  * 
  423.  *    Restore saved state variable
  424.  * 
  425.  *************************************************************************/
  426.  
  427. SOM_Scope BOOL   SOMLINK wpprgext_wpRestoreState(WPPrgExt *somSelf, ULONG ulReserved)
  428. {
  429.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  430.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_wpRestoreState");
  431.  
  432.     _wpRestoreLong(somSelf, szWPPrgExtClassTitle, IDKEY_FOLDER, &_folderClose);
  433.  
  434.     return (parent_wpRestoreState(somSelf,ulReserved));
  435. }
  436.  
  437. /*************************************************************************
  438.  * 
  439.  *  OVERRIDE: wpAddSettingsPages
  440.  * 
  441.  *  DESCRIPTION:
  442.  * 
  443.  *    Add folder settings page to let the user alter the flag
  444.  * 
  445.  *************************************************************************/
  446.  
  447. SOM_Scope BOOL   SOMLINK wpprgext_wpAddSettingsPages(WPPrgExt *somSelf, HWND hwndNotebook)
  448. {
  449.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  450.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_wpAddSettingsPages");
  451.  
  452.     if (parent_wpAddSettingsPages(somSelf, hwndNotebook) && _AddFolderOptionPage(somSelf, hwndNotebook) && _AddFolderKeyPage(somSelf, hwndNotebook)) {
  453.         return (TRUE);
  454.     } else {
  455.         return (FALSE);
  456.     }
  457.   
  458. }
  459.  
  460. /*************************************************************************
  461.  * 
  462.  *   METHOD: wpOpen                                        
  463.  *                                                         
  464.  *   DESCRIPTION:
  465.  * 
  466.  *     Opens the program object window. Close folder upon openning 
  467.  *     according to folderClose flag
  468.  * 
  469.  *************************************************************************/
  470.  
  471. SOM_Scope HWND   SOMLINK wpprgext_wpOpen(WPPrgExt *somSelf, HWND hwndCnr, ULONG ulView, ULONG param)
  472. {
  473.     ULONG longSize = sizeof(LONG);
  474.     LONG keyState;
  475.     BOOL close;
  476.     HWND hwndTop;
  477.     HWND hwndClient;
  478.     CHAR className[CCHMAXPATH];
  479.  
  480.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  481.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_wpOpen");
  482.  
  483.     if (!_wpSwitchTo(somSelf, ulView)) {
  484.  
  485.         /*
  486.          * Get close key scancode from system profile
  487.          */
  488.  
  489.         if (!PrfQueryProfileData(HINI_USERPROFILE, "WPPrgExt", "WPPrgExt", (PVOID)&virtualKey, &longSize))
  490.             virtualKey = VK_SHIFT;
  491.  
  492.         /*
  493.          * Get the state of shift keys so that we can close the parent
  494.          * folder if shift key is pressed
  495.          */
  496.         keyState = WinGetKeyState(HWND_DESKTOP, virtualKey);
  497.  
  498.         if (keyState & 0x8000)
  499.             close = TRUE;
  500.         else {
  501.  
  502.             /*
  503.              * Check for the flags in the Folder page in settings notebook
  504.              */
  505.             switch (ulView) {
  506.  
  507.                 case OPEN_SETTINGS:
  508.  
  509.                     if (_folderClose & CLOSENOTEBOOK)
  510.                         close = TRUE;
  511.                     else
  512.                         close = FALSE;
  513.  
  514.                     break;
  515.  
  516.                 case OPEN_RUNNING:
  517.  
  518.                     if (_folderClose & CLOSEPROGRAM)
  519.                         close = TRUE;
  520.                     else
  521.                         close = FALSE;
  522.  
  523.                     break;
  524.  
  525.                 default:
  526.                     close = FALSE;
  527.  
  528.             }
  529.         }
  530.  
  531.         if (close) {
  532.             /*
  533.              * The active window before opening the new folder must be
  534.              * the parent folder. If it's not the desktop window (if there
  535.              * are no window below the parent folder in z-order), close the
  536.              * parent window
  537.              */
  538.             if (((hwndTop = WinQueryActiveWindow(HWND_DESKTOP)) != NULLHANDLE) && (WinQueryWindow(hwndTop, QW_NEXT) != NULLHANDLE)) {
  539.  
  540.                 if ((hwndClient = WinWindowFromID(hwndTop, FID_CLIENT)) != NULLHANDLE) {
  541.                     WinQueryClassName(hwndClient, sizeof(className), className);
  542.  
  543.                     if (strcmp(className, "#37") == 0)
  544.                         WinSendMsg(hwndTop, WM_CLOSE, (MPARAM)0, (MPARAM)0);
  545.  
  546.                 }
  547.             }
  548.         }
  549.     }
  550.  
  551.     /*
  552.      * Call the original wpOpen
  553.      */
  554.     hwndTop = parent_wpOpen(somSelf, hwndCnr, ulView, param);
  555.  
  556.     /*
  557.      * If the parent window is closed, the newly created folder loses it's focus.
  558.      * I don't know why, but this will give it the focus back
  559.      */
  560.     if (close)
  561.        WinSetFocus(HWND_DESKTOP, hwndTop);
  562.  
  563.  
  564.     return hwndTop;
  565. }
  566.  
  567. /*************************************************************************
  568.  * 
  569.  *  OVERRIDE: wpSetup
  570.  * 
  571.  *  DESCRIPTION:
  572.  * 
  573.  *    Specift setup strings and do some initialization
  574.  * 
  575.  *************************************************************************/
  576.  
  577. SOM_Scope BOOL   SOMLINK wpprgext_wpSetup(WPPrgExt *somSelf, PSZ pszSetupString)
  578. {
  579.     WPPrgExtData *somThis = WPPrgExtGetData(somSelf);
  580.     WPPrgExtMethodDebug("WPPrgExt","wpprgext_wpSetup");
  581.  
  582.     return (parent_wpSetup(somSelf,pszSetupString));
  583. }
  584.  
  585. #undef SOM_CurrentClass
  586. #define SOM_CurrentClass SOMMeta
  587.  
  588. /*************************************************************************/
  589. /*                                                                       */
  590. /*                      Class Method Implementation                      */
  591. /*                                                                       */
  592. /*************************************************************************/
  593.  
  594. /*************************************************************************
  595.  *
  596.  *  METHOD: clsQueryModuleHandle                         ( ) PRIVATE
  597.  *                                                       (X) PUBLIC
  598.  *  DESCRIPTION:
  599.  *
  600.  *    This method returns the module handle of this class.
  601.  *
  602.  *  RETURN:
  603.  *
  604.  *    0          Unsuccessful
  605.  *    non-zero   Module handle
  606.  *
  607.  *************************************************************************/
  608.  
  609. SOM_Scope HMODULE   SOMLINK wpprgextM_clsQueryModuleHandle(M_WPPrgExt *somSelf)
  610. {
  611.     zString zsPathName;
  612.     APIRET rc;
  613.  
  614.     /* M_WPPrgExtData *somThis = M_WPPrgExtGetData(somSelf); */
  615.     M_WPPrgExtMethodDebug("M_WPPrgExt","wpprgextM_clsQueryModuleHandle");
  616.  
  617.     if (hmod == NULLHANDLE) {
  618.  
  619.        /*
  620.         *   Retrieve registered pathname of our module (DLL) and query the
  621.         *   module handle.
  622.         */
  623.        zsPathName = _somLocateClassFile(SOMClassMgrObject,
  624.                                         SOM_IdFromString("WPPrgExt"),
  625.                                         WPPrgExt_MajorVersion,
  626.                                         WPPrgExt_MinorVersion);
  627.        rc = DosQueryModuleHandle(zsPathName, &hmod);
  628.     }
  629.  
  630.     return (hmod);
  631. }
  632.  
  633. /*************************************************************************/
  634. /*                                                                       */
  635. /*                  Override Class Method Implementation                 */
  636. /*                                                                       */
  637. /*************************************************************************/
  638.  
  639. /*************************************************************************
  640.  * 
  641.  *  METHOD: wpclsInitData
  642.  * 
  643.  *  DESCRIPTION:
  644.  * 
  645.  *    Initialize the class data
  646.  * 
  647.  *************************************************************************/
  648.  
  649. SOM_Scope void   SOMLINK wpprgextM_wpclsInitData(M_WPPrgExt *somSelf)
  650. {
  651.  
  652.     /* M_WPPrgExtData *somThis = M_WPPrgExtGetData(somSelf); */
  653.     M_WPPrgExtMethodDebug("M_WPPrgExt","wpprgextM_wpclsInitData");
  654.  
  655.     parent_wpclsInitData(somSelf);
  656.  
  657.     /* 
  658.      * Get class title
  659.      */
  660.  
  661.     if (!WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), 
  662.                        _clsQueryModuleHandle(somSelf),  
  663.                        ID_TITLE,        
  664.                        sizeof(szWPPrgExtClassTitle),
  665.                        szWPPrgExtClassTitle))
  666.         strcpy(szWPPrgExtClassTitle, parent_wpclsQueryTitle(somSelf));
  667. }
  668.  
  669. /*************************************************************************
  670.  * 
  671.  *  METHOD: wpclsUnInitData
  672.  * 
  673.  *  DESCRIPTION:
  674.  * 
  675.  *    Free any class data
  676.  * 
  677.  *************************************************************************/
  678.  
  679. SOM_Scope void   SOMLINK wpprgextM_wpclsUnInitData(M_WPPrgExt *somSelf)
  680. {
  681.     /* M_WPPrgExtData *somThis = M_WPPrgExtGetData(somSelf); */
  682.     M_WPPrgExtMethodDebug("M_WPPrgExt","wpprgextM_wpclsUnInitData");
  683.  
  684.     parent_wpclsUnInitData(somSelf);
  685. }
  686.  
  687. /*************************************************************************
  688.  *
  689.  *  METHOD: wpclsQueryTitle                                
  690.  *                                                         
  691.  *  DESCRIPTION:
  692.  *
  693.  *    Return the string "Extended Program".
  694.  *
  695.  *************************************************************************/
  696.  
  697. SOM_Scope PSZ   SOMLINK wpprgextM_wpclsQueryTitle(M_WPPrgExt *somSelf)
  698. {
  699.     /* M_WPPrgExtData *somThis = M_WPPrgExtGetData(somSelf); */
  700.     M_WPPrgExtMethodDebug("M_WPPrgExt","wpprgextM_wpclsQueryTitle");
  701.  
  702.     /* 
  703.      * Return the class title for a WPPrgExt
  704.      */
  705.     if (*szWPPrgExtClassTitle)
  706.         return (szWPPrgExtClassTitle);
  707.     else 
  708.         return (parent_wpclsQueryTitle(somSelf));
  709.  
  710. }
  711.  
  712. /*************************************************************************/
  713. /*                                                                       */
  714. /*                   Non-method function implementation                  */
  715. /*                                                                       */
  716. /*************************************************************************/
  717.  
  718. MRESULT EXPENTRY FolderDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  719. {
  720.    PFOLDEROPTION pFolder;
  721.    MRESULT rc;
  722.  
  723.    switch(msg) {
  724.       case WM_INITDLG:
  725.          pFolder = (PFOLDEROPTION)_wpAllocMem((WPPrgExt *)mp2, sizeof(FOLDEROPTION), NULL);
  726.  
  727.          if (pFolder) {
  728.             memset((PVOID)pFolder, 0, sizeof(FOLDEROPTION));
  729.             pFolder->cb = sizeof(FOLDEROPTION);
  730.             pFolder->somSelf = (WPPrgExt *)mp2;
  731.             pFolder->closeFolder = _QueryFolderClose(pFolder->somSelf);
  732.          }
  733.          else 
  734.             break;
  735.  
  736.          WinSetWindowPtr(hwndDlg, QWL_USER, pFolder);
  737.  
  738.          if (pFolder->closeFolder & CLOSENOTEBOOK)
  739.             WinSendMsg(WinWindowFromID(hwndDlg, IDCHECK_CLOSENOTEBOOK), BM_SETCHECK, MPFROMSHORT(1), (MPARAM)0);
  740.          else
  741.             WinSendMsg(WinWindowFromID(hwndDlg, IDCHECK_CLOSENOTEBOOK), BM_SETCHECK, MPFROMSHORT(0), (MPARAM)0);
  742.  
  743.          if (pFolder->closeFolder & CLOSEPROGRAM)
  744.             WinSendMsg(WinWindowFromID(hwndDlg, IDCHECK_CLOSEPROGRAM), BM_SETCHECK, MPFROMSHORT(1), (MPARAM)0);
  745.          else
  746.             WinSendMsg(WinWindowFromID(hwndDlg, IDCHECK_CLOSEPROGRAM), BM_SETCHECK, MPFROMSHORT(0), (MPARAM)0);
  747.  
  748.          return (MRESULT)TRUE;
  749.  
  750.       case WM_CLOSE:
  751.          pFolder = WinQueryWindowPtr(hwndDlg, QWL_USER);
  752.  
  753.          if (pFolder == NULL) 
  754.              break;
  755.  
  756.          _wpFreeMem(pFolder->somSelf, (PBYTE)pFolder);
  757.          return (WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  758.  
  759.       case WM_CONTROL:
  760.          pFolder = WinQueryWindowPtr(hwndDlg, QWL_USER);
  761.  
  762.          if (pFolder == NULL) 
  763.             break;
  764.  
  765.          switch (SHORT1FROMMP(mp1)) {
  766.  
  767.             case IDCHECK_CLOSENOTEBOOK:
  768.  
  769.                if (SHORT2FROMMP(mp1) == BN_CLICKED) {
  770.                   rc = WinSendMsg(WinWindowFromID(hwndDlg, IDCHECK_CLOSENOTEBOOK), BM_QUERYCHECK, (MPARAM)0, (MPARAM)0);
  771.  
  772.                   if ((USHORT)rc == 1)
  773.                      pFolder->closeFolder |= CLOSENOTEBOOK;
  774.                   else if ((USHORT)rc == 0)
  775.                      pFolder->closeFolder &= ~CLOSENOTEBOOK;
  776.  
  777.                   _SetFolderClose(pFolder->somSelf, pFolder->closeFolder);
  778.                }
  779.  
  780.                break;
  781.             case IDCHECK_CLOSEPROGRAM:
  782.  
  783.                if (SHORT2FROMMP(mp1) == BN_CLICKED) {
  784.                   rc = WinSendMsg(WinWindowFromID(hwndDlg, IDCHECK_CLOSEPROGRAM), BM_QUERYCHECK, (MPARAM)0, (MPARAM)0);
  785.  
  786.                   if ((USHORT)rc == 1)
  787.                      pFolder->closeFolder |= CLOSEPROGRAM;
  788.                   else if ((USHORT)rc == 0)
  789.                      pFolder->closeFolder &= ~CLOSEPROGRAM;
  790.  
  791.                   _SetFolderClose(pFolder->somSelf, pFolder->closeFolder);
  792.                }
  793.  
  794.                break;
  795.  
  796.          }
  797.       
  798.          return (MRESULT)TRUE;
  799.    }
  800.  
  801.    return (WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  802.  
  803. /*************************************************************************
  804.  *
  805.  * Window procedure : CloseKeyDlgProc
  806.  *
  807.  *************************************************************************/
  808.  
  809. MRESULT EXPENTRY CloseKeyDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  810. {
  811.    SHORT sCount;
  812.    CHAR str[CCHMAXPATH];
  813.    PFOLDERKEY pFolder;
  814.  
  815.    switch (msg) {
  816.       case WM_INITDLG:
  817.          pFolder = (PFOLDERKEY)_wpAllocMem((WPPrgExt *)mp2, sizeof(FOLDERKEY), NULL);
  818.  
  819.          if (pFolder) {
  820.             memset((PVOID)pFolder, 0, sizeof(FOLDERKEY));
  821.             pFolder->cb = sizeof(FOLDERKEY);
  822.             pFolder->somSelf = (WPPrgExt *)mp2;
  823.          }
  824.          else
  825.             break;
  826.  
  827.          WinSetWindowPtr(hwndDlg, QWL_USER, pFolder);
  828.  
  829.          for (sCount=0; sCount < MAXKEY; sCount++) {
  830.             WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), _clsQueryModuleHandle((M_WPPrgExt *)_somGetClass(pFolder->somSelf)), (ULONG)(IDSC_SHIFT + sCount), CCHMAXPATH, str);
  831.  
  832.             WinSendMsg(WinWindowFromID(hwndDlg, IDCOMBO_KEYSELECTION), LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(str));
  833.          }
  834.  
  835.          _FindKeyFromScancode(pFolder->somSelf, virtualKey, str);
  836.          WinSetWindowText(WinWindowFromID(hwndDlg, IDCOMBO_KEYSELECTION), str);
  837.          return (MRESULT)TRUE;
  838.  
  839.       case WM_CLOSE:
  840.  
  841.          pFolder = WinQueryWindowPtr(hwndDlg, QWL_USER);
  842.  
  843.          if (pFolder == NULL)
  844.              break;
  845.  
  846.          _wpFreeMem(pFolder->somSelf, (PBYTE)pFolder);
  847.          return (WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  848.  
  849.       case WM_CONTROL:
  850.  
  851.          pFolder = WinQueryWindowPtr(hwndDlg, QWL_USER);
  852.  
  853.          if (pFolder == NULL)
  854.             break;
  855.  
  856.          switch (SHORT1FROMMP(mp1)) {
  857.  
  858.             case IDCOMBO_KEYSELECTION:
  859.  
  860.                if (SHORT2FROMMP(mp1) == CBN_ENTER) {
  861.                   WinQueryWindowText(WinWindowFromID(hwndDlg, IDCOMBO_KEYSELECTION), CCHMAXPATH, str);
  862.                   virtualKey = _FindScancodeFromKey(pFolder->somSelf, str);
  863.                   PrfWriteProfileData(HINI_USERPROFILE, "WPPrgExt", "WPPrgExt", &virtualKey, sizeof(LONG));
  864.                }
  865.  
  866.                break;
  867.          }
  868.  
  869.          return (MRESULT)TRUE;
  870.    }
  871.  
  872.    return (WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  873. }
  874.  
  875.