home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cnrexm.zip / FIGURE3.c < prev    next >
Text File  |  1993-04-14  |  4KB  |  88 lines

  1. /* User defined record structure.  Contains RECORDCORE plus
  2.  * application specific fields. */
  3. typedef struct _VEHICLERECORD {
  4.    RECORDCORE   RecordCore;
  5.    PSZ          Year;              /* Year of manufacture             */
  6.    PSZ          Vehicle;           /* Make and Model                  */
  7.    ULONG        Price;             /* Current Value in U.S. Dollars   */
  8.    PSZ          Color;             /* Dominant Color                  */
  9.    ULONG        MPG;               /* Miles Per Gallon                */
  10.    ULONG        CalPerHr;          /* Calories Per Hour               */
  11.    ULONG        Mileage;           /* Current Mileage                 */
  12.    BOOL         bGasPowered;       /* TRUE->Gas Powered, FALSE->Manual*/
  13. } VEHICLERECORD, *PVEHICLERECORD;
  14.  
  15. /* Structure definition to set up return values for filter function */
  16. typedef struct _FILTERSTRUCT {
  17.    BOOL         RetVal1;
  18.    BOOL         RetVal2;
  19. } FILTERSTRUCT, *PFILTERSTRUCT;
  20.  
  21.   /* The User wants a subset of the container items.(Process Filtering)
  22.    * This code would be called as a result of the user selecting menu
  23.    * options. */
  24.   case CNR_FILTER_GASPOWERED:
  25.   case CNR_FILTER_MANUAL:
  26.     {
  27.       PFIELDINFO     pFieldInfo;
  28.       FILTERSTRUCT   FilterStruct;
  29.  
  30.       /* Setup Return values.  TRUE->Visible, FALSE->NOT Visible
  31.        * This is so filter function knows whether to filter out
  32.        * Gas Powered objects or Manual Powered objects.
  33.        * Thus, we don't need two separate filter functions. */
  34.       if (SHORT1FROMMP(mp1) == CNR_FILTER_GASPOWERED)
  35.       {
  36.         FilterStruct.RetVal1 = TRUE;
  37.         FilterStruct.RetVal2 = FALSE;
  38.       }
  39.       else
  40.       {
  41.         FilterStruct.RetVal1 = FALSE;
  42.         FilterStruct.RetVal2 = TRUE;
  43.       }
  44.  
  45.       /* Tell the container to start the Filtering Process. */
  46.       WinSendMsg (hwndCnr, CM_FILTER,
  47.                   MPFROMP(pfnFilter), MPFROMP(&FilterStruct));
  48.  
  49.       /* Obtain pointer to the first Details View Column */
  50.       pFieldInfo = (PFIELDINFO)WinSendMsg (hwndCnr, CM_QUERYDETAILFIELDINFO,
  51.                                            NULL, MPFROMSHORT(CMA_FIRST));
  52.  
  53.       /* Iterate through all columns and make visible only those
  54.        * columns that apply to the desired subset.  The pUserData field
  55.        * of the FIELDINFO structure is utilized for this. */
  56.       while (pFieldInfo)
  57.       {
  58.         if (SHORT1FROMMP(mp1) == CNR_FILTER_GASPOWERED)
  59.         {
  60.           /* If the desired subset is Gas-Powered then make the
  61.            * columns labeled with a "2" invisible.
  62.            * "2" -> Manual Powered column only. */
  63.           if (pFieldInfo->pUserData == (PVOID)2))
  64.             pFieldInfo->flData |= CFA_INVISIBLE;
  65.           else
  66.             pFieldInfo->flData &= ~CFA_INVISIBLE;
  67.         }
  68.         else
  69.         {
  70.           /* If the desired subset is Manual then make the
  71.            * columns labeled with a "1" invisible.
  72.            * "1" -> Gas Powered column only. */
  73.           if (pFieldInfo->pUserData == (PVOID)1))
  74.             pFieldInfo->flData |= CFA_INVISIBLE;
  75.           else
  76.             pFieldInfo->flData &= ~CFA_INVISIBLE;
  77.         }
  78.         pFieldInfo = (PFIELDINFO)WinSendMsg (hwndCnr,
  79.                                              CM_QUERYDETAILFIELDINFO,
  80.                                              MPFROMP(pFieldInfo),
  81.                                              MPFROMSHORT(CMA_NEXT));
  82.       }
  83.  
  84.       /* Refresh the Details View completely. */
  85.       WinSendMsg (hwndCnr, CM_INVALIDATEDETAILFIELDINFO, NULL, NULL);
  86.     }
  87.     break;
  88.