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