home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cnradv.zip / CTXTMENU.C < prev    next >
C/C++ Source or Header  |  1993-07-01  |  70KB  |  1,644 lines

  1. /*********************************************************************
  2.  *                                                                   *
  3.  * MODULE NAME :  ctxtmenu.c             AUTHOR:  Rick Fishman       *
  4.  * DATE WRITTEN:  11-30-92                                           *
  5.  *                                                                   *
  6.  * DESCRIPTION:                                                      *
  7.  *                                                                   *
  8.  *  This module is part of CNRADV.EXE. It contains the functions     *
  9.  *  necessary to implement the container context menu.               *
  10.  *                                                                   *
  11.  * CALLABLE FUNCTIONS:                                               *
  12.  *                                                                   *
  13.  *  VOID CtxtmenuCreate( HWND hwndClient, PCNRITEM pciSelected );    *
  14.  *  VOID CtxtmenuCommand( HWND hwndClient, ULONG idCommand );        *
  15.  *  VOID CtxtmenuSetView( HWND hwndClient, ULONG ulViewType );       *
  16.  *  VOID CtxtmenuEnd( HWND hwndClient );                             *
  17.  *                                                                   *
  18.  * HISTORY:                                                          *
  19.  *                                                                   *
  20.  *  11-30-92 - Source copied from CNRMENU.EXE sample.                *
  21.  *             Added processing of selection-type menu items.        *
  22.  *             Added processing of new items on View submenu.        *
  23.  *             Added ToggleMiniIcons function.                       *
  24.  *  12-05-92 - Added CA_OWNERPAINTBACKGROUND in CtxtmenuSetView.     *
  25.  *             Added processing of Background menu items.            *
  26.  *             Added SetViewType() to cut down CtxtmenuSetView code. *
  27.  *             Added CA_MIXEDTARGETEMPH in CtxtmenuSetView.          *
  28.  *  01-31-93 - Added correct way to do mini icons per IBM.           *
  29.  *               Changed the ToggleMiniIcons function to take out    *
  30.  *               the workaround functionality.                       *
  31.  *  06-06-93 - Added code for the new AutoPosition menu item.        *
  32.  *             Added checking of SelectionType menu item.            *
  33.  *             Added WinSetFocus to container after menu is gone.    *
  34.  *             Added code for the new TargetEmphasis submenu.        *
  35.  *  06-30-93   Added code for IDM_FILTERDIRS menu item.              *
  36.  *                                                                   *
  37.  *  Rick Fishman                                                     *
  38.  *  Code Blazers, Inc.                                               *
  39.  *  4113 Apricot                                                     *
  40.  *  Irvine, CA. 92720                                                *
  41.  *  CIS ID: 72251,750                                                *
  42.  *                                                                   *
  43.  *********************************************************************/
  44.  
  45. #pragma strings(readonly)   // used for debug version of memory mgmt routines
  46.  
  47. /*********************************************************************/
  48. /*------- Include relevant sections of the OS/2 header files --------*/
  49. /*********************************************************************/
  50.  
  51. #define  INCL_WINDIALOGS
  52. #define  INCL_WINERRORS
  53. #define  INCL_WINFRAMEMGR
  54. #define  INCL_WINMENUS
  55. #define  INCL_WINPOINTERS
  56. #define  INCL_WINSTDCNR
  57. #define  INCL_WINSYS
  58. #define  INCL_WINWINDOWMGR
  59.  
  60. /**********************************************************************/
  61. /*----------------------------- INCLUDES -----------------------------*/
  62. /**********************************************************************/
  63.  
  64. #include <os2.h>
  65. #include <stdarg.h>
  66. #include <stdio.h>
  67. #include <stdlib.h>
  68. #include <string.h>
  69. #include "cnradv.h"
  70.  
  71. /*********************************************************************/
  72. /*------------------- APPLICATION DEFINITIONS -----------------------*/
  73. /*********************************************************************/
  74.  
  75. /**********************************************************************/
  76. /*---------------------------- STRUCTURES ----------------------------*/
  77. /**********************************************************************/
  78.  
  79. /**********************************************************************/
  80. /*----------------------- FUNCTION PROTOTYPES ------------------------*/
  81. /**********************************************************************/
  82.  
  83. static VOID   SetViewType         ( ULONG ulViewType, PINSTANCE pi );
  84. static VOID   TurnOffSelFlags     ( HWND hwndCnr );
  85. static VOID   NewWindows          ( HWND hwndClient, BOOL fAllSelected );
  86. static VOID   TurnOnSourceEmphasis( HWND hwndClient );
  87. static VOID   TurnOffSourceEmphasis( HWND hwndClient );
  88. static INT    CountSelectedRecs   ( HWND hwndCnr, PCNRITEM pciUnderMouse );
  89. static VOID   NewWin              ( HWND hwndCnr, PSZ szBaseDir, PCNRITEM pci );
  90. static VOID   TailorMenu          ( HWND hwndCnr, HWND hwndMenu,
  91.                                     PCNRITEM pciSelected );
  92. static VOID   SetConditionalCascade( HWND hwndMenu, USHORT idSubMenu,
  93.                                     USHORT idDefaultItem );
  94. static INT    AddOtherWindows     ( HWND hwndCnr, HWND hwndMenu );
  95. static BOOL   AddOtherWinItem     ( HWND hwndClient, HWND hwndOtherFrame,
  96.                                     HWND hwndOtherClient, HWND hwndSubMenu,
  97.                                     INT idMenuItem );
  98. static USHORT GetDefaultId        ( HWND hwndClient, USHORT idSubMenu );
  99. static VOID   ChangeSelType       ( HWND hwndClient, USHORT idMenuitem );
  100. static VOID   ChangeAutoPos       ( HWND hwndClient );
  101. static VOID   ChangeTargetEmphasis( HWND hwndClient, USHORT idMenuItem );
  102. static VOID   ChangeBackground    ( HWND hwndClient, USHORT idMenuitem );
  103. static VOID   ToggleMiniIcons     ( HWND hwndClient );
  104. static VOID   FilterDirectories   ( HWND hwndClient );
  105.  
  106. static BOOL APIENTRY FilterDirs   ( PRECORDCORE prc, PVOID pv );
  107.  
  108. /**********************************************************************/
  109. /*------------------------ GLOBAL VARIABLES --------------------------*/
  110. /**********************************************************************/
  111.  
  112. /**********************************************************************/
  113. /*-------------------------- CtxtmenuCreate --------------------------*/
  114. /*                                                                    */
  115. /*  CREATE THE CONTEXT MENU.                                          */
  116. /*                                                                    */
  117. /*  INPUT: client window handle,                                      */
  118. /*         pointer to CNRITEM that mouse pointer is over              */
  119. /*                                                                    */
  120. /*  1.                                                                */
  121. /*                                                                    */
  122. /*  OUTPUT: nothing                                                   */
  123. /*                                                                    */
  124. /*--------------------------------------------------------------------*/
  125. /**********************************************************************/
  126. VOID CtxtmenuCreate( HWND hwndClient, PCNRITEM pciSelected )
  127. {
  128.     POINTL    ptl;
  129.     BOOL      fSuccess = TRUE;
  130.     USHORT    idStart = IDM_VIEW_SUBMENU;
  131.     HWND      hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  132.     HWND      hwndMenu = WinLoadMenu( hwndClient, 0, ID_CONTEXT_MENU );
  133.     PINSTANCE pi = INSTDATA( hwndClient );
  134.  
  135.     if( !pi )
  136.     {
  137.         Msg( "CtxtmenuCreate cant get Inst data. RC(%X)", HWNDERR(hwndClient) );
  138.  
  139.         return;
  140.     }
  141.  
  142.     if( !hwndMenu )
  143.     {
  144.         Msg( "CtxtmenuCreate WinLoadMenu RC(%X)", HWNDERR( hwndClient ) );
  145.  
  146.         return;
  147.     }
  148.  
  149.     // Save the pointer to the CNRITEM that was under the mouse pointer when
  150.     // the context menu was invoked. We will need this value when we get
  151.     // WM_COMMAND values because the WM_COMMAND message doesn't tell you which
  152.     // container record the context menu applies to. If the pointer is over
  153.     // white space when the context menu is invoked, pciSelected will be NULL
  154.  
  155.     pi->pciSelected = pciSelected;
  156.  
  157.     // Selected records are tagged with their CNRITEM.fSelected flag. Initialize
  158.     // all container records to 'not selected'.
  159.  
  160.     TurnOffSelFlags( hwndCnr );
  161.  
  162.     // Turn on source emphasis for applicable records. The function that does
  163.     // this also checks if any of the records represent directories. Init this
  164.     // bool to FALSE. It will be set to TRUE if a directory is found.
  165.  
  166.     pi->fDirSelected = FALSE;
  167.  
  168.     TurnOnSourceEmphasis( hwndClient );
  169.  
  170.     // Get the position of the mouse pointer
  171.  
  172.     fSuccess = WinQueryPointerPos( HWND_DESKTOP, &ptl );
  173.  
  174.     if( fSuccess )
  175.     {
  176.         // Convert the position of the mouse pointer to coordinates with respect
  177.         // to the client window.
  178.  
  179.         fSuccess = WinMapWindowPoints( HWND_DESKTOP, hwndClient, &ptl, 1 );
  180.  
  181.         if( !fSuccess )
  182.             Msg( "CtxtmenuCreate WinMapWindowPoints failed! RC(%X)",
  183.                  HWNDERR( hwndClient ) );
  184.     }
  185.     else
  186.         Msg( "CtxtmenuCreate WinQueryPointerPos failed! RC(%X)",
  187.              HWNDERR( hwndClient ) );
  188.  
  189.     // Add/remove menu items, etc.
  190.  
  191.     TailorMenu( hwndCnr, hwndMenu, pciSelected );
  192.  
  193.     // Try to get rid of problem with source emphasis not painting
  194.     // completely when mouse clicks on container while the container is
  195.     // partially overlapped by another window. This doesn't work but it is
  196.     // left in so I won't forget that I tried it.
  197.  
  198.     WinUpdateWindow( hwndCnr );
  199.  
  200.     if( !WinPopupMenu( hwndClient, hwndClient, hwndMenu, ptl.x, ptl.y,
  201.                        idStart, PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD |
  202.                        PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_NONE ) )
  203.         Msg( "CtxtmenuCreate WinPopupMenu failed! RC(%X)", HWNDERR(hwndClient));
  204. }
  205.  
  206. /**********************************************************************/
  207. /*-------------------------- CtxtmenuCommand -------------------------*/
  208. /*                                                                    */
  209. /*  PROCESS A WM_COMMAND MESSAGE FROM THE CONTEXT MENU.               */
  210. /*                                                                    */
  211. /*  INPUT: client window handle,                                      */
  212. /*         command id,                                                */
  213. /*         command source                                             */
  214. /*                                                                    */
  215. /*  1.                                                                */
  216. /*                                                                    */
  217. /*  OUTPUT: nothing                                                   */
  218. /*                                                                    */
  219. /*--------------------------------------------------------------------*/
  220. /**********************************************************************/
  221. VOID CtxtmenuCommand( HWND hwndClient, ULONG idCommand, ULONG ulCmdSrc )
  222. {
  223.     switch( idCommand )
  224.     {
  225.         case IDM_VIEW_TREEICON:
  226.             CtxtmenuSetView( hwndClient, CV_TREE | CV_ICON );
  227.             break;
  228.  
  229.         case IDM_VIEW_TREENAME:
  230.             CtxtmenuSetView( hwndClient, CV_TREE | CV_NAME );
  231.             break;
  232.  
  233.         case IDM_VIEW_TREETEXT:
  234.             CtxtmenuSetView( hwndClient, CV_TREE | CV_TEXT );
  235.             break;
  236.  
  237.         case IDM_VIEW_NAME:
  238.             CtxtmenuSetView( hwndClient, CV_NAME );
  239.             break;
  240.  
  241.         case IDM_VIEW_NAMEFLOWED:
  242.             CtxtmenuSetView( hwndClient, CV_NAME | CV_FLOW );
  243.             break;
  244.  
  245.         case IDM_VIEW_TEXT:
  246.             CtxtmenuSetView( hwndClient, CV_TEXT );
  247.             break;
  248.  
  249.         case IDM_VIEW_TEXTFLOWED:
  250.             CtxtmenuSetView( hwndClient, CV_TEXT | CV_FLOW );
  251.             break;
  252.  
  253.         case IDM_VIEW_ICON:
  254.             CtxtmenuSetView( hwndClient, CV_ICON );
  255.             break;
  256.  
  257.         case IDM_VIEW_DETAILS:
  258.             CtxtmenuSetView( hwndClient, CV_DETAIL );
  259.             break;
  260.  
  261.         case IDM_VIEW_MINI:
  262.             ToggleMiniIcons( hwndClient );
  263.             break;
  264.  
  265.         case IDM_CREATE_NEWWIN:
  266.  
  267.             // Only go thru all selected records if this command came from the
  268.             // context menu (this WM_COMMAND message is also sent by the client
  269.             // window on a CN_ENTER).
  270.  
  271.             NewWindows( hwndClient, ulCmdSrc == CMDSRC_MENU ? TRUE : FALSE );
  272.             break;
  273.  
  274.         case IDM_ARRANGE:
  275.             if( !WinSendDlgItemMsg( hwndClient, CNR_DIRECTORY, CM_ARRANGE,
  276.                                     NULL, NULL ) )
  277.                 Msg( "CtxtmenuCommand CM_ARRANGE RC(%X)", HWNDERR(hwndClient) );
  278.  
  279.             break;
  280.  
  281.         case IDM_SEL_SINGLE:
  282.         case IDM_SEL_MULTIPLE:
  283.         case IDM_SEL_EXTENDED:
  284.             ChangeSelType( hwndClient, idCommand );
  285.             break;
  286.  
  287.         case IDM_TARGEMPH_DEF:
  288.         case IDM_TARGEMPH_ORDERED:
  289.         case IDM_TARGEMPH_MIXED:
  290.             ChangeTargetEmphasis( hwndClient, idCommand );
  291.             break;
  292.  
  293.         case IDM_AUTOPOSITION:
  294.             ChangeAutoPos( hwndClient );
  295.             break;
  296.  
  297.         case IDM_BKGD_RED:
  298.         case IDM_BKGD_WHITE:
  299.         case IDM_BKGD_YELLOW:
  300.         case IDM_BKGD_BLUE:
  301.         case IDM_BKGD_GREY:
  302.         case IDM_BKGD_BITMAP:
  303.             ChangeBackground( hwndClient, idCommand );
  304.             break;
  305.  
  306.         case IDM_SORT_NAME:
  307.         case IDM_SORT_DATETIME:
  308.         case IDM_SORT_DIRORDER:
  309.  
  310.             // In sort.c
  311.  
  312.             SortContainer( hwndClient, idCommand );
  313.             break;
  314.  
  315.         case IDM_VIEW_SUBMENU:
  316.         case IDM_SORT_SUBMENU:
  317.         {
  318.             // Find out the default id of the submenu and simulate that menu
  319.             // item being pressed.
  320.  
  321.             USHORT id = GetDefaultId( hwndClient, idCommand );
  322.  
  323.             if( id )
  324.                 WinSendMsg( hwndClient, WM_COMMAND, MPFROM2SHORT( id, 0 ),
  325.                             MPFROM2SHORT( CMDSRC_MENU, 0 ) );
  326.             break;
  327.         }
  328.  
  329.         case IDM_FILTERDIRS:
  330.             FilterDirectories( hwndClient );
  331.             break;
  332.  
  333.         default:
  334.         {
  335.             PINSTANCE pi = INSTDATA( hwndClient );
  336.  
  337.             // hwndFrame was set when the item was put into the menu. It is the
  338.             // frame window handle that contains the directory pointed to by
  339.             // the text in the menuitem.
  340.  
  341.             if( pi && idCommand >= IDM_OTHERWIN_ITEM1 &&
  342.                 idCommand <= IDM_OTHERWIN_LASTITEM )
  343.                 WinSetFocus( HWND_DESKTOP,
  344.                              pi->hwndFrame[ idCommand - IDM_OTHERWIN_ITEM1 ] );
  345.             break;
  346.         }
  347.     }
  348. }
  349.  
  350. /**********************************************************************/
  351. /*-------------------------- CtxtmenuSetView -------------------------*/
  352. /*                                                                    */
  353. /*  SET THE TYPE OF VIEW FOR THE CONTAINER                            */
  354. /*                                                                    */
  355. /*  INPUT: client window handle,                                      */
  356. /*         view type to set to                                        */
  357. /*                                                                    */
  358. /*  1.                                                                */
  359. /*                                                                    */
  360. /*  OUTPUT: nothing                                                   */
  361. /*                                                                    */
  362. /*--------------------------------------------------------------------*/
  363. /**********************************************************************/
  364. VOID CtxtmenuSetView( HWND hwndClient, ULONG ulViewType )
  365. {
  366.     PINSTANCE pi = INSTDATA( hwndClient );
  367.     CNRINFO   cnri;
  368.  
  369.     if( !pi )
  370.     {
  371.         Msg( "CtxtmenuSetView cant get Inst data. RC(%X)", HWNDERR(hwndClient));
  372.  
  373.         return;
  374.     }
  375.  
  376.     cnri.cb = sizeof( CNRINFO );
  377.  
  378.     // Set the container window attributes: Set the container view mode. Use a
  379.     // container title. Put a separator between the title and the records
  380.     // beneath it. Make the container title read-only. Make it so the container
  381.     // sends itself a CM_PAINTBACKGROUND message so we can paint the container
  382.     // background ourselves in its subclassed window procedure. Add the type
  383.     // of target emphasis that the user specified thru a menu option.
  384.  
  385.     cnri.flWindowAttr = ulViewType | pi->flTargetEmphasis | CA_CONTAINERTITLE |
  386.                         CA_TITLESEPARATOR | CA_TITLEREADONLY |
  387.                         CA_OWNERPAINTBACKGROUND;
  388.  
  389.     SetViewType( ulViewType, pi );
  390.  
  391.     // If we are in DETAIL view, tell the container that we will be
  392.     // using column headings.
  393.  
  394.     if( ulViewType & CV_DETAIL )
  395.         cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
  396.  
  397.  
  398.     if( ulViewType & CV_TREE )
  399.     {
  400.         // Use default spacing between levels in the tree view. Also use
  401.         // the default width of a line that shows record relationships.
  402.  
  403.         cnri.cxTreeIndent = -1;
  404.         cnri.cxTreeLine   = -1;
  405.  
  406.         cnri.flWindowAttr |=  CA_TREELINE;
  407.     }
  408.  
  409.     (void) strcat( pi->szCnrTitle, pi->szDirectory );
  410.  
  411.     cnri.pszCnrTitle = pi->szCnrTitle;
  412.  
  413.     // Set the line spacing between rows to be the minimal value so we conserve
  414.     // on container whitespace.
  415.  
  416.     cnri.cyLineSpacing = 0;
  417.  
  418.     if( pi->fMiniIcons )
  419.         cnri.flWindowAttr |= CV_MINI;
  420.  
  421.     // Set the container parameters. Note that mp2 specifies which fields of
  422.     // of the CNRINFO structure to use. The CMA_FLWINDOWATTR says to use
  423.     // flWindowAttr to specify which 'Window Attribute' fields to use.
  424.  
  425.     if( !WinSendDlgItemMsg( hwndClient, CNR_DIRECTORY, CM_SETCNRINFO,
  426.                             MPFROMP( &cnri ),
  427.                             MPFROMLONG( CMA_FLWINDOWATTR | CMA_CNRTITLE |
  428.                                         CMA_LINESPACING ) ) )
  429.         Msg( "CtxtmenuSetView CM_SETCNRINFO RC(%X)", HWNDERR( hwndClient ) );
  430.  
  431.     // The CM_ARRANGE message is applicable only in ICON view. It will arrange
  432.     // the icons according to CUA. Note that this message is unnecessary if
  433.     // the CCS_AUTOPOSITION style is used on the WinCreateWindow call for the
  434.     // container. The problem with using that style is that you have no control
  435.     // over *when* the arranging is done.
  436.  
  437.     if( ulViewType == CV_ICON )
  438.         if( !WinSendDlgItemMsg( hwndClient, CNR_DIRECTORY, CM_ARRANGE, NULL,
  439.                                 NULL ) )
  440.             Msg( "CtxtmenuSetView CM_ARRANGE RC(%X)", HWNDERR( hwndClient ) );
  441. }
  442.  
  443. /**********************************************************************/
  444. /*--------------------------- SetViewType ----------------------------*/
  445. /*                                                                    */
  446. /*  STORE INFORMATION SENSITIVE TO VIEW TYPE                          */
  447. /*                                                                    */
  448. /*  INPUT: view being set,                                            */
  449. /*         pointer to client's instance data                          */
  450. /*                                                                    */
  451. /*  1.                                                                */
  452. /*                                                                    */
  453. /*  OUTPUT: nothing                                                   */
  454. /*                                                                    */
  455. /*--------------------------------------------------------------------*/
  456. /**********************************************************************/
  457. static VOID SetViewType( ULONG ulViewType, PINSTANCE pi )
  458. {
  459.     switch( ulViewType )
  460.     {
  461.         case (CV_TREE | CV_ICON):
  462.  
  463.             (void) strcpy( pi->szCnrTitle, "Tree/Icon view - " );
  464.  
  465.             pi->flCurrentView = CV_TREE;
  466.  
  467.             break;
  468.  
  469.         case (CV_TREE | CV_TEXT):
  470.  
  471.             (void) strcpy( pi->szCnrTitle, "Tree/Text view - " );
  472.  
  473.             pi->flCurrentView = CV_TREE;
  474.  
  475.             break;
  476.  
  477.         case (CV_TREE | CV_NAME):
  478.  
  479.             (void) strcpy( pi->szCnrTitle, "Tree/Name view - " );
  480.  
  481.             pi->flCurrentView = CV_TREE;
  482.  
  483.             break;
  484.  
  485.         case CV_ICON:
  486.  
  487.             (void) strcpy( pi->szCnrTitle, "Icon view - " );
  488.  
  489.             pi->flCurrentView = CV_ICON;
  490.  
  491.             break;
  492.  
  493.         case CV_NAME:
  494.  
  495.             (void) strcpy( pi->szCnrTitle, "Name view - " );
  496.  
  497.             pi->flCurrentView = CV_NAME;
  498.  
  499.             break;
  500.  
  501.         case (CV_NAME | CV_FLOW):
  502.  
  503.             (void) strcpy( pi->szCnrTitle, "Name/flowed view - " );
  504.  
  505.             pi->flCurrentView = CV_NAME;
  506.  
  507.             break;
  508.  
  509.         case CV_DETAIL:
  510.  
  511.             (void) strcpy( pi->szCnrTitle, "Detail view - " );
  512.  
  513.             pi->flCurrentView = CV_DETAIL;
  514.  
  515.             break;
  516.  
  517.         case CV_TEXT:
  518.  
  519.             (void) strcpy( pi->szCnrTitle, "Text view - " );
  520.  
  521.             pi->flCurrentView = CV_TEXT;
  522.  
  523.             break;
  524.  
  525.         case (CV_TEXT | CV_FLOW):
  526.  
  527.             (void) strcpy( pi->szCnrTitle, "Text/flowed view - " );
  528.  
  529.             pi->flCurrentView = CV_TEXT;
  530.  
  531.             break;
  532.     }
  533. }
  534.  
  535. /**********************************************************************/
  536. /*---------------------------- CtxtmenuEnd ---------------------------*/
  537. /*                                                                    */
  538. /*  PROCESS WM_MENUEND MESSAGE FOR THE CONTEXT MENU.                  */
  539. /*                                                                    */
  540. /*  INPUT: client window handle                                       */
  541. /*                                                                    */
  542. /*  1.                                                                */
  543. /*                                                                    */
  544. /*  OUTPUT: nothing                                                   */
  545. /*                                                                    */
  546. /*--------------------------------------------------------------------*/
  547. /**********************************************************************/
  548. VOID CtxtmenuEnd( HWND hwndClient )
  549. {
  550.     PINSTANCE pi = INSTDATA( hwndClient );
  551.     HWND      hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  552.  
  553.     if( !pi )
  554.     {
  555.         Msg( "CtxtmenuEnd cant get Instdata RC(%X)", HWNDERR( hwndClient ) );
  556.  
  557.         return;
  558.     }
  559.  
  560.     TurnOffSourceEmphasis( hwndClient );
  561.  
  562.     // Try to get rid of problem with source emphasis not painting
  563.     // completely when mouse clicks on container while the container is
  564.     // partially overlapped by another window. This doesn't work but it is
  565.     // left in so I won't forget that I tried it.
  566.  
  567.     WinUpdateWindow( hwndCnr );
  568.  
  569.     // Reset variable that was only used during context menu processing
  570.  
  571.     pi->fDirSelected = FALSE;
  572.  
  573.     // After the menu is gone the container no longer has the focus so we have
  574.     // to reset it.
  575.  
  576.     WinSetFocus( HWND_DESKTOP, hwndCnr );
  577. }
  578.  
  579. /**********************************************************************/
  580. /*-------------------------- TurnOffSelFlags -------------------------*/
  581. /*                                                                    */
  582. /*  TURN OFF THE fSelected FLAG FOR ALL CONTAINER RECORDS.            */
  583. /*                                                                    */
  584. /*  INPUT: container window handle                                    */
  585. /*                                                                    */
  586. /*  1.                                                                */
  587. /*                                                                    */
  588. /*  OUTPUT: nothing                                                   */
  589. /*                                                                    */
  590. /*--------------------------------------------------------------------*/
  591. /**********************************************************************/
  592. static VOID TurnOffSelFlags( HWND hwndCnr )
  593. {
  594.     PCNRITEM pci = NULL;
  595.     USHORT   usWhatRec = CMA_FIRST;
  596.  
  597.     while( fTrue )
  598.     {
  599.         pci = (PCNRITEM) WinSendMsg( hwndCnr, CM_QUERYRECORD, MPFROMP( pci ),
  600.                                      MPFROM2SHORT( usWhatRec, CMA_ITEMORDER ) );
  601.  
  602.         if( (INT) pci == -1 )
  603.         {
  604.             Msg( "TurnOffSelFlags CM_QUERYRECORD RC(%X)", HWNDERR( hwndCnr ) );
  605.  
  606.             break;
  607.         }
  608.  
  609.         if( !pci )
  610.             break;
  611.  
  612.         pci->fSelected = FALSE;
  613.  
  614.         usWhatRec = CMA_NEXT;
  615.     }
  616. }
  617.  
  618. /**********************************************************************/
  619. /*----------------------------- NewWindows ---------------------------*/
  620. /*                                                                    */
  621. /*  CREATE NEW WINDOWS FOR SELECTED CONTAINER RECORDS.                */
  622. /*                                                                    */
  623. /*  INPUT: client window handle,                                      */
  624. /*         flag indicating if all selected records are to be looked at*/
  625. /*                                                                    */
  626. /*  1.                                                                */
  627. /*                                                                    */
  628. /*  OUTPUT: nothing                                                   */
  629. /*                                                                    */
  630. /*--------------------------------------------------------------------*/
  631. /**********************************************************************/
  632. static VOID NewWindows( HWND hwndClient, BOOL fAllSelected )
  633. {
  634.     PINSTANCE pi = INSTDATA( hwndClient );
  635.     HWND      hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  636.     PCNRITEM  pci = NULL;
  637.     USHORT    usWhatRec = CMA_FIRST;
  638.  
  639.     if( !pi )
  640.     {
  641.         Msg( "NewWindows cant get Inst data RC(%X)", HWNDERR( hwndClient ) );
  642.  
  643.         return;
  644.     }
  645.  
  646.     // Create new window for the currently selected record
  647.  
  648.     NewWin( hwndCnr, pi->szDirectory, pi->pciSelected );
  649.  
  650.     // Create new windows for all records that have source emphasis if the
  651.     // flag passed to this function indicates that we are to do this. We would
  652.     // not want to do this if the user double-clicked on just one record vs.
  653.     // selecting 'CreateNewWindow' from the menu.
  654.  
  655.     for( ; fAllSelected ; )
  656.     {
  657.         pci = (PCNRITEM) WinSendMsg( hwndCnr, CM_QUERYRECORD, MPFROMP( pci ),
  658.                                      MPFROM2SHORT( usWhatRec, CMA_ITEMORDER ) );
  659.  
  660.         if( (INT) pci == -1 )
  661.         {
  662.             Msg( "NewWindows CM_QUERYRECORD RC(%X)", HWNDERR( hwndCnr ) );
  663.  
  664.             break;
  665.         }
  666.  
  667.         if( !pci )
  668.             break;
  669.  
  670.         if( pci->fSelected && pci != pi->pciSelected )
  671.             NewWin( hwndCnr, pi->szDirectory, pci );
  672.  
  673.         usWhatRec = CMA_NEXT;
  674.     }
  675. }
  676.  
  677. /**********************************************************************/
  678. /*------------------------ TurnOnSourceEmphasis ----------------------*/
  679. /*                                                                    */
  680. /*  TURN ON SOURCE EMPHASIS FOR APPLICABLE CONTAINER RECORDS.         */
  681. /*                                                                    */
  682. /*  INPUT: client window handle                                       */
  683. /*                                                                    */
  684. /*  1.                                                                */
  685. /*                                                                    */
  686. /*  OUTPUT: nothing                                                   */
  687. /*                                                                    */
  688. /*--------------------------------------------------------------------*/
  689. /**********************************************************************/
  690. static VOID TurnOnSourceEmphasis( HWND hwndClient )
  691. {
  692.     PINSTANCE pi = INSTDATA( hwndClient );
  693.     HWND      hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  694.     BOOL      fRecsSelected = TRUE;
  695.     INT       iSelCount;
  696.  
  697.     if( !pi )
  698.     {
  699.         Msg( "TurnOn..Emphasis cant get Inst data RC(%X)", HWNDERR(hwndClient));
  700.  
  701.         return;
  702.     }
  703.  
  704.     // NOTE: CRA_SOURCE is defined in *our* header file because CRA_SOURCE
  705.     // appeared in the 10/30/92 Service Pack and is not yet in the toolkit
  706.     // header files at this writing.
  707.  
  708.     // If no record is selected (pciSelected is NULL), we set source emphasis
  709.     // to the container itself because the mouse pointer is over whitespace.
  710.  
  711.     if( !pi->pciSelected )
  712.     {
  713.         if( !WinSendMsg( hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP( NULL ),
  714.                          MPFROM2SHORT( TRUE, CRA_SOURCE ) ) )
  715.             Msg( "CM_SETRECORDEMPHASIS failed! RC(%X)", HWNDERR( hwndClient ) );
  716.  
  717.         // Try to get rid of problem with source emphasis not painting
  718.         // completely when mouse clicks on container while the container is
  719.         // partially overlapped by another window. This doesn't work but it is
  720.         // left in so I won't forget that I tried it.
  721.  
  722.         WinUpdateWindow( hwndCnr );
  723.  
  724.         return;
  725.     }
  726.  
  727.     // Get the number of records that are currently in the 'selected' state in
  728.     // the container. We only care about *all* selected records if the one that
  729.     // is now under the mouse pointer is also in the selected state. If it
  730.     // is not, CountSelectedRecs will pass us back a -1 to indicate that we only
  731.     // need to process that record even though others are in selected state.
  732.     // Also keep track in pi->fDirSelected if there are any records that
  733.     // represent directories. This will become useful during menu tailoring.
  734.     // Last thing: set the fSelected BOOL in the CNRITEM struct so we know
  735.     // which records we qualified for source emphasis. When we get the
  736.     // WM_MENUEND message we turn off source emphasis. The WM_MENUEND message
  737.     // happens before we get the WM_COMMAND message so it is too late when we
  738.     // get the WM_COMMAND message to just query which records have the source
  739.     // emphasis to figure out which recs to process.
  740.  
  741.     iSelCount = CountSelectedRecs( hwndCnr, pi->pciSelected );
  742.  
  743.     if( iSelCount == -1 )
  744.     {
  745.         fRecsSelected = FALSE;
  746.  
  747.         iSelCount = 1;
  748.     }
  749.  
  750.     if( iSelCount )
  751.     {
  752.         if( fRecsSelected )
  753.         {
  754.             PCNRITEM pci;
  755.             INT      i;
  756.  
  757.             pci = (PCNRITEM) CMA_FIRST;
  758.  
  759.             // For each selected record turn on source emphasis
  760.  
  761.             for( i = 0; i < iSelCount; i++ )
  762.             {
  763.                 pci = (PCNRITEM) WinSendMsg( hwndCnr, CM_QUERYRECORDEMPHASIS,
  764.                                              MPFROMP( pci ),
  765.                                              MPFROMSHORT( CRA_SELECTED ) );
  766.  
  767.                 if( !WinSendMsg( hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP( pci ),
  768.                                  MPFROM2SHORT( TRUE, CRA_SOURCE ) ) )
  769.                     Msg( "CM_SETRECORDEMPHASIS failed! RC(%X)",
  770.                          HWNDERR( hwndClient ) );
  771.  
  772.                 pci->fSelected = TRUE;
  773.  
  774.                 if( (pci->attrFile & FILE_DIRECTORY) &&
  775.                      pci->szFileName[0] != '.' )
  776.                     pi->fDirSelected = TRUE;
  777.             }
  778.         }
  779.         else
  780.         {
  781.             if( !WinSendMsg( hwndCnr, CM_SETRECORDEMPHASIS,
  782.                              MPFROMP( pi->pciSelected ),
  783.                              MPFROM2SHORT( TRUE, CRA_SOURCE ) ) )
  784.                 Msg( "CM_SETRECORDEMPHASIS failed! RC(%X)",HWNDERR(hwndClient));
  785.  
  786.             pi->pciSelected->fSelected = TRUE;
  787.  
  788.             if( (pi->pciSelected->attrFile & FILE_DIRECTORY) &&
  789.                  pi->pciSelected->szFileName[0] != '.' )
  790.                 pi->fDirSelected = TRUE;
  791.         }
  792.     }
  793. }
  794.  
  795. /**********************************************************************/
  796. /*----------------------- TurnOffSourceEmphasis ----------------------*/
  797. /*                                                                    */
  798. /*  TURN OFF SOURCE EMPHASIS FOR THOSE RECORDS THAT HAVE IT.          */
  799. /*                                                                    */
  800. /*  INPUT: client window handle                                       */
  801. /*                                                                    */
  802. /*  1.                                                                */
  803. /*                                                                    */
  804. /*  OUTPUT: nothing                                                   */
  805. /*                                                                    */
  806. /*--------------------------------------------------------------------*/
  807. /**********************************************************************/
  808. static VOID TurnOffSourceEmphasis( HWND hwndClient )
  809. {
  810.     PINSTANCE pi = INSTDATA( hwndClient );
  811.     HWND      hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  812.  
  813.     if( !pi )
  814.     {
  815.         Msg( "TurnOff..Emphasis cant get Instdata RC(%X)", HWNDERR(hwndClient));
  816.  
  817.         return;
  818.     }
  819.  
  820.     // If no record is selected (pciSelected is NULL), we had set source
  821.     // emphasis to the container itself because the mouse pointer was over
  822.     // whitespace. So turn it off for the container. Otherwise, turn it off
  823.     // for the selected record and all others that have source emphasis
  824.  
  825.     if( pi->pciSelected )
  826.     {
  827.         PCNRITEM pci = (PCNRITEM) CMA_FIRST;
  828.  
  829.         if( !WinSendMsg( hwndCnr, CM_SETRECORDEMPHASIS,
  830.                          MPFROMP( pi->pciSelected ),
  831.                          MPFROM2SHORT( FALSE, CRA_SOURCE ) ) )
  832.             Msg( "TurnOff..Emphasis CM_SETRECORDEMPHASIS failed! RC(%X)",
  833.                  HWNDERR( hwndClient ) );
  834.  
  835.         while( fTrue )
  836.         {
  837.             pci = (PCNRITEM) WinSendMsg( hwndCnr, CM_QUERYRECORDEMPHASIS,
  838.                                      MPFROMP( pci ), MPFROMSHORT( CRA_SOURCE) );
  839.  
  840.             if( !pci )
  841.                 break;
  842.  
  843.             if( pci != pi->pciSelected )
  844.             {
  845.                 if( !WinSendMsg( hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP( pci ),
  846.                                  MPFROM2SHORT( FALSE, CRA_SOURCE ) ) )
  847.                     Msg( "TurnOff... CM_SETRECORDEMPHASIS failed! RC(%X)",
  848.                          HWNDERR( hwndClient ) );
  849.             }
  850.         }
  851.     }
  852.     else
  853.         if( !WinSendMsg( hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP( NULL ),
  854.                          MPFROM2SHORT( FALSE, CRA_SOURCE ) ) )
  855.             Msg( "TurnOff...Emphasis CM_SETRECORDEMPHASIS failed! RC(%X)",
  856.                  HWNDERR( hwndClient ) );
  857. }
  858.  
  859. /**********************************************************************/
  860. /*------------------------ CountSelectedRecs -------------------------*/
  861. /*                                                                    */
  862. /*  COUNT THE NUMBER OF RECORDS THAT ARE CURRENTLY SELECTED.          */
  863. /*                                                                    */
  864. /*  INPUT: pointer to the record that was under the pointer.          */
  865. /*                                                                    */
  866. /*  1.                                                                */
  867. /*                                                                    */
  868. /*  OUTPUT: number of selected recs, 0 if none, -1 if the record that */
  869. /*          the mouse pointer was under was not selected.             */
  870. /*                                                                    */
  871. /*--------------------------------------------------------------------*/
  872. /**********************************************************************/
  873. static INT CountSelectedRecs( HWND hwndCnr, PCNRITEM pciUnderMouse )
  874. {
  875.     INT      iCount = 0;
  876.     PCNRITEM pci;
  877.     BOOL     fFound = FALSE;
  878.  
  879.     if( pciUnderMouse )
  880.     {
  881.         pci = (PCNRITEM) CMA_FIRST;
  882.  
  883.         while( pci )
  884.         {
  885.             pci = (PCNRITEM) WinSendMsg( hwndCnr, CM_QUERYRECORDEMPHASIS,
  886.                                          MPFROMP( pci ),
  887.                                          MPFROMSHORT( CRA_SELECTED ) );
  888.             if( pci )
  889.             {
  890.                 if( pci == pciUnderMouse )
  891.                     fFound = TRUE;
  892.  
  893.                 iCount++;
  894.             }
  895.         }
  896.  
  897.         if( !fFound )
  898.             iCount = -1;
  899.     }
  900.  
  901.     return iCount;
  902. }
  903.  
  904. /**********************************************************************/
  905. /*------------------------------ NewWin ------------------------------*/
  906. /*                                                                    */
  907. /*  CREATE A NEW WINDOW FOR A DIRECTORY.                              */
  908. /*                                                                    */
  909. /*  INPUT: container window handle,                                   */
  910. /*         pointer to base directory name for this client window,     */
  911. /*         pointer to CNRITEM record to create window for             */
  912. /*                                                                    */
  913. /*  1.                                                                */
  914. /*                                                                    */
  915. /*  OUTPUT: nothing                                                   */
  916. /*                                                                    */
  917. /*--------------------------------------------------------------------*/
  918. /**********************************************************************/
  919. static VOID NewWin( HWND hwndCnr, PSZ szBaseDir, PCNRITEM pci )
  920. {
  921.     // If the user selected a directory, create another directory window for it
  922.  
  923.     if( pci && (pci->attrFile & FILE_DIRECTORY) && pci->szFileName[0] != '.' )
  924.     {
  925.         CHAR szDirectory[ CCHMAXPATH + 1 ];
  926.  
  927.         (void) strcpy( szDirectory, szBaseDir );
  928.  
  929.         // Recursively go up the tree and add the subdirectory names to the
  930.         // fully qualified directory name.
  931.  
  932.         FullyQualify( szDirectory, hwndCnr, pci );
  933.  
  934.         // CreateDirectoryWin is in CREATE.C. By specifying pci as the third
  935.         // parameter we are saying that we want the new container to share
  936.         // records with this one.
  937.  
  938.         (void) CreateDirectoryWin( szDirectory, hwndCnr, pci );
  939.     }
  940. }
  941.  
  942. /**********************************************************************/
  943. /*--------------------------- TailorMenu -----------------------------*/
  944. /*                                                                    */
  945. /*  TAILOR THE MENU FOR THE SELECTED OBJECT                           */
  946. /*                                                                    */
  947. /*  INPUT: container window handle,                                   */
  948. /*         menu window handle,                                        */
  949. /*         pointer to CNRITEM record that is selected                 */
  950. /*                                                                    */
  951. /*  1.                                                                */
  952. /*                                                                    */
  953. /*  OUTPUT: nothing                                                   */
  954. /*                                                                    */
  955. /*--------------------------------------------------------------------*/
  956. /**********************************************************************/
  957. static VOID TailorMenu( HWND hwndCnr, HWND hwndMenu, PCNRITEM pciSelected )
  958. {
  959.     CNRINFO   cnri;
  960.     ULONG     flStyle = STYLES( hwndCnr );
  961.     PINSTANCE pi = INSTDATA( PARENT( hwndCnr ) );
  962.  
  963.     if( !pi )
  964.     {
  965.         Msg( "TailorMenu cant get Instdata RC(%X)", HWNDERR( hwndCnr ) );
  966.  
  967.         return;
  968.     }
  969.  
  970.     // Set the MS_CONDITIONALCASCADE bit and default menu item for submenus.
  971.  
  972.     SetConditionalCascade( hwndMenu, IDM_VIEW_SUBMENU, IDM_VIEW_ICON );
  973.     SetConditionalCascade( hwndMenu, IDM_SORT_SUBMENU, IDM_SORT_DIRORDER );
  974.  
  975.     // Take the CreateNewWindow menu item off the menu if the mouse pointer is
  976.     // not over a container record or if that record is not a directory or if
  977.     // no selected records are directories. We can only create a new directory
  978.     // window for a directory record.
  979.  
  980.     if( !pciSelected || !(pi->fDirSelected ||
  981.         ((pciSelected->attrFile & FILE_DIRECTORY)
  982.           && pciSelected->szFileName[0] != '.')) )
  983.         if( !WinSendMsg( hwndMenu, MM_DELETEITEM,
  984.                          MPFROM2SHORT( IDM_CREATE_NEWWIN, FALSE ), NULL ) )
  985.             Msg( "TailorMenu MM_DELETEITEM failed for IDM_CREATE_NEWWIN RC(%X)",
  986.                   HWNDERR( hwndMenu ) );
  987.  
  988.     if( WinSendMsg( hwndCnr, CM_QUERYCNRINFO, MPFROMP( &cnri ),
  989.                     MPFROMLONG( sizeof( CNRINFO ) ) ) )
  990.     {
  991.         // The Arrange menu item is only applicable to ICON VIEW. Since the
  992.         // Tree view can be or'ed with CV_ICON, we need to first check if we
  993.         // are in Tree view before we care about CV_ICON by itself
  994.  
  995.         if( (cnri.flWindowAttr & CV_TREE) || !(cnri.flWindowAttr & CV_ICON) )
  996.             if( !WinSendMsg( hwndMenu, MM_DELETEITEM,
  997.                              MPFROM2SHORT( IDM_ARRANGE, FALSE ), NULL ) )
  998.                 Msg( "TailorMenu MM_DELETEITEM failed for IDM_ARRANGE RC(%X)",
  999.                      HWNDERR( hwndMenu ) );
  1000.     }
  1001.     else
  1002.         Msg( "TailorMenu CM_QUERYCNRINFO failed RC(%X)", HWNDERR( hwndCnr ) );
  1003.  
  1004.     // Add a menu item for each directory window (other than our's) that we
  1005.     // find on the desktop. If there aren't any others, delete the OtherWindow
  1006.     // Submenu since it wouldn't apply
  1007.  
  1008.     if( !AddOtherWindows( hwndCnr, hwndMenu ) )
  1009.         if( !WinSendMsg( hwndMenu, MM_DELETEITEM,
  1010.                          MPFROM2SHORT( IDM_OTHERWIN_SUBMENU, FALSE ), NULL ) )
  1011.             Msg( "TailorMenu MM_DELETEITEM failed for IDM_OTHERWIN_SUB RC(%X)",
  1012.                  HWNDERR( hwndMenu ) );
  1013.  
  1014.     // Check appropriate menu items
  1015.  
  1016.     if( pi->fMiniIcons )
  1017.         if( !WinCheckMenuItem( hwndMenu, IDM_VIEW_MINI, TRUE ) )
  1018.             Msg( "TailorMenu CheckMenuItem( MINI ) RC(%X)", HWNDERR(hwndMenu) );
  1019.  
  1020.     if( pi->fFilterDirs )
  1021.         if( !WinCheckMenuItem( hwndMenu, IDM_FILTERDIRS, TRUE ) )
  1022.             Msg( "TailorMenu CheckMenuItem( FILT ) RC(%X)", HWNDERR(hwndMenu) );
  1023.  
  1024.     if( flStyle & CCS_AUTOPOSITION )
  1025.         if( !WinCheckMenuItem( hwndMenu, IDM_AUTOPOSITION, TRUE ) )
  1026.             Msg( "TailorMenu CheckMenuItem(AUTOPOS) RC(%X)", HWNDERR(hwndMenu));
  1027.  
  1028.     if( flStyle & CCS_SINGLESEL )
  1029.     {
  1030.         if( !WinCheckMenuItem( hwndMenu, IDM_SEL_SINGLE, TRUE ) )
  1031.             Msg( "TailorMenu CheckMenuItem(SINGLE) RC(%X)", HWNDERR(hwndMenu));
  1032.     }
  1033.     else if( flStyle & CCS_EXTENDSEL )
  1034.     {
  1035.         if( !WinCheckMenuItem( hwndMenu, IDM_SEL_EXTENDED, TRUE ) )
  1036.             Msg( "TailorMenu CheckMenuItem(EXTEND) RC(%X)", HWNDERR(hwndMenu));
  1037.     }
  1038.     else
  1039.         if( !WinCheckMenuItem( hwndMenu, IDM_SEL_MULTIPLE, TRUE ) )
  1040.             Msg( "TailorMenu CheckMenuItem(MULT) RC(%X)", HWNDERR(hwndMenu));
  1041.  
  1042.     if( pi->flTargetEmphasis == CA_ORDEREDTARGETEMPH )
  1043.     {
  1044.         if( !WinCheckMenuItem( hwndMenu, IDM_TARGEMPH_ORDERED, TRUE ) )
  1045.             Msg( "TailorMenu CheckMenuItem(ORDERED) RC(%X)", HWNDERR(hwndMenu));
  1046.     }
  1047.     else if( pi->flTargetEmphasis == CA_MIXEDTARGETEMPH )
  1048.     {
  1049.         if( !WinCheckMenuItem( hwndMenu, IDM_TARGEMPH_MIXED, TRUE ) )
  1050.             Msg( "TailorMenu CheckMenuItem(MIXED) RC(%X)", HWNDERR(hwndMenu));
  1051.     }
  1052.     else
  1053.         if( !WinCheckMenuItem( hwndMenu, IDM_TARGEMPH_DEF, TRUE ) )
  1054.             Msg( "TailorMenu CheckMenuItem(TARGDEF) RC(%X)", HWNDERR(hwndMenu));
  1055. }
  1056.  
  1057. /**********************************************************************/
  1058. /*---------------------- SetConditionalCascade -----------------------*/
  1059. /*                                                                    */
  1060. /*  SET A SUBMENU TO BE A CONDITIONAL CASCADE SUBMENU                 */
  1061. /*                                                                    */
  1062. /*  INPUT: menu window handle,                                        */
  1063. /*         id of submenu to make conditionally cascaded,              */
  1064. /*         id of item to make the default item of the cascaded menu   */
  1065. /*                                                                    */
  1066. /*  1.                                                                */
  1067. /*                                                                    */
  1068. /*  OUTPUT: nothing                                                   */
  1069. /*                                                                    */
  1070. /*--------------------------------------------------------------------*/
  1071. /**********************************************************************/
  1072. static VOID SetConditionalCascade( HWND hwndMenu, USHORT idSubMenu,
  1073.                                    USHORT idDefaultItem )
  1074. {
  1075.     MENUITEM mi;
  1076.  
  1077.     if( WinSendMsg( hwndMenu, MM_QUERYITEM,
  1078.                     MPFROM2SHORT( idSubMenu, TRUE ), &mi ) )
  1079.     {
  1080.         // Set the MS_CONDITIONALCASCADE bit for the submenu.
  1081.  
  1082.         if( WinSetWindowBits( mi.hwndSubMenu, QWL_STYLE, MS_CONDITIONALCASCADE,
  1083.                               MS_CONDITIONALCASCADE ) )
  1084.         {
  1085.             // Set cascade menu default
  1086.  
  1087.             if( !WinSendMsg( mi.hwndSubMenu, MM_SETDEFAULTITEMID,
  1088.                              MPFROMSHORT( idDefaultItem ), NULL ) )
  1089.                Msg( "MM_SETDEFAULTITEMID failed! RC(%X)", HWNDERR( hwndMenu ) );
  1090.         }
  1091.         else
  1092.             Msg( "Set...Cascade WinSetWindowBits RC(%X)", HWNDERR( hwndMenu ) );
  1093.     }
  1094.     else
  1095.         Msg( "Set...Cascade MM_QUERYITEM failed! RC(%X)", HWNDERR( hwndMenu ) );
  1096. }
  1097.  
  1098. /**********************************************************************/
  1099. /*------------------------- AddOtherWindows --------------------------*/
  1100. /*                                                                    */
  1101. /*  ADD OTHER DIRECTORY WINDOWS AS ITEMS ON THE "OTHER WINDOW" SUBMENU*/
  1102. /*                                                                    */
  1103. /*  INPUT: container window handle,                                   */
  1104. /*         menu window handle                                         */
  1105. /*                                                                    */
  1106. /*  1.                                                                */
  1107. /*                                                                    */
  1108. /*  OUTPUT: number of other windows                                   */
  1109. /*                                                                    */
  1110. /*--------------------------------------------------------------------*/
  1111. /**********************************************************************/
  1112. static INT AddOtherWindows( HWND hwndCnr, HWND hwndMenu )
  1113. {
  1114.     INT       iOthers = 0, idMenuItem = IDM_OTHERWIN_ITEM1;
  1115.     HWND      hwndEnum;
  1116.     MENUITEM  miSubMenu;
  1117.  
  1118.     if( !WinSendMsg( hwndMenu, MM_QUERYITEM,
  1119.                      MPFROM2SHORT( IDM_OTHERWIN_SUBMENU, TRUE ), &miSubMenu ) )
  1120.     {
  1121.         Msg( "AddOtherWindows MM_QUERYITEM RC(%X)", HWNDERR( hwndMenu ) );
  1122.  
  1123.         return 0;
  1124.     }
  1125.  
  1126.     hwndEnum = WinBeginEnumWindows( HWND_DESKTOP );
  1127.  
  1128.     if( hwndEnum )
  1129.     {
  1130.         HWND hwndFrame, hwndClient;
  1131.         CHAR szClass[ 50 ];
  1132.  
  1133.         while( fTrue )
  1134.         {
  1135.             hwndFrame = WinGetNextWindow( hwndEnum );
  1136.  
  1137.             if( !hwndFrame )
  1138.                 break;
  1139.  
  1140.             // If we found a frame window (child of the desktop), check to see
  1141.             // if it has a client window because that's the one that would have
  1142.             // the class that we're looking for
  1143.  
  1144.             hwndClient = WinWindowFromID( hwndFrame, FID_CLIENT );
  1145.  
  1146.             if( hwndClient )
  1147.             {
  1148.                 // Make sure we are checking NULL-terminated strings
  1149.  
  1150.                 (void) memset( szClass, 0, sizeof( szClass ) );
  1151.  
  1152.                 // Get the class of this client window. If it is one of ours
  1153.                 // and it isn't the current window, add it to the OtherWindow
  1154.                 // submenu.
  1155.  
  1156.                 if( hwndClient != PARENT( hwndCnr ) &&
  1157.                     WinQueryClassName( hwndClient, sizeof(szClass), szClass ) )
  1158.                 {
  1159.                     if( !strcmp( szClass, DIRECTORY_WINCLASS ) )
  1160.                         if( AddOtherWinItem( PARENT( hwndCnr ), hwndFrame,
  1161.                                hwndClient, miSubMenu.hwndSubMenu, idMenuItem ) )
  1162.                         {
  1163.                             idMenuItem++;
  1164.  
  1165.                             iOthers++;
  1166.                         }
  1167.                 }
  1168.             }
  1169.         }
  1170.  
  1171.         WinEndEnumWindows( hwndEnum );
  1172.     }
  1173.     else
  1174.         Msg( "AddOtherWindows WinBeginEnumWindows RC(%X)", HWNDERR( hwndCnr ) );
  1175.  
  1176.     return iOthers;
  1177. }
  1178.  
  1179. /**********************************************************************/
  1180. /*------------------------- AddOtherWinItem --------------------------*/
  1181. /*                                                                    */
  1182. /*  ADD THE OTHER DIRECTORY WINDOW AS A MENU ITEM.                    */
  1183. /*                                                                    */
  1184. /*  INPUT: client window handle of our window,                        */
  1185. /*         frame window handle of other window,                       */
  1186. /*         client window handle of other window,                      */
  1187. /*         OtherWindow submenu window handle,                         */
  1188. /*         menu item id                                               */
  1189. /*                                                                    */
  1190. /*  1.                                                                */
  1191. /*                                                                    */
  1192. /*  OUTPUT: TRUE or FALSE if successful or not                        */
  1193. /*                                                                    */
  1194. /*--------------------------------------------------------------------*/
  1195. /**********************************************************************/
  1196. static BOOL AddOtherWinItem( HWND hwndClient, HWND hwndOtherFrame,
  1197.                              HWND hwndOtherClient, HWND hwndSubMenu,
  1198.                              INT idMenuItem )
  1199. {
  1200.     PINSTANCE piUs = INSTDATA( hwndClient );
  1201.     PINSTANCE piOther = INSTDATA( hwndOtherClient );
  1202.     BOOL      fSuccess = TRUE;
  1203.  
  1204.     if( piUs && piOther )
  1205.     {
  1206.         MENUITEM  miItem;
  1207.         SHORT     sMenuRC;
  1208.  
  1209.         (void) memset( &miItem, 0, sizeof( MENUITEM ) );
  1210.  
  1211.         miItem.iPosition = MIT_END;
  1212.         miItem.afStyle   = MIS_TEXT;
  1213.         miItem.id        = idMenuItem;
  1214.  
  1215.         // Save the frame window handle so we can easily retrieve it if this
  1216.         // menu item is selected so we can change focus to that frame window.
  1217.  
  1218.         piUs->hwndFrame[ idMenuItem - IDM_OTHERWIN_ITEM1 ] = hwndOtherFrame;
  1219.  
  1220.         sMenuRC = (SHORT) WinSendMsg( hwndSubMenu, MM_INSERTITEM,
  1221.                                       MPFROMP( &miItem ),
  1222.                                       MPFROMP( piOther->szDirectory ) );
  1223.  
  1224.         if( sMenuRC == MIT_MEMERROR || sMenuRC == MIT_ERROR )
  1225.         {
  1226.             fSuccess = FALSE;
  1227.  
  1228.             Msg( "AddOtherWinItem MM_INSERTITEM MenuRC(%d) RC(%X)",
  1229.                  sMenuRC, HWNDERR( hwndClient ) );
  1230.         }
  1231.     }
  1232.     else
  1233.     {
  1234.         fSuccess = FALSE;
  1235.  
  1236.         Msg( "AddOtherWindows cant get Inst data RC(%X)", HWNDERR(hwndClient) );
  1237.     }
  1238.  
  1239.     return fSuccess;
  1240. }
  1241.  
  1242. /**********************************************************************/
  1243. /*-------------------------- GetDefaultId ----------------------------*/
  1244. /*                                                                    */
  1245. /*  GET THE DEFAULT ID FOR A MS_CONDITIONALCASCADE SUBMENU            */
  1246. /*                                                                    */
  1247. /*  INPUT: client window handle,                                      */
  1248. /*         id of submenu                                              */
  1249. /*                                                                    */
  1250. /*  1.                                                                */
  1251. /*                                                                    */
  1252. /*  OUTPUT: id of default item                                        */
  1253. /*                                                                    */
  1254. /*--------------------------------------------------------------------*/
  1255. /**********************************************************************/
  1256. static USHORT GetDefaultId( HWND hwndClient, USHORT idSubMenu )
  1257. {
  1258.     USHORT  id = 0;
  1259.     HWND    hwndMenu = WinWindowFromID( hwndClient, ID_CONTEXT_MENU );
  1260.  
  1261.     if( hwndMenu )
  1262.     {
  1263.         MENUITEM mi;
  1264.  
  1265.         if( WinSendMsg( hwndMenu, MM_QUERYITEM, MPFROM2SHORT( idSubMenu, TRUE ),
  1266.                         &mi ))
  1267.         {
  1268.             id = (USHORT) WinSendMsg( mi.hwndSubMenu,
  1269.                                       MM_QUERYDEFAULTITEMID, NULL, NULL );
  1270.  
  1271.             if( !id )
  1272.                 Msg( "GetDefaultId MM_QUERYDEFAULTITEMID RC(%X)",
  1273.                       HWNDERR( hwndClient ) );
  1274.         }
  1275.         else
  1276.             Msg( "GetDefaultId MM_QUERYITEM RC(%X)", HWNDERR( hwndClient ) );
  1277.     }
  1278.  
  1279. /*****************************************************************************
  1280. BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
  1281.  
  1282.     else
  1283.         Msg( "GetDefaultId WinWindowFromID RC(%X)", HWNDERR( hwndClient ) );
  1284.  
  1285. For some reason, only in a specific instance, the WinWindowFromID fails but no
  1286. valid error code is returned from WinGetLastError. This happens under the
  1287. following circumstances:
  1288.  
  1289.  - the popup menu is active
  1290.  - you select the Other Window submenu but don't select a menu item
  1291.  - you select a conditionally cascaded submenu but not the cascade button
  1292.  
  1293. I tried to nail this down but could not.
  1294.  
  1295. BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
  1296. ******************************************************************************/
  1297.  
  1298.     return id;
  1299. }
  1300.  
  1301. /**********************************************************************/
  1302. /*-------------------------- ChangeSelType ---------------------------*/
  1303. /*                                                                    */
  1304. /*  CHANGE THE CONTAINER SELECTION TYPE                               */
  1305. /*                                                                    */
  1306. /*  INPUT: client window handle,                                      */
  1307. /*         id of menu item that determines selection type             */
  1308. /*                                                                    */
  1309. /*  1.                                                                */
  1310. /*                                                                    */
  1311. /*  OUTPUT: nothing                                                   */
  1312. /*                                                                    */
  1313. /*--------------------------------------------------------------------*/
  1314. /**********************************************************************/
  1315. static VOID ChangeSelType( HWND hwndClient, USHORT idMenuitem )
  1316. {
  1317.     HWND  hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  1318.     ULONG flSelType = CCS_SINGLESEL | CCS_MULTIPLESEL | CCS_EXTENDSEL;
  1319.  
  1320.     // Clear existing selection type
  1321.  
  1322.     if( !WinSetWindowBits( hwndCnr, QWL_STYLE, 0, flSelType ) )
  1323.         Msg( "ChangeSelType WinSetWindowBits RC(%X)", HWNDERR( hwndClient ) );
  1324.  
  1325.     switch( idMenuitem )
  1326.     {
  1327.         case IDM_SEL_SINGLE:
  1328.  
  1329.             flSelType = CCS_SINGLESEL;
  1330.             break;
  1331.  
  1332.         case IDM_SEL_MULTIPLE:
  1333.  
  1334.             flSelType = CCS_MULTIPLESEL;
  1335.             break;
  1336.  
  1337.         case IDM_SEL_EXTENDED:
  1338.  
  1339.             flSelType = CCS_EXTENDSEL;
  1340.             break;
  1341.     }
  1342.  
  1343.     // Set new selection type
  1344.  
  1345.     if( !WinSetWindowBits( hwndCnr, QWL_STYLE, flSelType, flSelType ) )
  1346.         Msg( "ChangeSelType WinSetWindowBits RC(%X)", HWNDERR( hwndClient ) );
  1347. }
  1348.  
  1349. /**********************************************************************/
  1350. /*-------------------------- ChangeAutoPos ---------------------------*/
  1351. /*                                                                    */
  1352. /*  TOGGLE THE CONTAINER'S CCS_AUTOPOSITION STYLE                     */
  1353. /*                                                                    */
  1354. /*  INPUT: client window handle                                       */
  1355. /*                                                                    */
  1356. /*  1.                                                                */
  1357. /*                                                                    */
  1358. /*  OUTPUT: nothing                                                   */
  1359. /*                                                                    */
  1360. /*--------------------------------------------------------------------*/
  1361. /**********************************************************************/
  1362. static VOID ChangeAutoPos( HWND hwndClient )
  1363. {
  1364.     HWND  hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  1365.     ULONG flStyle = STYLES( hwndCnr );
  1366.  
  1367.     if( flStyle & CCS_AUTOPOSITION )
  1368.     {
  1369.         if( !WinSetWindowBits( hwndCnr, QWL_STYLE, 0, CCS_AUTOPOSITION ) )
  1370.             Msg( "ChangeAutoPos WinSetWindowBits RC(%X)", HWNDERR(hwndClient) );
  1371.     }
  1372.     else
  1373.         if( !WinSetWindowBits( hwndCnr, QWL_STYLE, CCS_AUTOPOSITION,
  1374.                                CCS_AUTOPOSITION ) )
  1375.             Msg( "ChangeAutoPos WinSetWindowBits RC(%X)", HWNDERR(hwndClient) );
  1376. }
  1377.  
  1378. /**********************************************************************/
  1379. /*----------------------- ChangeTargetEmphasis -----------------------*/
  1380. /*                                                                    */
  1381. /*  CHANGE THE CONTAINER TARGET EMPHASIS TYPE                         */
  1382. /*                                                                    */
  1383. /*  INPUT: client window handle,                                      */
  1384. /*         id of menu item that determines target emphasis            */
  1385. /*                                                                    */
  1386. /*  1.                                                                */
  1387. /*                                                                    */
  1388. /*  OUTPUT: nothing                                                   */
  1389. /*                                                                    */
  1390. /*--------------------------------------------------------------------*/
  1391. /**********************************************************************/
  1392. static VOID ChangeTargetEmphasis( HWND hwndClient, USHORT idMenuitem )
  1393. {
  1394.     PINSTANCE pi = INSTDATA( hwndClient );
  1395.     HWND      hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  1396.     CNRINFO   cnri;
  1397.  
  1398.     if( pi )
  1399.     {
  1400.         switch( idMenuitem )
  1401.         {
  1402.             case IDM_TARGEMPH_DEF:
  1403.  
  1404.                 pi->flTargetEmphasis = 0;
  1405.                 break;
  1406.  
  1407.             case IDM_TARGEMPH_ORDERED:
  1408.  
  1409.                 pi->flTargetEmphasis = CA_ORDEREDTARGETEMPH;
  1410.                 break;
  1411.  
  1412.             case IDM_TARGEMPH_MIXED:
  1413.  
  1414.                 pi->flTargetEmphasis = CA_MIXEDTARGETEMPH;
  1415.                 break;
  1416.         }
  1417.     }
  1418.     else
  1419.         Msg( "ChangeTargetEmphasis cant get Inst data RC(%X)",
  1420.              HWNDERR( hwndClient ) );
  1421.  
  1422.     // Get the existing value of flWindowAttr...
  1423.  
  1424.     if( !WinSendMsg( hwndCnr, CM_QUERYCNRINFO, MPFROMP( &cnri ),
  1425.                      MPFROMLONG( sizeof( CNRINFO ) ) ) )
  1426.         Msg( "ChangeTargetEmphasis CM_QUERYCNRINFO RC(%X)", HWNDERR(hwndCnr) );
  1427.  
  1428.     // ... remove the old target emphasis value ...
  1429.  
  1430.     cnri.flWindowAttr &= ~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH);
  1431.  
  1432.     // ... add the appropriate target emphasis value ...
  1433.  
  1434.     cnri.flWindowAttr |= pi->flTargetEmphasis;
  1435.  
  1436.     // ... and set it
  1437.  
  1438.     if( !WinSendMsg( hwndCnr, CM_SETCNRINFO, MPFROMP( &cnri ),
  1439.                      MPFROMLONG( CMA_FLWINDOWATTR ) ) )
  1440.         Msg( "ChangeTargetEmphasis CM_SETCNRINFO RC(%X)", HWNDERR(hwndCnr) );
  1441.  
  1442.  
  1443. }
  1444.  
  1445. /**********************************************************************/
  1446. /*------------------------- ChangeBackground -------------------------*/
  1447. /*                                                                    */
  1448. /*  CHANGE THE BACKGROUND COLOR OF THE CONTAINER.                     */
  1449. /*                                                                    */
  1450. /*  INPUT: client window handle,                                      */
  1451. /*         id of menu item that determines selection type             */
  1452. /*                                                                    */
  1453. /*  1.                                                                */
  1454. /*                                                                    */
  1455. /*  OUTPUT: nothing                                                   */
  1456. /*                                                                    */
  1457. /*--------------------------------------------------------------------*/
  1458. /**********************************************************************/
  1459. static VOID ChangeBackground( HWND hwndClient, USHORT idMenuitem )
  1460. {
  1461.     PINSTANCE pi = INSTDATA( hwndClient );
  1462.  
  1463.     if( !pi )
  1464.     {
  1465.         Msg( "ChangeBackground cant get Instdata RC(%X)", HWNDERR(hwndClient) );
  1466.  
  1467.         return;
  1468.     }
  1469.  
  1470.     switch( idMenuitem )
  1471.     {
  1472.         case IDM_BKGD_RED:
  1473.  
  1474.             pi->clrBackground = CLR_RED;
  1475.             break;
  1476.  
  1477.         case IDM_BKGD_WHITE:
  1478.  
  1479.             pi->clrBackground = CLR_WHITE;
  1480.             break;
  1481.  
  1482.         case IDM_BKGD_YELLOW:
  1483.  
  1484.             pi->clrBackground = CLR_YELLOW;
  1485.             break;
  1486.  
  1487.         case IDM_BKGD_BLUE:
  1488.  
  1489.             pi->clrBackground = CLR_BLUE;
  1490.             break;
  1491.  
  1492.         case IDM_BKGD_GREY:
  1493.  
  1494.             pi->clrBackground = CLR_PALEGRAY;
  1495.             break;
  1496.  
  1497.         case IDM_BKGD_BITMAP:
  1498.  
  1499.             pi->clrBackground = 0;
  1500.             break;
  1501.     }
  1502.  
  1503.     // Note that you must use TRUE as the last parameter in WinInvalidateRect
  1504.     // to tell the container to paint its child windows. The container is
  1505.     // made up of more than one window, many in the case of Details view.
  1506.  
  1507.     if( !WinInvalidateRect( WinWindowFromID( hwndClient, CNR_DIRECTORY ), NULL,
  1508.                             TRUE ) )
  1509.         Msg( "ChangeBackground WinInvalidateRect RC(%X)", HWNDERR(hwndClient) );
  1510. }
  1511.  
  1512. /**********************************************************************/
  1513. /*------------------------- ToggleMiniIcons --------------------------*/
  1514. /*                                                                    */
  1515. /*  TOGGLE ON OR OFF MINI ICONS                                       */
  1516. /*                                                                    */
  1517. /*  INPUT: client window handle                                       */
  1518. /*                                                                    */
  1519. /*  1.                                                                */
  1520. /*                                                                    */
  1521. /*  OUTPUT: nothing                                                   */
  1522. /*                                                                    */
  1523. /*--------------------------------------------------------------------*/
  1524. /**********************************************************************/
  1525. static VOID ToggleMiniIcons( HWND hwndClient )
  1526. {
  1527.     HWND      hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  1528.     PINSTANCE pi = INSTDATA( hwndClient );
  1529.     CNRINFO   cnri;
  1530.  
  1531.     if( !pi )
  1532.     {
  1533.         Msg( "ToggleMiniIcons cant get Instdata RC(%X)", HWNDERR( hwndCnr ) );
  1534.  
  1535.         return;
  1536.     }
  1537.  
  1538.     // Toggle the BOOL that lets the rest of the program know what mode we are
  1539.     // in.
  1540.  
  1541.     pi->fMiniIcons ^= TRUE;
  1542.  
  1543.     // Get the existing value of flWindowAttr...
  1544.  
  1545.     if( !WinSendMsg( hwndCnr, CM_QUERYCNRINFO, MPFROMP( &cnri ),
  1546.                      MPFROMLONG( sizeof( CNRINFO ) ) ) )
  1547.         Msg( "ToggleMiniIcons CM_QUERYCNRINFO RC(%X)", HWNDERR( hwndCnr ) );
  1548.  
  1549.     // ... toggle the CV_MINI flag...
  1550.  
  1551.     cnri.flWindowAttr ^= CV_MINI;
  1552.  
  1553.     // ... and set it
  1554.  
  1555.     if( !WinSendMsg( hwndCnr, CM_SETCNRINFO, MPFROMP( &cnri ),
  1556.                      MPFROMLONG( CMA_FLWINDOWATTR ) ) )
  1557.         Msg( "ToggleMiniIcons CM_SETCNRINFO RC(%X)", HWNDERR( hwndCnr ) );
  1558.  
  1559.     if( !WinSendMsg( hwndCnr, CM_INVALIDATERECORD, NULL, NULL ) )
  1560.         Msg( "ToggleMiniIcons CM_INVALIDATERECORD RC(%X)", HWNDERR( hwndCnr ) );
  1561.  
  1562.     if( cnri.flWindowAttr & CV_ICON )
  1563.         if( !WinSendMsg( hwndCnr, CM_ARRANGE, NULL, NULL ) )
  1564.             Msg( "ToggleMiniIcons CM_ARRANGE RC(%X)", HWNDERR( hwndCnr ) );
  1565. }
  1566.  
  1567. /**********************************************************************/
  1568. /*------------------------ FilterDirectories -------------------------*/
  1569. /*                                                                    */
  1570. /*  HANDLE THE FILTERING (OR NOT) OF DIRECTORIES FROM THE CONTAINER   */
  1571. /*                                                                    */
  1572. /*  INPUT: client window handle                                       */
  1573. /*                                                                    */
  1574. /*  1.                                                                */
  1575. /*                                                                    */
  1576. /*  OUTPUT: nothing                                                   */
  1577. /*                                                                    */
  1578. /*--------------------------------------------------------------------*/
  1579. /**********************************************************************/
  1580. static VOID FilterDirectories( HWND hwndClient )
  1581. {
  1582.     HWND      hwndCnr = WinWindowFromID( hwndClient, CNR_DIRECTORY );
  1583.     PINSTANCE pi = INSTDATA( hwndClient );
  1584.  
  1585.     if( !pi )
  1586.     {
  1587.         Msg( "FilterDirectories cant get Instdata RC(%X)", HWNDERR( hwndCnr ) );
  1588.         return;
  1589.     }
  1590.  
  1591.     // Toggle the 'FilterDirectories' flag.
  1592.  
  1593.     pi->fFilterDirs ^= TRUE;
  1594.  
  1595.     // If filtering, let the container do it for us with the help of our filter
  1596.     // function. If not, sending the container a CM_FILTER message with NULL
  1597.     // for the filter function reverses the filtering process.
  1598.  
  1599.     if( !WinSendMsg( hwndCnr, CM_FILTER,
  1600.                      pi->fFilterDirs ? MPFROMP( FilterDirs ) : NULL, NULL ) )
  1601.     {
  1602.         // The docs say that if there are no filtered items you will get a
  1603.         // PMERR_NO_FILTERED_ITEMS return code, but that error code is not in
  1604.         // any of the headers. If you send CM_FILTER with NULL for the filter
  1605.         // function and there weren't any filtered records you get a 0x1F02
  1606.         // error message which is also not documented. Might as well not do
  1607.         // any error-checking <sigh>.
  1608.  
  1609.         //USHORT usErr = HWNDERR( hwndCnr );
  1610.         //if( usErr != PMERR_NO_FILTERED_ITEMS )
  1611.         //    Msg( "FilterDirectories CM_FILTER RC(%X)", usErr );
  1612.         hwndCnr=hwndCnr; //Keep compiler happy ("empty if statement")
  1613.     }
  1614. }
  1615.  
  1616. /**********************************************************************/
  1617. /*---------------------------- FilterDirs ----------------------------*/
  1618. /*                                                                    */
  1619. /*  FILTER FUNCTION FOR FILTERING DIRECTORIES.                        */
  1620. /*                                                                    */
  1621. /*  INPUT: record to be inspected,                                    */
  1622. /*         application storage area (not used here)                   */
  1623. /*                                                                    */
  1624. /*  1.                                                                */
  1625. /*                                                                    */
  1626. /*  NOTES: The container really just sets the CRA_FILTERED bit in the */
  1627. /*         record if FALSE is returned. It invalidates the container  */
  1628. /*         records after all records have passed through here.        */
  1629. /*                                                                    */
  1630. /*  OUTPUT: TRUE if the record is to be viewable, FALSE if not        */
  1631. /*                                                                    */
  1632. /*--------------------------------------------------------------------*/
  1633. /**********************************************************************/
  1634. static BOOL APIENTRY FilterDirs( PRECORDCORE prc, PVOID pv )
  1635. {
  1636.     pv = pv; // Keep the compiler happy.
  1637.  
  1638.     return !(((PCNRITEM)prc)->attrFile & FILE_DIRECTORY );
  1639. }
  1640.  
  1641. /*************************************************************************
  1642.  *                     E N D     O F     S O U R C E                     *
  1643.  *************************************************************************/
  1644.