home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: WPS_PM / WPS_PM.zip / xfld085s.zip / main / xfpgmf.c < prev    next >
C/C++ Source or Header  |  1999-02-22  |  26KB  |  646 lines

  1.  
  2. /*
  3.  *@@sourcefile xfpgmf.c:
  4.  *      This file contains the following major XFolder parts:
  5.  *
  6.  *      --  XFldProgramFile SOM stuff
  7.  *
  8.  *      Check the other files starting with xf* for the
  9.  *      other XFolder classes.
  10.  *
  11.  *      XFldProgram is only responsible for changing the
  12.  *      default icons of executable files.
  13.  *
  14.  *      Installation of this class is optional.
  15.  *
  16.  *@@somclass XFldProgramFile xfpgmf_
  17.  *@@somclass M_XFldProgramFile xfpgmfM_
  18.  */
  19.  
  20. /*
  21.  *      Copyright (C) 1997-99 Ulrich Möller.
  22.  *      This file is part of the XFolder source package.
  23.  *      XFolder is free software; you can redistribute it and/or modify
  24.  *      it under the terms of the GNU General Public License as published
  25.  *      by the Free Software Foundation, in version 2 as it comes in the
  26.  *      "COPYING" file of the XFolder main distribution.
  27.  *      This program is distributed in the hope that it will be useful,
  28.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  29.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  30.  *      GNU General Public License for more details.
  31.  */
  32.  
  33. /*
  34.  *  This file was generated by the SOM Compiler and Emitter Framework.
  35.  *  Generated using:
  36.  *      SOM Emitter emitctm: 2.41
  37.  */
  38.  
  39. #ifndef SOM_Module_xfpgmf_Source
  40. #define SOM_Module_xfpgmf_Source
  41. #endif
  42. #define XFldProgramFile_Class_Source
  43. #define M_XFldProgramFile_Class_Source
  44.  
  45. /*
  46.  *  Suggested #include order:
  47.  *  1)  os2.h
  48.  *  2)  C library headers
  49.  *  3)  SOM headers which work with precompiled header files
  50.  *  4)  headers in /helpers
  51.  *  5)  headers in /main with dlgids.h and common.h first
  52.  *  6)  #pragma hdrstop to prevent VAC++ crashes
  53.  *  7)  other needed SOM headers
  54.  *  8)  for non-SOM-class files: corresponding header (e.g. classlst.h)
  55.  */
  56.  
  57. #define INCL_DOSSESMGR          // DosQueryAppType
  58. #define INCL_DOSERRORS
  59. #define INCL_WINPROGRAMLIST     // needed for WPProgram
  60. #define INCL_WINPOINTERS
  61. #include <os2.h>
  62.  
  63. // C library headers
  64. #include <stdio.h>
  65.  
  66. // headers in /helpers
  67.  
  68. // SOM headers which don't crash with prec. header files
  69.  
  70. // other SOM headers
  71. #pragma hdrstop                 // VAC++ keeps crashing otherwise
  72. #include "xfpgmf.ih"
  73.  
  74. // headers in /main
  75. #include "common.h"             // the majestic XFolder include file
  76.  
  77.  
  78. /* ******************************************************************
  79.  *                                                                  *
  80.  *   Global variables                                               *
  81.  *                                                                  *
  82.  ********************************************************************/
  83.  
  84.  
  85. /* ******************************************************************
  86.  *                                                                  *
  87.  *   here come the XFldProgramFile instance methods                 *
  88.  *                                                                  *
  89.  ********************************************************************/
  90.  
  91. /*
  92.  *@@ xfQueryProgType:
  93.  *           this returns the PROG_* flag signalling the executable
  94.  *           type of the program file.
  95.  *           Note that in addition to the PROG_* flags defined in
  96.  *           PROGDETAILS, this may also return the following:
  97.  *               PROG_XF_DLL     for dynamic link libraries
  98.  *               PROG_XF_DRIVER  for virtual or physical device drivers;
  99.  *                               most files ending in .SYS will be
  100.  *                               recognized as DLL's though.
  101.  */
  102.  
  103. SOM_Scope ULONG  SOMLINK xfpgmf_xfQueryProgType(XFldProgramFile *somSelf)
  104. {
  105.     PPROGDETAILS    pProgDetails;
  106.     ULONG           ulSize;
  107.  
  108.     XFldProgramFileData *somThis = XFldProgramFileGetData(somSelf);
  109.     XFldProgramFileMethodDebug("XFldProgramFile","xfpgmf_xfQueryProgType");
  110.  
  111.     #ifdef DEBUG_ASSOCS
  112.         _Pmpf(("  xfQueryProgType %s, before: 0x%lX",
  113.             _wpQueryTitle(somSelf), _ulAppType));
  114.     #endif
  115.  
  116.     if (_ulAppType == -1)
  117.     {
  118.         // not queried yet:
  119.  
  120.         // get program object data
  121.         if ((_wpQueryProgDetails(somSelf, (PPROGDETAILS)NULL, &ulSize))) {
  122.             if ((pProgDetails = (PPROGDETAILS)malloc(ulSize)) != NULL) {
  123.                 if ((_wpQueryProgDetails(somSelf, pProgDetails, &ulSize)))
  124.                 {
  125.                     // we base our assumptions on what OS/2 thinks
  126.                     // the app type is
  127.                     _ulAppType = pProgDetails->progt.progc;
  128.  
  129.                     #ifdef DEBUG_ASSOCS
  130.                         _Pmpf(("    progdtls.progc: 0x%lX",
  131.                                     _ulAppType));
  132.                     #endif
  133.  
  134.                     // and we modify a few of these assumptions
  135.                     switch (_ulAppType)
  136.                     {
  137.                         case PROG_PDD:
  138.                         case PROG_VDD:
  139.                             // these two types are documented in pmshl.h,
  140.                             // but I'm not sure they're ever used; convert
  141.                             // them to our own driver type
  142.                             _ulAppType = PROG_XF_DRIVER;
  143.                         break;
  144.  
  145.                         // Windows:
  146.                         case PROG_WINDOW_REAL         :
  147.                         case PROG_30_STD              :
  148.                         case PROG_WINDOW_AUTO         :
  149.                         case PROG_30_STDSEAMLESSVDM   :
  150.                         case PROG_30_STDSEAMLESSCOMMON:
  151.                         case PROG_31_STDSEAMLESSVDM   :
  152.                         case PROG_31_STDSEAMLESSCOMMON:
  153.                         case PROG_31_ENHSEAMLESSVDM   :
  154.                         case PROG_31_ENHSEAMLESSCOMMON:
  155.                         case PROG_31_ENH              :
  156.                         case PROG_31_STD              :
  157.                         {
  158.                             // for all the Windows app types, we check
  159.                             // for whether the extension of the file is
  160.                             // DLL or 386; if so, we change the type to
  161.                             // DLL. Otherwise,  all Windows DLL's get
  162.                             // some default windoze icon.
  163.                             CHAR    szProgramFile[CCHMAXPATH];
  164.                             if (_wpQueryFilename(somSelf, szProgramFile, FALSE))
  165.                             {
  166.                                 PSZ     pLastDot = strrchr(szProgramFile, '.');
  167.                                 strupr(szProgramFile);
  168.                                 if (strcmp(pLastDot, ".DLL") == 0)
  169.                                     // DLL found:
  170.                                     _ulAppType = PROG_XF_DLL;
  171.                             }
  172.                         break; }
  173.  
  174.                         case PROG_DEFAULT:  // == 0; OS/2 isn't sure what this is
  175.                         {
  176.                             CHAR        szProgramFile[CCHMAXPATH];
  177.                             APIRET      arc;
  178.  
  179.                             if (_wpQueryFilename(somSelf, szProgramFile, TRUE))
  180.                             {
  181.                                 // no type available: get it ourselves
  182.                                 arc = DosQueryAppType(szProgramFile, &(_ulDosAppType));
  183.                                 if (arc == NO_ERROR) {
  184.                                     if (_ulDosAppType == 0)
  185.                                         _ulAppType = PROG_FULLSCREEN;
  186.                                     else if (   (_ulDosAppType & 0x40)
  187.                                              || (_ulDosAppType & 0x80)
  188.                                             )
  189.                                         // some driver bit set
  190.                                         _ulAppType = PROG_XF_DRIVER;
  191.                                     else if ((_ulDosAppType & 0xF0) == 0x10)
  192.                                         // DLL bit set
  193.                                         _ulAppType = PROG_XF_DLL;
  194.                                     else if (_ulDosAppType & 0x20)
  195.                                         // DOS bit set?
  196.                                         _ulAppType = PROG_WINDOWEDVDM;
  197.                                     else if ((_ulDosAppType & 0x0003) == 0x0003) // "Window-API" == PM
  198.                                         _ulAppType = PROG_PM;
  199.                                     else if (   ((_ulDosAppType & 0xFFFF) == 0x1000) // windows program (?!?)
  200.                                              || ((_ulDosAppType & 0xFFFF) == 0x0400) // windows program (?!?)
  201.                                             )
  202.                                         _ulAppType = PROG_31_ENH;
  203.                                     else if ((_ulDosAppType & 0x03) == 0x02)
  204.                                         _ulAppType = PROG_WINDOWABLEVIO;
  205.                                     else if ((_ulDosAppType & 0x03) == 0x01)
  206.                                         _ulAppType = PROG_FULLSCREEN;
  207.                                 }
  208.                             }
  209.                         break; }
  210.  
  211.                         // the other values are OK, leave them as is
  212.  
  213.                     } // end switch (_ulAppType)
  214.                 }
  215.                 free(pProgDetails);
  216.             }
  217.         }
  218.     }
  219.  
  220.     #ifdef DEBUG_ASSOCS
  221.         _Pmpf(("  End of xfQueryProgType, returning: 0x%lX",
  222.                 _ulAppType));
  223.     #endif
  224.  
  225.     return (_ulAppType);
  226.  
  227. }
  228.  
  229. /*
  230.  *@@ wpInitData:
  231.  *           initialize instance data for a program file
  232.  */
  233.  
  234. SOM_Scope void  SOMLINK xfpgmf_wpInitData(XFldProgramFile *somSelf)
  235. {
  236.     XFldProgramFileData *somThis = XFldProgramFileGetData(somSelf);
  237.     XFldProgramFileMethodDebug("XFldProgramFile","xfpgmf_wpInitData");
  238.  
  239.     // initialize instance data
  240.     _ulDosAppType = -1;
  241.     _ulAppType = -1;
  242.     _fProgIconSet = FALSE;
  243.     _hptrThis = NULLHANDLE;
  244.  
  245.     XFldProgramFile_parent_WPProgramFile_wpInitData(somSelf);
  246. }
  247.  
  248. /*
  249.  *@@ wpObjectReady:
  250.  *           this is called upon an object when its creation
  251.  *           or awakening is complete. This is the last method
  252.  *           which gets called during instantiation of a
  253.  *           WPS object.
  254.  *           For XFldProgramFile, we need this notification to
  255.  *           reset the icon data in our instance data, because
  256.  *           otherwise we get wrong icons when copying program
  257.  *           files.
  258.  */
  259.  
  260. SOM_Scope void  SOMLINK xfpgmf_wpObjectReady(XFldProgramFile *somSelf,
  261.                                              ULONG ulCode, WPObject* refObject)
  262. {
  263.     XFldProgramFileData *somThis = XFldProgramFileGetData(somSelf);
  264.     XFldProgramFileMethodDebug("XFldProgramFile","xfpgmf_wpObjectReady");
  265.  
  266.     // _Pmpf(("  %s: wpObjectReady", _wpQueryTitle(somSelf) ));
  267.     // reset our app type flags, because when program files
  268.     // are _copied_, wpSetProgIcon gets called one time too early
  269.     // (between wpInitData and wpObjectReady; at this point,
  270.     // the PROGDETAILS have no meaningful values, and xfQueryProgType
  271.     // has returned garbage data),
  272.     // and a second time in time (after wpObjectReady);
  273.     // for this second time we need to pretend that we haven't
  274.     // queried the app type yet, because for the second call
  275.     // of wpSetProgIcon, the icon will then be set correctly
  276.     _ulDosAppType = -1;
  277.     _ulAppType = -1;
  278.  
  279.     XFldProgramFile_parent_WPProgramFile_wpObjectReady(somSelf,
  280.                                                        ulCode,
  281.                                                        refObject);
  282.     // _Pmpf(("  End of wpObjectReady"));
  283. }
  284.  
  285. /*
  286.  *@@ wpQueryStyle:
  287.  *           this instance method returns the object style flags.
  288.  */
  289.  
  290. SOM_Scope ULONG  SOMLINK xfpgmf_wpQueryStyle(XFldProgramFile *somSelf)
  291. {
  292.     ULONG ulStyle = 0;
  293.     // XFldProgramFileData *somThis = XFldProgramFileGetData(somSelf);
  294.     XFldProgramFileMethodDebug("XFldProgramFile","xfpgmf_wpQueryStyle");
  295.  
  296.     ulStyle = XFldProgramFile_parent_WPProgramFile_wpQueryStyle(somSelf);
  297.  
  298.     #ifdef DEBUG_ASSOCS
  299.         _Pmpf(("%s: wpQueryStyle: 0x%lX %s %s",
  300.                     _wpQueryTitle(somSelf),
  301.                     ulStyle,
  302.                     (ulStyle & OBJSTYLE_NOTDEFAULTICON) ? "OBJSTYLE_NOTDEFAULTICON" : "",
  303.                     (ulStyle & OBJSTYLE_CUSTOMICON) ? "OBJSTYLE_CUSTOMICON" : ""));
  304.     #endif
  305.     return (ulStyle /* & ~OBJSTYLE_CUSTOMICON */);
  306. }
  307.  
  308. /*
  309.  *@@ wpSetIcon:
  310.  *           this instance method sets the visual icon for
  311.  *           this program file. This is not stored in the
  312.  *           persistent data (which is only done in
  313.  *           wpSetIconData), but only changes the visual
  314.  *           appearance of the object.
  315.  */
  316.  
  317. SOM_Scope BOOL  SOMLINK xfpgmf_wpSetIcon(XFldProgramFile *somSelf,
  318.                                          HPOINTER hptrNewIcon)
  319. {
  320.     BOOL brc = TRUE;
  321.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  322.     XFldProgramFileMethodDebug("XFldProgramFile","xfpgmf_wpSetIcon");
  323.  
  324.     #ifdef DEBUG_ASSOCS
  325.         _Pmpf(("    %s wpSetIcon", _wpQueryTitle(somSelf) ));
  326.     #endif
  327.     // icon replacements allowed?
  328.     /* if (pGlobalSettings->ReplIcons) {
  329.         XFldProgramFileData *somThis = XFldProgramFileGetData(somSelf);
  330.         // we only allow the icon to be changed if
  331.         // this is a call from _wpSetProgIcon (which
  332.         // we have overriden) or if the WPS calls this
  333.         // method for the first time, e.g. because it is
  334.         // being set by some method other than wpSetProgIcon,
  335.         // which happens if the WPS has determined the icon
  336.         // from the executable or .ICON EA's.
  337.         if (    (_hptrThis == NULLHANDLE)
  338.              || (_fProgIconSet)
  339.            )
  340.         {
  341.             _hptrThis = hptrNewIcon;
  342.             brc = XFldProgramFile_parent_WPProgramFile_wpSetIcon(somSelf,
  343.                                                                    hptrNewIcon);
  344.             // prohibit subsequent calls
  345.             _fProgIconSet = FALSE;
  346.         }
  347.         // else: ignore the call. The WPS keeps messing with
  348.         // program icons from methods other than _wpSetProgIcon,
  349.         // which we must ignore.
  350.  
  351.     } else */
  352.         brc = XFldProgramFile_parent_WPProgramFile_wpSetIcon(somSelf,
  353.                                                                hptrNewIcon);
  354.  
  355.     return (brc);
  356. }
  357.  
  358. /*
  359.  *@@ wpSetProgIcon:
  360.  *           this instance method sets the visual icon for
  361.  *           this program file to the appropriate custom
  362.  *           or default icon. We override this to change
  363.  *           the default icons for program files using
  364.  *           /ICONS/ICONS.DLL, if the global settings allow
  365.  *           this.
  366.  *           The following methods are called by the WPS when
  367.  *           an icon is to be determined for a WPProgramFile:
  368.  *           -- if the file has its own icon, e.g. from the
  369.  *              .ICON EAs: only wpSetIcon, this method does
  370.  *              _not_ get called then.
  371.  *           -- otherwise (no .ICON):
  372.  *              1)  wpQueryIcon, which calls
  373.  *              2)  wpSetProgIcon, which per default calls
  374.  *              3)  wpSetIcon
  375.  *           We must return an individual icon in this method,
  376.  *           so we load the icons from /ICONS/ICONS.DLL every
  377.  *           time we arrive here.
  378.  *           If we return a "global" icon handle which could
  379.  *           have been loaded in wpclsInitData, unfortunately
  380.  *           the WPS will destroy that "global" icon, ruining
  381.  *           the icons of all other program files also.
  382.  */
  383.  
  384. SOM_Scope BOOL  SOMLINK xfpgmf_wpSetProgIcon(XFldProgramFile *somSelf,
  385.                                              PFEA2LIST pfeal)
  386. {
  387.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  388.     HPOINTER    hptr = NULLHANDLE;
  389.  
  390.     XFldProgramFileData *somThis = XFldProgramFileGetData(somSelf);
  391.     XFldProgramFileMethodDebug("XFldProgramFile","xfpgmf_wpSetProgIcon");
  392.  
  393.     // icon replacements allowed?
  394.     if (pGlobalSettings->ReplIcons) {
  395.         CHAR        szProgramFile[CCHMAXPATH];
  396.         HMODULE     hmodIconsDLL = cmnQueryIconsDLL();
  397.         APIRET      arc = NO_ERROR;
  398.  
  399.         #ifdef DEBUG_ASSOCS
  400.             _Pmpf(("%s: wpSetProgIcon",
  401.                         _wpQueryTitle(somSelf) ));
  402.         #endif
  403.  
  404.         if (_wpQueryFilename(somSelf, szProgramFile, TRUE))
  405.         {
  406.  
  407.             // first: check if an .ICO file of the same filestem
  408.             // exists in the folder. If so, _always_ use that icon.
  409.             PSZ p = strrchr(szProgramFile, '.');
  410.             if (p) {
  411.                 CHAR szIconFile[CCHMAXPATH];
  412.                 strncpy(szIconFile, szProgramFile, (p-szProgramFile));
  413.                 strcpy(szIconFile + (p-szProgramFile), ".ico");
  414.                 #ifdef DEBUG_ASSOCS
  415.                     _Pmpf(("   Icon file: %s", szIconFile));
  416.                 #endif
  417.                 hptr = WinLoadFileIcon(szIconFile, TRUE);
  418.             }
  419.  
  420.             if (!hptr)
  421.             {
  422.                 // no such .ICO file exists:
  423.                 // examine the application type we have
  424.                 switch (_xfQueryProgType(somSelf))
  425.                 {
  426.  
  427.                     // PM:
  428.                     case PROG_PM                  :
  429.                     // Windows:
  430.                     case PROG_WINDOW_REAL         :
  431.                     case PROG_30_STD              :
  432.                     case PROG_WINDOW_AUTO         :
  433.                     case PROG_30_STDSEAMLESSVDM   :
  434.                     case PROG_30_STDSEAMLESSCOMMON:
  435.                     case PROG_31_STDSEAMLESSVDM   :
  436.                     case PROG_31_STDSEAMLESSCOMMON:
  437.                     case PROG_31_ENHSEAMLESSVDM   :
  438.                     case PROG_31_ENHSEAMLESSCOMMON:
  439.                     case PROG_31_ENH              :
  440.                     case PROG_31_STD              :
  441.                     {
  442.                         // have PM determine the icon
  443.                         hptr = WinLoadFileIcon(szProgramFile, TRUE);
  444.                     break; }
  445.  
  446.                     case PROG_WINDOWABLEVIO:
  447.                     {
  448.                         // "window compatible":
  449.                         // OS/2 window icon
  450.                         hptr = WinLoadPointer(HWND_DESKTOP, hmodIconsDLL,
  451.                                108);
  452.                     break; }
  453.  
  454.                     case PROG_FULLSCREEN:
  455.                     {
  456.                         // "not window compatible":
  457.                         // OS/2 fullscreen icon
  458.                         hptr = WinLoadPointer(HWND_DESKTOP, hmodIconsDLL,
  459.                                107);
  460.                     break; }
  461.  
  462.                     case PROG_WINDOWEDVDM:
  463.                     {
  464.                         // DOS window
  465.                         hptr = WinLoadPointer(HWND_DESKTOP, hmodIconsDLL,
  466.                                105);
  467.                     break; }
  468.  
  469.                     case PROG_VDM: // == PROG_REAL
  470.                     {
  471.                         // DOS fullscreen
  472.                         hptr = WinLoadPointer(HWND_DESKTOP, hmodIconsDLL,
  473.                                104);
  474.                     break; }
  475.  
  476.                     case PROG_XF_DLL:
  477.                     {   // DLL flag set: load DLL icon
  478.                         hptr = WinLoadPointer(HWND_DESKTOP, hmodIconsDLL,
  479.                                103);
  480.                     break; }
  481.  
  482.                     case PROG_XF_DRIVER:
  483.                     {
  484.                         hptr = WinLoadPointer(HWND_DESKTOP, hmodIconsDLL,
  485.                                106);
  486.                     break; }
  487.  
  488.                     default:
  489.                     {
  490.                         // unknown:
  491.                         hptr = WinLoadPointer(HWND_DESKTOP, hmodIconsDLL,
  492.                                102);
  493.                     }
  494.  
  495.                 }
  496.             }
  497.         }
  498.     }
  499.  
  500.     if (hptr == NULLHANDLE) {
  501.         // replacement icon does not exist in /ICONS
  502.         // or Global Settings do not allow replacements:
  503.         // call default parent method
  504.         return (XFldProgramFile_parent_WPProgramFile_wpSetProgIcon(somSelf,
  505.                                                            pfeal));
  506.     }
  507.     // else:
  508.  
  509.     // set a flag for our wpSetIcon override
  510.     _fProgIconSet = TRUE;
  511.  
  512.     // some icon from /ICONS found: set it
  513.     _wpSetIcon(somSelf, hptr);
  514.  
  515.     #ifdef DEBUG_ASSOCS
  516.         _Pmpf(("End of xfpgmf_wpSetProgIcon"));
  517.     #endif
  518.  
  519.     return (TRUE);
  520. }
  521.  
  522. /*
  523.  *@@ wpQueryDefaultView:
  524.  *           this returns the default view of an object, that
  525.  *           is, which view is opened if the program file is
  526.  *           double-clicked upon. This is also used to mark
  527.  *           the default view in the "Open" context submenu.
  528.  *           For WPProgramFile, the WPS always returns
  529.  *           OPEN_RUNNING (0x04), which doesn't make sense
  530.  *           for DLL's and drivers, which cannot be executed.
  531.  *           We therefore return the value for "first associated
  532.  *           program", which is 0x1000.
  533.  *           Oh yes, as usual, this value is undocumented. ;-)
  534.  */
  535.  
  536. SOM_Scope ULONG  SOMLINK xfpgmf_wpQueryDefaultView(XFldProgramFile *somSelf)
  537. {
  538.     ULONG ulView;
  539.     ULONG ulProgType = _xfQueryProgType(somSelf);
  540.  
  541.     XFldProgramFileData *somThis = XFldProgramFileGetData(somSelf);
  542.     XFldProgramFileMethodDebug("XFldProgramFile","xfpgmf_wpQueryDefaultView");
  543.  
  544.     #ifdef DEBUG_ASSOCS
  545.         _Pmpf(( "wpQueryDefaultView for %s", _wpQueryTitle(somSelf) ));
  546.     #endif
  547.  
  548.     ulView = XFldProgramFile_parent_WPProgramFile_wpQueryDefaultView(somSelf);
  549.  
  550.     if (    (ulProgType == PROG_XF_DLL)
  551.          || (ulProgType == PROG_XF_DRIVER)
  552.          || (ulProgType == PROG_DEFAULT)
  553.        )
  554.         if (ulView == OPEN_RUNNING)
  555.             // we can neither run DLL's nor drivers, so we
  556.             // pass the first context menu item
  557.             ulView = 0x1000;        // this is the WPS internal code
  558.                                     // for the first association view
  559.  
  560.     return (ulView);
  561. }
  562.  
  563. /*
  564.  *@@ wpFilterPopupMenu:
  565.  *           remove the "Program" context menu entry for
  566.  *           DLL's and drivers
  567.  */
  568.  
  569. SOM_Scope ULONG  SOMLINK xfpgmf_wpFilterPopupMenu(XFldProgramFile *somSelf,
  570.                                                   ULONG ulFlags,
  571.                                                   HWND hwndCnr,
  572.                                                   BOOL fMultiSelect)
  573. {
  574.     ULONG ulFilter;
  575.     ULONG ulProgType = _xfQueryProgType(somSelf);
  576.  
  577.     /* XFldProgramFileData *somThis = XFldProgramFileGetData(somSelf); */
  578.     XFldProgramFileMethodDebug("XFldProgramFile","xfpgmf_wpFilterPopupMenu");
  579.  
  580.     ulFilter = XFldProgramFile_parent_WPProgramFile_wpFilterPopupMenu(somSelf,
  581.                                                                    ulFlags,
  582.                                                                    hwndCnr,
  583.                                                                    fMultiSelect);
  584.     if (    (ulProgType == PROG_XF_DLL)
  585.          || (ulProgType == PROG_XF_DRIVER)
  586.          || (ulProgType == PROG_DEFAULT)
  587.        )
  588.         ulFilter &= ~ CTXT_PROGRAM;
  589.  
  590.     return (ulFilter);
  591. }
  592.  
  593. /* ******************************************************************
  594.  *                                                                  *
  595.  *   here come the XFldProgramFile class methods                    *
  596.  *                                                                  *
  597.  ********************************************************************/
  598.  
  599. /*
  600.  *@@ wpclsInitData:
  601.  *           we override this to initialize the path for the
  602.  *           custom XFolder icons from the /ICONS directory.
  603.  */
  604.  
  605. SOM_Scope void  SOMLINK xfpgmfM_wpclsInitData(M_XFldProgramFile *somSelf)
  606. {
  607.     // M_XFldProgramFileData *somThis = M_XFldProgramFileGetData(somSelf);
  608.     M_XFldProgramFileMethodDebug("M_XFldProgramFile","xfpgmfM_wpclsInitData");
  609.  
  610.     M_XFldProgramFile_parent_M_WPProgramFile_wpclsInitData(somSelf);
  611. }
  612.  
  613. CHAR szInstanceFilter[100];
  614.  
  615. /*
  616.  *@@ wpclsQueryInstanceFilter:
  617.  *           this class method determines which file-system objects
  618.  *           will be instances of WPProgramFile/XFldProgramFile
  619.  *           by specifying a file title filter. To avoid the annoying
  620.  *           behavior of OS/2 Warp 4 that some DLL's are instances
  621.  *           of WPProgramFile and some are not, we make all DLL's
  622.  *           instances of WPProgramFile by specifying "*.DLL" too.
  623.  *           This does not work using wpclsQueryInstance type,
  624.  *           because the WPS seems to be using some default file
  625.  *           type of "Executable", which is determined in some hidden
  626.  *           place.
  627.  */
  628.  
  629. SOM_Scope PSZ  SOMLINK xfpgmfM_wpclsQueryInstanceFilter(M_XFldProgramFile *somSelf)
  630. {
  631.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  632.     /* M_XFldProgramFileData *somThis = M_XFldProgramFileGetData(somSelf); */
  633.     M_XFldProgramFileMethodDebug("M_XFldProgramFile","xfpgmfM_wpclsQueryInstanceFilter");
  634.  
  635.     if (    (somSelf == _XFldProgramFile)
  636.          && (pGlobalSettings->ReplIcons)
  637.        )
  638.     {
  639.         strcpy(szInstanceFilter, "*.ADD,*.COM,*.DLL,*.DMD,*.EXE,*.FLT,*.IFS,*.SNP,*.SYS");
  640.         return (szInstanceFilter);
  641.     }
  642.     else
  643.         return (M_XFldProgramFile_parent_M_WPProgramFile_wpclsQueryInstanceFilter(somSelf));
  644. }
  645.  
  646.