home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sftick.zip / adv / contain / CONTAIN3.C < prev    next >
Text File  |  1994-05-05  |  22KB  |  675 lines

  1. #define INCL_WINFRAMEMGR
  2. #define INCL_WINMENUS
  3. #define INCL_WINPOINTERS
  4. #define INCL_WINSTDCNR
  5. #define INCL_WINSYS
  6. #define INCL_WINWINDOWMGR
  7.  
  8. #include <os2.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13.  
  14. #include "CONTAIN3.H"
  15.  
  16. #define CLS_CLIENT               "SampleClass"
  17.  
  18. #define MAX_RECORDS                10
  19.  
  20. //----------------------------------------------------
  21. // For the GA 2.0 toolkit, CRA_SOURCE is not defined,
  22. // but it should be.
  23. //----------------------------------------------------
  24.  
  25. #ifndef CRA_SOURCE
  26. #define CRA_SOURCE               0x00004000L
  27. #endif
  28.  
  29. typedef struct _CLIENTDATA {
  30.    HWND     hwndCnr ;
  31.    HPOINTER hptrIcon ;
  32.    HWND     hwndMenu ;
  33.    BOOL     bCnrSelected ;
  34. } CLIENTDATA, *PCLIENTDATA ;
  35.  
  36. typedef struct _RECORDINFO {
  37.    MINIRECORDCORE mrcStd ;
  38.    BOOL           bEmphasized ;
  39. } RECORDINFO, *PRECORDINFO ;
  40.  
  41. MRESULT EXPENTRY clientWndProc ( HWND hwndClient,
  42.                                  ULONG ulMsg,
  43.                                  MPARAM mpParm1,
  44.                                  MPARAM mpParm2 ) ;
  45.  
  46. CHAR *pRecordTitles[] = {"KLetter",
  47.                          "BLetter",
  48.                          "ZLetter",
  49.                          "OOOOOOOO",
  50.                          "11111111",
  51.                          "Panov",
  52.                          "Woo",
  53.                          "Watts",
  54.                          "Art of OS/2",
  55.                          "Hello, World!" } ;
  56.  
  57. /* record initalization function */
  58. VOID initRecordInfo ( PCLIENTDATA pcdData,
  59.                       PRECORDINFO psiRecord,
  60.                       USHORT usIndex ) ;
  61. /* sort Routine */
  62. SHORT pfnSortRecords( PMINIRECORDCORE pmr1,
  63.                       PMINIRECORDCORE pmr2,
  64.                       PVOID pStorage) ;
  65.  
  66. /* routine to turn on and off emphasis */
  67. VOID emphasizeRecs ( HWND hwndCnr, BOOL bEmphasize ) ;
  68.  
  69. /* routine to free all the container memory */
  70. VOID freeCnrInfo ( HWND hwndCnr ) ;
  71.  
  72. INT main ( VOID )
  73. {
  74.    HAB          habAnchor ;
  75.    HMQ          hmqQueue ;
  76.    ULONG        ulFlags ;
  77.    HWND         hwndFrame ;
  78.    QMSG         qmMsg ;
  79.  
  80.  
  81.    /* basic PM stuff */
  82.  
  83.    habAnchor = WinInitialize ( 0 ) ;
  84.    hmqQueue = WinCreateMsgQueue ( habAnchor, 0 ) ;
  85.  
  86.    WinRegisterClass ( habAnchor,
  87.                       CLS_CLIENT,
  88.                       clientWndProc,
  89.                       0,
  90.                       sizeof ( PVOID )) ;
  91.  
  92.    ulFlags = FCF_SIZEBORDER | FCF_TITLEBAR |
  93.              FCF_TASKLIST | FCF_SHELLPOSITION |
  94.              FCF_SYSMENU ;
  95.  
  96.    hwndFrame = WinCreateStdWindow ( HWND_DESKTOP,
  97.                                     WS_VISIBLE,
  98.                                     &ulFlags,
  99.                                     CLS_CLIENT,
  100.                                     "Container Sample",
  101.                                     0,
  102.                                     NULLHANDLE,
  103.                                     RES_CLIENT,
  104.                                     NULL ) ;
  105.  
  106.    if ( hwndFrame ) {
  107.       while ( WinGetMsg ( habAnchor, &qmMsg, NULLHANDLE, 0, 0 ))
  108.          WinDispatchMsg ( habAnchor, &qmMsg ) ;
  109.  
  110.       WinDestroyWindow ( hwndFrame ) ;
  111.    } /* endif */
  112.  
  113.    WinDestroyMsgQueue ( hmqQueue ) ;
  114.    WinTerminate ( habAnchor ) ;
  115.    return 0 ;
  116. }
  117.  
  118.  
  119.  
  120.  
  121.  
  122. MRESULT EXPENTRY clientWndProc ( HWND hwndClient,
  123.                                  ULONG ulMsg,
  124.                                  MPARAM mpParm1,
  125.                                  MPARAM mpParm2 )
  126. {
  127.    PCLIENTDATA pcdData ;
  128.  
  129.    pcdData = ( PCLIENTDATA ) WinQueryWindowPtr ( hwndClient, 0 ) ;
  130.  
  131.    switch ( ulMsg ) {
  132.    case WM_CREATE:
  133.       {
  134.          MENUITEM miItem ;
  135.          ULONG ulStyle ;
  136.          ULONG ulExtra ;
  137.          RECORDINSERT riRecord ;
  138.          PRECORDINFO psiRecords ;
  139.          PRECORDINFO psiHeadRecord ;
  140.          USHORT usIndex1 ;
  141.  
  142.          /* allocate window word data */
  143.          pcdData = ( PCLIENTDATA ) malloc ( sizeof ( CLIENTDATA ));
  144.  
  145.          /* error checking */
  146.          if ( pcdData ==  NULL ) {
  147.             WinAlarm ( HWND_DESKTOP, WA_ERROR ) ;
  148.             WinMessageBox ( HWND_DESKTOP,
  149.                             HWND_DESKTOP,
  150.                             "No memory is available",
  151.                             "Error",
  152.                             0,
  153.                             MB_ICONEXCLAMATION | MB_OK ) ;
  154.             return MRFROMSHORT ( TRUE ) ;
  155.          } /* endif */
  156.  
  157.          /* assign window word to client window */
  158.          WinSetWindowPtr ( hwndClient, QWL_USER, pcdData ) ;
  159.  
  160.          pcdData->hwndCnr = NULLHANDLE ;
  161.          pcdData->hptrIcon = NULLHANDLE ;
  162.          pcdData->hwndMenu = NULLHANDLE ;
  163.          pcdData->bCnrSelected = FALSE ;
  164.  
  165.          pcdData->hwndCnr = WinCreateWindow (
  166.                                      hwndClient,
  167.                                      WC_CONTAINER,
  168.                                      "",
  169.                                      CCS_MINIRECORDCORE |
  170.                                      CCS_EXTENDSEL |
  171.                                      WS_VISIBLE,
  172.                                      0,
  173.                                      0,
  174.                                      0,
  175.                                      0,
  176.                                      hwndClient,
  177.                                      HWND_TOP,
  178.                                      WND_CONTAINER,
  179.                                      NULL,
  180.                                      NULL ) ;
  181.  
  182.          /* error checking */
  183.          if ( pcdData->hwndCnr ==  NULLHANDLE ) {
  184.  
  185.             free ( pcdData ) ;
  186.             WinAlarm ( HWND_DESKTOP, WA_ERROR ) ;
  187.             WinMessageBox ( HWND_DESKTOP,
  188.                             HWND_DESKTOP,
  189.                             "Cannot create container",
  190.                             "Error",
  191.                             0,
  192.                             MB_ICONEXCLAMATION | MB_OK ) ;
  193.             return MRFROMSHORT ( TRUE ) ;
  194.          } /* endif */
  195.  
  196.          /* load icon and popup menu */
  197.          pcdData->hptrIcon = WinLoadPointer ( HWND_DESKTOP,
  198.                                     NULLHANDLE,
  199.                                     ICO_ITEM ) ;
  200.  
  201.          pcdData->hwndMenu = WinLoadMenu ( hwndClient,
  202.                                          NULLHANDLE,
  203.                                          RES_CLIENT ) ;
  204.  
  205.          /* what is the menuitem window handle for the VIEW */
  206.          /* submenu ? */
  207.          WinSendMsg ( pcdData->hwndMenu,
  208.                       MM_QUERYITEM,
  209.                       MPFROM2SHORT ( M_VIEWS, TRUE ) ,
  210.                       MPFROMP ( &miItem )) ;
  211.  
  212.  
  213.          /* change menu style to conditional cascade */
  214.          ulStyle = WinQueryWindowULong ( miItem.hwndSubMenu,
  215.                                          QWL_STYLE ) ;
  216.  
  217.          ulStyle |= MS_CONDITIONALCASCADE ;
  218.          WinSetWindowULong ( miItem.hwndSubMenu,
  219.                              QWL_STYLE,
  220.                              ulStyle ) ;
  221.  
  222.  
  223.          /* set default to icon view */
  224.          WinSendMsg ( miItem.hwndSubMenu,
  225.                       MM_SETDEFAULTITEMID,
  226.                       MPFROMSHORT ( MI_ICON ) ,
  227.                       0 ) ;
  228.  
  229.  
  230.          /* what is the extra space */
  231.          ulExtra = sizeof ( RECORDINFO ) -
  232.                    sizeof ( MINIRECORDCORE ) ;
  233.  
  234.  
  235.          /* record info */
  236.          riRecord.cb = sizeof ( RECORDINSERT ) ;
  237.          riRecord.pRecordOrder = ( PRECORDCORE ) CMA_END ;
  238.          riRecord.fInvalidateRecord = FALSE ;
  239.          riRecord.zOrder = CMA_TOP ;
  240.  
  241.  
  242.          /* allocate the container memory for each record */
  243.          psiHeadRecord = ( PRECORDINFO ) PVOIDFROMMR (
  244.                            WinSendMsg ( pcdData->hwndCnr,
  245.                                      CM_ALLOCRECORD,
  246.                                      MPFROMLONG ( ulExtra ) ,
  247.                                      MPFROMSHORT ( MAX_RECORDS ))) ;
  248.  
  249.  
  250.          /* set the current record at the first of the linked list */
  251.          psiRecords = psiHeadRecord ;
  252.  
  253.          /* cycle through all records in memory, initializing */
  254.          /* each one */
  255.  
  256.          for ( usIndex1 = 0 ; usIndex1 < MAX_RECORDS ;
  257.                   usIndex1 ++ ) {
  258.  
  259.             /* initialize */
  260.             initRecordInfo( pcdData, psiRecords, usIndex1 ) ;
  261.  
  262.  
  263.             /* get the next record in the linked list */
  264.             psiRecords =
  265.                (PRECORDINFO) psiRecords->mrcStd.preccNextRecord ;
  266.          } /* endfor */
  267.  
  268.          /* records will have no parent, and number to be */
  269.          /* inserted is  MAX_RECORDS                      */
  270.  
  271.          riRecord.pRecordParent = NULL ;
  272.          riRecord.cRecordsInsert = MAX_RECORDS ;
  273.  
  274.          /* insert all the records in one batch */
  275.          WinSendMsg ( pcdData->hwndCnr,
  276.                       CM_INSERTRECORD,
  277.                       MPFROMP ( psiHeadRecord ) ,
  278.                       MPFROMP ( &riRecord )) ;
  279.  
  280.  
  281.  
  282.          /* sort all the records */
  283.          WinSendMsg( pcdData->hwndCnr,
  284.                      CM_SORTRECORD,
  285.                      MPFROMP(pfnSortRecords),
  286.                      MPVOID ) ;
  287.  
  288.          WinSendMsg ( hwndClient,
  289.                       WM_COMMAND,
  290.                       MPFROMSHORT ( MI_ICON ) ,
  291.                       0 ) ;
  292.       }
  293.       break ;
  294.  
  295.    case WM_DESTROY:
  296.       freeCnrInfo ( pcdData->hwndCnr ) ;
  297.  
  298.       if ( pcdData->hwndCnr ) {
  299.          WinDestroyWindow ( pcdData->hwndCnr ) ;
  300.       } /* endif */
  301.  
  302.       if ( pcdData->hptrIcon ) {
  303.          WinDestroyPointer ( pcdData->hptrIcon ) ;
  304.       } /* endif */
  305.  
  306.       free ( pcdData ) ;
  307.       break ;
  308.  
  309.    case WM_SIZE:
  310.       if ( pcdData->hwndCnr != NULLHANDLE ) {
  311.  
  312.          WinSetWindowPos ( pcdData->hwndCnr,
  313.                            NULLHANDLE,
  314.                            0,
  315.                            0,
  316.                            SHORT1FROMMP ( mpParm2 ) ,
  317.                            SHORT2FROMMP ( mpParm2 ) ,
  318.                            SWP_MOVE | SWP_SIZE ) ;
  319.       } /* endif */
  320.       break ;
  321.  
  322.    /* once an item is chosen from the menu, turn off selection */
  323.    case WM_MENUEND:
  324.  
  325.       switch ( SHORT1FROMMP ( mpParm1 )) {
  326.       case FID_MENU:
  327.          if ( pcdData->bCnrSelected ) {
  328.             WinSendMsg ( pcdData->hwndCnr,
  329.                          CM_SETRECORDEMPHASIS,
  330.                          0,
  331.                          MPFROM2SHORT ( FALSE, CRA_SOURCE )) ;
  332.             pcdData->bCnrSelected = FALSE ;
  333.          } else {
  334.             emphasizeRecs ( pcdData->hwndCnr, FALSE ) ;
  335.          } /* endif */
  336.          break ;
  337.  
  338.       default:
  339.          return WinDefWindowProc ( hwndClient,
  340.                                    ulMsg,
  341.                                    mpParm1,
  342.                                    mpParm2 ) ;
  343.       } /* endswitch */
  344.       break ;
  345.  
  346.    case WM_CONTROL:
  347.       switch ( SHORT1FROMMP ( mpParm1 )) {
  348.       case WND_CONTAINER:
  349.          switch ( SHORT2FROMMP ( mpParm1 )) {
  350.          case CN_CONTEXTMENU:
  351.             {
  352.                PRECORDINFO psiRecord ;
  353.                POINTL ptlMouse ;
  354.  
  355.                /* Get the record that the user selected for a menu */
  356.  
  357.                psiRecord = ( PRECORDINFO ) PVOIDFROMMP ( mpParm2 ) ;
  358.                if ( psiRecord ) {
  359.                   if (( psiRecord->mrcStd.flRecordAttr &
  360.                     CRA_SELECTED ) == 0 )
  361.                   {
  362.                      /* if selected is FALSE, set it to SOURCE emphasis */
  363.                      WinSendMsg ( pcdData->hwndCnr,
  364.                                   CM_SETRECORDEMPHASIS,
  365.                                   MPFROMP ( psiRecord ) ,
  366.                                   MPFROM2SHORT ( TRUE, CRA_SOURCE )) ;
  367.                      psiRecord->bEmphasized = TRUE ;
  368.                   } else {
  369.                      /* find which records are selected and set */
  370.                      /* SELECTED emphasis ON */
  371.                      emphasizeRecs ( pcdData->hwndCnr, TRUE ) ;
  372.                   } /* endif */
  373.                } else {
  374.                   /* turn SOURCE emphasis on for the entire container */
  375.                   WinSendMsg ( pcdData->hwndCnr,
  376.                                CM_SETRECORDEMPHASIS,
  377.                                0,
  378.                                MPFROM2SHORT ( TRUE, CRA_SOURCE )) ;
  379.                   pcdData->bCnrSelected = TRUE ;
  380.                } /* endif */
  381.  
  382.                /* where is the pointer? */
  383.  
  384.                WinQueryPointerPos ( HWND_DESKTOP, &ptlMouse ) ;
  385.  
  386.                /* map the pointer to client window coordinates */
  387.                WinMapWindowPoints ( HWND_DESKTOP,
  388.                                     hwndClient,
  389.                                     &ptlMouse,
  390.                                     1 ) ;
  391.  
  392.  
  393.                /* popup menu */
  394.                WinPopupMenu ( hwndClient,
  395.                               hwndClient,
  396.                               pcdData->hwndMenu,
  397.                               ptlMouse.x,
  398.                               ptlMouse.y,
  399.                               M_VIEWS,
  400.                               PU_HCONSTRAIN |
  401.                               PU_VCONSTRAIN |
  402.                               PU_KEYBOARD |
  403.                               PU_MOUSEBUTTON1 |
  404.                               PU_MOUSEBUTTON2 |
  405.                               PU_NONE ) ;
  406.             }
  407.             break ;
  408.  
  409.          default:
  410.             return WinDefWindowProc ( hwndClient,
  411.                                       ulMsg,
  412.                                       mpParm1,
  413.                                       mpParm2 ) ;
  414.          } /* endswitch */
  415.          break ;
  416.  
  417.       default:
  418.          return WinDefWindowProc ( hwndClient,
  419.                                    ulMsg,
  420.                                    mpParm1,
  421.                                    mpParm2 ) ;
  422.       } /* endswitch */
  423.       break ;
  424.  
  425.    case WM_COMMAND:
  426.       switch ( SHORT1FROMMP ( mpParm1 )) {
  427.       case MI_ICON:
  428.          {
  429.             CNRINFO ciInfo ;
  430.  
  431.             ciInfo.cb = sizeof ( CNRINFO ) ;
  432.             ciInfo.flWindowAttr = CV_ICON ;
  433.  
  434.             WinSendMsg ( pcdData->hwndCnr,
  435.                          CM_SETCNRINFO,
  436.                          MPFROMP ( &ciInfo ) ,
  437.                          MPFROMLONG ( CMA_FLWINDOWATTR )) ;
  438.  
  439.             WinSendMsg ( pcdData->hwndCnr,
  440.                          CM_ARRANGE,
  441.                          NULL,
  442.                          NULL ) ;
  443.          }
  444.          break ;
  445.  
  446.  
  447.       case MI_TREE:
  448.          {
  449.             CNRINFO ciInfo ;
  450.  
  451.             ciInfo.cb = sizeof ( CNRINFO ) ;
  452.             ciInfo.flWindowAttr = CV_TREE | CV_ICON | CA_TREELINE ;
  453.             ciInfo.cxTreeIndent = - 1 ;
  454.             ciInfo.cxTreeLine = - 1 ;
  455.  
  456.             WinSendMsg ( pcdData->hwndCnr,
  457.                          CM_SETCNRINFO,
  458.                          MPFROMP ( &ciInfo ) ,
  459.                          MPFROMLONG ( CMA_FLWINDOWATTR )) ;
  460.          }
  461.          break ;
  462.  
  463.       case MI_NAMEFLOWED:
  464.          {
  465.             CNRINFO ciInfo ;
  466.  
  467.             ciInfo.cb = sizeof ( CNRINFO ) ;
  468.             ciInfo.flWindowAttr = CV_NAME | CV_FLOW ;
  469.  
  470.             WinSendMsg ( pcdData->hwndCnr,
  471.                          CM_SETCNRINFO,
  472.                          MPFROMP ( &ciInfo ) ,
  473.                          MPFROMLONG ( CMA_FLWINDOWATTR )) ;
  474.  
  475.             WinSendMsg ( pcdData->hwndCnr,
  476.                          CM_ARRANGE,
  477.                          NULL,
  478.                          NULL ) ;
  479.          }
  480.          break ;
  481.  
  482.       case MI_TEXTFLOWED:
  483.          {
  484.             CNRINFO ciInfo ;
  485.  
  486.             ciInfo.cb = sizeof ( CNRINFO ) ;
  487.             ciInfo.flWindowAttr = CV_TEXT | CV_FLOW ;
  488.  
  489.             WinSendMsg ( pcdData->hwndCnr,
  490.                          CM_SETCNRINFO,
  491.                          MPFROMP ( &ciInfo ) ,
  492.                          MPFROMLONG ( CMA_FLWINDOWATTR )) ;
  493.  
  494.             WinSendMsg ( pcdData->hwndCnr,
  495.                          CM_ARRANGE,
  496.                          NULL,
  497.                          NULL ) ;
  498.          }
  499.          break ;
  500.  
  501.       case MI_EXIT:
  502.          WinPostMsg ( hwndClient, WM_CLOSE, 0, 0 ) ;
  503.          break ;
  504.  
  505.       case MI_RESUME:
  506.          break ;
  507.  
  508.       default:
  509.          return WinDefWindowProc ( hwndClient,
  510.                                    ulMsg,
  511.                                    mpParm1,
  512.                                    mpParm2 ) ;
  513.       } /* endswitch */
  514.       break ;
  515.  
  516.    case WM_PAINT:
  517.       {
  518.          HPS hpsPaint ;
  519.          RECTL rclPaint ;
  520.  
  521.          hpsPaint = WinBeginPaint ( hwndClient,
  522.                                     NULLHANDLE,
  523.                                     &rclPaint ) ;
  524.  
  525.          WinFillRect ( hpsPaint, &rclPaint, SYSCLR_WINDOW ) ;
  526.          WinEndPaint ( hpsPaint ) ;
  527.       }
  528.       break ;
  529.  
  530.    default:
  531.       return WinDefWindowProc ( hwndClient,
  532.                                 ulMsg,
  533.                                 mpParm1,
  534.                                 mpParm2 ) ;
  535.    } /* endswitch */
  536.  
  537.    return MRFROMSHORT ( FALSE ) ;
  538. }
  539.  
  540. /****************************************************************/
  541. /*                                                              */
  542. /* This routine is used to sort all records in the container    */
  543. /*                                                              */
  544. /****************************************************************/
  545.  
  546. SHORT EXPENTRY pfnSortRecords( PMINIRECORDCORE pmr1,
  547.                                PMINIRECORDCORE pmr2,
  548.                                PVOID pStorage)
  549. {
  550.  
  551.    SHORT sBig ;
  552.    PRECORDINFO pRecord1, pRecord2 ;
  553.  
  554.    pRecord1 = (PRECORDINFO)pmr1 ;
  555.    pRecord2 = (PRECORDINFO)pmr2 ;
  556.    sBig = strcmp( pRecord1->mrcStd.pszIcon, pRecord2->mrcStd.pszIcon ) ;
  557.  
  558.    return (sBig ) ;
  559.  
  560. }
  561.  
  562. /****************************************************************/
  563. /*                                                              */
  564. /* This routine is used initialize all records in the container */
  565. /*                                                              */
  566. /****************************************************************/
  567.  
  568. VOID initRecordInfo ( PCLIENTDATA pcdData,
  569.                       PRECORDINFO psiRecord,
  570.                       USHORT usIndex )
  571. {
  572.  
  573.    psiRecord->mrcStd.cb = sizeof ( MINIRECORDCORE ) ;
  574.  
  575.    psiRecord->mrcStd.pszIcon = malloc ( 256 ) ;
  576.    if ( psiRecord->mrcStd.pszIcon )
  577.          strcpy( psiRecord->mrcStd.pszIcon, pRecordTitles[usIndex] ) ;
  578.  
  579.    psiRecord->mrcStd.hptrIcon = pcdData->hptrIcon ;
  580.    psiRecord->bEmphasized = FALSE ;
  581.  
  582.  
  583.    return ;
  584. }
  585. /****************************************************************/
  586. /*                                                              */
  587. /* This routine is used to turn on and off the emphasis for all */
  588. /* selected records                                             */
  589. /*                                                              */
  590. /****************************************************************/
  591.  
  592. VOID emphasizeRecs ( HWND hwndCnr, BOOL bEmphasize )
  593. {
  594.    SHORT          sFlag ;
  595.    PRECORDINFO    psiRecord ;
  596.  
  597.    /* Do I want source emphasis or selected emphasis */
  598.    sFlag = (( bEmphasize ) ? CRA_SELECTED : CRA_SOURCE ) ;
  599.  
  600.    /* Get the first record with emphasis */
  601.    psiRecord = ( PRECORDINFO ) PVOIDFROMMR (
  602.                 WinSendMsg ( hwndCnr,
  603.                              CM_QUERYRECORDEMPHASIS,
  604.                              MPFROMP ( CMA_FIRST ) ,
  605.                              MPFROMSHORT ( sFlag )) ) ;
  606.  
  607.    while ( psiRecord ) {
  608.       /* if TRUE, turn on SOURCE emphasis */
  609.       if ( bEmphasize ) {
  610.          WinSendMsg ( hwndCnr,
  611.                       CM_SETRECORDEMPHASIS,
  612.                       MPFROMP ( psiRecord ) ,
  613.                       MPFROM2SHORT ( TRUE, CRA_SOURCE )) ;
  614.  
  615.          psiRecord->bEmphasized = TRUE ;
  616.       } else {
  617.  
  618.          /* if FALSE, turn off SOURCE emphasis */
  619.          WinSendMsg ( hwndCnr,
  620.                       CM_SETRECORDEMPHASIS,
  621.                       MPFROMP ( psiRecord ) ,
  622.                       MPFROM2SHORT ( FALSE, CRA_SOURCE )) ;
  623.  
  624.          psiRecord->bEmphasized = FALSE ;
  625.       } /* endif */
  626.  
  627.       /* get next selected record */
  628.       psiRecord = ( PRECORDINFO ) PVOIDFROMMR (
  629.                     WinSendMsg ( hwndCnr,
  630.                                  CM_QUERYRECORDEMPHASIS,
  631.                                  MPFROMP ( psiRecord ) ,
  632.                                  MPFROMSHORT ( sFlag ))) ;
  633.    } /* endwhile */
  634.    return ;
  635. }
  636.  
  637. /****************************************************************/
  638. /*                                                              */
  639. /* this routine is called when the container is being close to  */
  640. /* free all the memory that was allocated for the container     */
  641. /*                                                              */
  642. /****************************************************************/
  643.  
  644. VOID freeCnrInfo ( HWND hwndCnr )
  645. {
  646.    PRECORDINFO psiRecord ;
  647.  
  648.  
  649.    /* get the first record */
  650.    psiRecord = ( PRECORDINFO ) PVOIDFROMMR (
  651.                 WinSendMsg ( hwndCnr,
  652.                              CM_QUERYRECORD,
  653.                              0,
  654.                              MPFROM2SHORT ( CMA_FIRST,
  655.                                             CMA_ITEMORDER ))) ;
  656.    while (psiRecord) {
  657.  
  658.        /* free title string */
  659.  
  660.        if ( psiRecord->mrcStd.pszIcon ) {
  661.           free ( psiRecord->mrcStd.pszIcon ) ;
  662.        } /* endif */
  663.  
  664.  
  665.        /* get next record */
  666.        psiRecord = ( PRECORDINFO ) PVOIDFROMMR (
  667.                      WinSendMsg ( hwndCnr,
  668.                                   CM_QUERYRECORD,
  669.                                   MPFROMP ( psiRecord ) ,
  670.                                   MPFROM2SHORT ( CMA_NEXT,
  671.                                              CMA_ITEMORDER ))) ;
  672.    } /* endwhile */
  673.    return ;
  674. }
  675.