home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / framctl2.zip / FRAMECTL.C next >
C/C++ Source or Header  |  1996-10-07  |  30KB  |  571 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /* Program name:   FrameCtl.C                                           */
  4. /* Title:          A Picture Perfect Control                            */
  5. /*                 OS/2 Magazine - GUI Corner                           */
  6. /*                 October 1996 issue                                   */
  7. /*                                                                      */
  8. /* Author:         Mark Benge   IBM Corp.                               */
  9. /*                 Matt Smith   Prominare Inc.                          */
  10. /*                                                                      */
  11. /* Description:    Illustrates how to add frame control extensions.     */
  12. /*                                                                      */
  13. /* DISCLAIMER OF WARRANTIES:                                            */
  14. /* -------------------------                                            */
  15. /* The following [enclosed] code is sample code created by IBM          */
  16. /* Corporation and Prominare Inc.  This sample code is not part of any  */
  17. /* standard IBM product and is provided to you solely for the purpose   */
  18. /* of assisting you in the development of your applications.  The code  */
  19. /* is provided "AS IS", without warranty of any kind.  Neither IBM nor  */
  20. /* Prominare shall be liable for any damages arising out of your        */
  21. /* use of the sample code, even if they have been advised of the        */
  22. /* possibility of such damages.                                         */
  23. /************************************************************************/
  24.  
  25. #define INCL_DOS                   /* Include OS/2 DOS Kernal           */
  26. #define INCL_GPI                   /* Include OS/2 PM GPI Interface     */
  27. #define INCL_WIN                   /* Include OS/2 PM Windows Interface */
  28.  
  29. #include <os2.h>
  30. #include <string.h>
  31. #include <stdio.h>
  32. #include <malloc.h>
  33.  
  34. #include "framectl.h"
  35.  
  36. /************************************************************************/
  37. /* This module contains example installable control that can be used    */
  38. /* by any OS/2 2.x and Warp Presentation Manager application.  The      */
  39. /* sample demonstrates the principles of adding frame control           */
  40. /* extensions such that other extensions can be added using this as     */
  41. /* a model.                                                             */
  42. /*                                                                      */
  43. /* Filename : FrameCtl.C                                                */
  44. /* Version  : 1.00                                                      */
  45. /* Created  : 1996-06-07                                                */
  46. /* Revised  :                                                           */
  47. /* Released :                                                           */
  48. /*                                                                      */
  49. /* Routines:  MRESULT EXPENTRY FrameWndProc( HWND hWnd, ULONG msg,      */
  50. /*                                           MPARAM mp1, MPARAM mp2 )   */
  51. /*            int main(int argc, char* argv[] )                         */
  52. /*                                                                      */
  53. /* Copyright ╕ International Business Machines Corp., 1991,1992,1993.   */
  54. /* Copyright ╕ 1989-1993  Prominare Inc.  All Rights Reserved.          */
  55. /*                                                                      */
  56. /************************************************************************/
  57.  
  58. HWND hwndHelpBtn;                  /* Help Button Handle                */
  59. HWND hwndComboBox;                 /* Combo Box Handle                  */
  60. PFNWP DefFrameWndProc;             /* Frame Control Subclass Procedure  */
  61.  
  62. LONG lMinTitleHeight = 0;          /* Height of the title bar           */
  63. LONG lMinMenuHeight = 0;           /* Height of the menu bar            */
  64.  
  65. LONG colorArray[] = { CLR_BLUE, CLR_WHITE, CLR_RED,
  66.                       CLR_GREEN, CLR_BLACK };
  67.  
  68. /************************************************************************/
  69. /* Prototypes                                                           */
  70. /************************************************************************/
  71. int main( int, char* [] );
  72. MRESULT EXPENTRY FrameWndProc( HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  73. LONG CalcMenuBarMinWidth( HWND hWnd );
  74.  
  75. /* --- FrameWndProc ----------------------------------- [ Private ] --- */
  76. /*                                                                      */
  77. /*     This function is used to process the messages for the frame      */
  78. /*     control window.                                                  */
  79. /*                                                                      */
  80. /*     Upon Entry:                                                      */
  81. /*                                                                      */
  82. /*     HWND   hWnd; = Window Handle                                     */
  83. /*     ULONG  msg;  = PM Message                                        */
  84. /*     MPARAM mp1;  = Message Parameter 1                               */
  85. /*     MPARAM mp2;  = Message Parameter 2                               */
  86. /*                                                                      */
  87. /*     Upon Exit:                                                       */
  88. /*                                                                      */
  89. /* -------------------------------------------------------------------- */
  90. MRESULT EXPENTRY FrameWndProc( HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  91. {
  92.   switch ( msg )
  93.   {
  94.     case WM_FORMATFRAME :
  95.     {
  96.       /******************************************************************/
  97.       /* Query the number of standard frame controls                    */
  98.       /******************************************************************/
  99.       ULONG ulStdCtlCount = (ULONG)DefFrameWndProc( hWnd, msg, mp1, mp2 );
  100.       ULONG ulIdx = ulStdCtlCount;
  101.  
  102.       /******************************************************************/
  103.       /* Access the SWP array that is passed to us                      */
  104.       /******************************************************************/
  105.       ULONG i;
  106.       PSWP swpArr = (PSWP)mp1;
  107.  
  108.       for (i=0; i < ulStdCtlCount; i++)
  109.       {
  110.         if ( WinQueryWindowUShort( swpArr[i].hwnd, QWS_ID ) == FID_TITLEBAR )
  111.         {
  112.           /**************************************************************/
  113.           /* Initialize the SWPs for our graphic button control.        */
  114.           /* Since the SWP array for the std frame controls is 0-based  */
  115.           /* and occupy indexes 0 thru n-1 (where n is the total        */
  116.           /* count), we use index n for our graphic button control.     */
  117.           /* Please note that the width and height of our button is the */
  118.           /* same as the height of the title bar.                       */
  119.           /**************************************************************/
  120.           swpArr[ulIdx].fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST;
  121.           swpArr[ulIdx].cy = swpArr[i].cy;
  122.           swpArr[ulIdx].cx = swpArr[ulIdx].cy;
  123.           swpArr[ulIdx].y  = swpArr[i].y;
  124.           swpArr[ulIdx].hwndInsertBehind = HWND_TOP;
  125.  
  126.           /**************************************************************/
  127.           /* Calculate the x-position for the help graphic button, and  */
  128.           /* set its window handle.                                     */
  129.           /**************************************************************/
  130.           swpArr[ulIdx].x = swpArr[i].x + swpArr[i].cx - swpArr[ulIdx].cx;
  131.           swpArr[ulIdx].hwnd = hwndHelpBtn;
  132.  
  133.           /**************************************************************/
  134.           /* Adjust width of the title bar to accomodate the help       */
  135.           /* graphic button.                                            */
  136.           /**************************************************************/
  137.           swpArr[i].cx -= swpArr[ulIdx].cx;
  138.  
  139.           /**************************************************************/
  140.           /* Save the minimum title bar height that we'll use in        */
  141.           /* WM_QUERYTRACKINFO processing to calculate the minimum      */
  142.           /* tracking height.                                           */
  143.           /**************************************************************/
  144.           lMinTitleHeight = (swpArr[i].cy > lMinTitleHeight) ? swpArr[i].cy
  145.                                                              : lMinTitleHeight;
  146.         }
  147.  
  148.         if ( WinQueryWindowUShort( swpArr[i].hwnd, QWS_ID ) == FID_MENU )
  149.         {
  150.           /**************************************************************/
  151.           /* Initialize the SWP for our drop down combo box.  Since     */
  152.           /* the SWP array for the std frame controls is 0-based and    */
  153.           /* occupy indexes 0 thru n-1 (where n is the total count),    */
  154.           /* and the graphic buttions occupy n and n+1, we start with   */
  155.           /* index n+2 for our drop down combo box.                     */
  156.           /**************************************************************/
  157.           /**************************************************************/
  158.           /* These values are the same for both controls, so we init    */
  159.           /* them all at once.  Please note that the width and height   */
  160.           /* of our buttons is the same as the height of the title bar. */
  161.           /**************************************************************/
  162.           swpArr[ulIdx+1].fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST;
  163.           swpArr[ulIdx+1].cy = COMBOBOX_HEIGHT;
  164.           swpArr[ulIdx+1].cx = COMBOBOX_WIDTH;
  165.           swpArr[ulIdx+1].y  = swpArr[i].y -
  166.                                (COMBOBOX_HEIGHT - swpArr[i].cy - 1);
  167.           swpArr[ulIdx+1].hwndInsertBehind = HWND_TOP;
  168.  
  169.           /**************************************************************/
  170.           /* Calculate the x-position for the help graphic button, and  */
  171.           /* set its window handle.                                     */
  172.           /**************************************************************/
  173.           swpArr[ulIdx+1].x = swpArr[i].x + swpArr[i].cx - swpArr[ulIdx+1].cx;
  174.           swpArr[ulIdx+1].hwnd = hwndComboBox;
  175.  
  176.           /**************************************************************/
  177.           /* Adjust the width of the menu bar to accomodate our drop    */
  178.           /* down combo box.                                            */
  179.           /**************************************************************/
  180.           swpArr[i].cx -= swpArr[ulIdx+1].cx;
  181.  
  182.           /**************************************************************/
  183.           /* Save the minimum menu bar height that we'll use in         */
  184.           /* WM_QUERYTRACKINFO processing to calculate the minimum      */
  185.           /* tracking height.                                           */
  186.           /**************************************************************/
  187.           lMinMenuHeight = (swpArr[i].cy > lMinMenuHeight) ? swpArr[i].cy
  188.                                                            : lMinMenuHeight;
  189.         }
  190.       }
  191.  
  192.       /******************************************************************/
  193.       /* Increment the number of frame controls to include our graphic  */
  194.       /* button control and drop down combo box.                        */
  195.       /******************************************************************/
  196.       return( (MRESULT)(ulIdx + 2) );
  197.     }
  198.  
  199.     case WM_QUERYFRAMECTLCOUNT :
  200.       /******************************************************************/
  201.       /* Query the standard frame controls count and increment to       */
  202.       /* include our graphic button control and drop down combo box.    */
  203.       /******************************************************************/
  204.       return( (MRESULT)((ULONG)DefFrameWndProc( hWnd, msg, mp1, mp2 ) + 2) );
  205.  
  206.     case WM_QUERYTRACKINFO :
  207.     {
  208.       /******************************************************************/
  209.       /* Query the default tracking information for the standard frame  */
  210.       /* control.                                                       */
  211.       /******************************************************************/
  212.       BOOL rc = (BOOL)DefFrameWndProc( hWnd, msg, mp1, mp2 );
  213.       PTRACKINFO pTrackInfo = (PTRACKINFO)mp2;
  214.  
  215.       /******************************************************************/
  216.       /* Calculate the minimum width that we require for the menu bar.  */
  217.       /******************************************************************/
  218.       LONG lMinMenuBarWidth = CalcMenuBarMinWidth( hWnd );
  219.  
  220.       if ( lMinMenuBarWidth == MIT_ERROR )
  221.         return( (MRESULT)FALSE );
  222.  
  223.       /******************************************************************/
  224.       /* Calculate and set the minimum tracking width and height.  Note */
  225.       /* that we only use the menu bar to calculate the minmum width.   */
  226.       /* You may want to expand this calculation to include the title   */
  227.       /* bar or other factors.                                          */
  228.       /******************************************************************/
  229.       pTrackInfo->ptlMinTrackSize.x = COMBOBOX_WIDTH +
  230.                                       lMinMenuBarWidth +
  231.                                       (WinQuerySysValue( HWND_DESKTOP,
  232.                                                          SV_CXSIZEBORDER ) * 2);
  233.       pTrackInfo->ptlMinTrackSize.y = lMinTitleHeight + lMinMenuHeight +
  234.                                       (WinQuerySysValue( HWND_DESKTOP,
  235.                                                          SV_CYSIZEBORDER ) * 2);
  236.       return( (MRESULT)TRUE );
  237.     }
  238.  
  239.     case WM_COMMAND :
  240.       if ( SHORT1FROMMP(mp2) == CMDSRC_MENU )
  241.       {
  242.         /****************************************************************/
  243.         /* Process the Exit request.                                    */
  244.         /****************************************************************/
  245.         if ( (USHORT)mp1 == MI_FILE_EXIT )
  246.         {
  247.           /**************************************************************/
  248.           /* Close the frame extensions sample application.             */
  249.           /**************************************************************/
  250.           WinPostMsg( hWnd, WM_CLOSE, 0, 0 );
  251.           return( (MRESULT)FALSE );
  252.         }
  253.         else
  254.         {
  255.           /**************************************************************/
  256.           /* Place holder for next issue.                               */
  257.           /**************************************************************/
  258.           if ( (USHORT)mp1 == MI_CAT_TBD )
  259.           {
  260.             /************************************************************/
  261.             /*                                                          */
  262.             /************************************************************/
  263.             return( (MRESULT)FALSE );
  264.           }
  265.         }
  266.       }
  267.       return( DefFrameWndProc( hWnd, msg, mp1, mp2 ) );
  268.  
  269.     case WM_CONTROL :
  270.       if ( (SHORT1FROMMP(mp1) == COMBOBOX_ID)  &&
  271.            (SHORT2FROMMP(mp1) == CBN_LBSELECT) )
  272.       {
  273.         /****************************************************************/
  274.         /* Process the list box selection notification.                 */
  275.         /****************************************************************/
  276.         LONG lFgnColor;
  277.         LONG lSelIndex = (LONG)WinSendMsg( (HWND)mp2,
  278.                                            LM_QUERYSELECTION,
  279.                                            MPFROMLONG(LIT_FIRST),
  280.                                            0 );
  281.         if ( lSelIndex == LIT_NONE )
  282.           return( FALSE );
  283.  
  284.         lFgnColor = colorArray[lSelIndex];
  285.         WinSetPresParam( WinWindowFromID( hWnd, FID_CLIENT ),
  286.                          PP_FOREGROUNDCOLORINDEX,
  287.                          4UL,
  288.                          &lFgnColor );
  289.  
  290.       }
  291.       return( DefFrameWndProc( hWnd, msg, mp1, mp2 ) );
  292.  
  293.     case WM_HELP :
  294.       /******************************************************************/
  295.       /* Process a click on the help graphic button.                    */
  296.       /******************************************************************/
  297.       if ( (USHORT)mp1 == HELP_BUTTON_ID )
  298.       {
  299.         /****************************************************************/
  300.         /* Display the help panel for this sample.                      */
  301.         /****************************************************************/
  302.         return( WinSendMsg( WinQueryHelpInstance( hWnd ),
  303.                             HM_DISPLAY_HELP,
  304.                             mp1,
  305.                             HM_RESOURCEID ) );
  306.       }
  307.  
  308.     default:
  309.       return( DefFrameWndProc( hWnd, msg, mp1, mp2 ) );
  310.   }
  311.  
  312.   return( (MRESULT)FALSE );
  313. }
  314.  
  315.  
  316. /* --- CalcMenuBarMinWidth ---------------------------- [ Private ] --- */
  317. /*                                                                      */
  318. /*     This function is used to dynamically calculate the minimum menu  */
  319. /*     bar width required to display the entire menu bar.               */
  320. /*                                                                      */
  321. /*     Upon Entry:                                                      */
  322. /*                                                                      */
  323. /*     HWND   hWnd; = Frame Window Handle                               */
  324. /*                                                                      */
  325. /*     Upon Exit:                                                       */
  326. /*                                                                      */
  327. /* -------------------------------------------------------------------- */
  328. LONG CalcMenuBarMinWidth( HWND hWnd )
  329. {
  330.   RECTL rect;
  331.   LONG i;
  332.   LONG lMinWidth = 0;
  333.   HWND hwndMenuBar = WinWindowFromID( hWnd, FID_MENU );
  334.  
  335.   /**********************************************************************/
  336.   /* Get the count of the menu items on the menu bar.                   */
  337.   /**********************************************************************/
  338.   LONG lMenuItemsCount = (LONG)WinSendMsg( hwndMenuBar,
  339.                                            MM_QUERYITEMCOUNT,
  340.                                            0,
  341.                                            0 );
  342.  
  343.   for ( i=0; i < lMenuItemsCount; i++ )
  344.   {
  345.     /********************************************************************/
  346.     /* Get the id of the menu item.                                     */
  347.     /********************************************************************/
  348.     LONG itemID = (LONG)WinSendMsg( hwndMenuBar,
  349.                                      MM_ITEMIDFROMPOSITION,
  350.                                      MPFROMLONG( i ),
  351.                                      0 );
  352.     if ( itemID == MIT_ERROR )
  353.       return( MIT_ERROR );
  354.  
  355.     /********************************************************************/
  356.     /* Get the rectangle for the menu item.                             */
  357.     /********************************************************************/
  358.     if ( WinSendMsg( hwndMenuBar,
  359.                      MM_QUERYITEMRECT,
  360.                      MPFROM2SHORT((USHORT)itemID, FALSE),
  361.                      MPFROMP(&rect) ) )
  362.     {
  363.       /******************************************************************/
  364.       /* Calculate the item's width and add it to the width of the      */
  365.       /* other items.                                                   */
  366.       /******************************************************************/
  367.       lMinWidth += (rect.xRight - rect.xLeft);
  368.     }
  369.     else
  370.       return( MIT_ERROR );
  371.   }
  372.  
  373.   return( lMinWidth );
  374. }
  375.  
  376.  
  377. /* --- main ----------------------------------------------------------- */
  378. /*     Main function.                                                   */
  379. /* -------------------------------------------------------------------- */
  380. int main( int argc, char* argv[] )
  381. {
  382.   HAB      hAB;                    /* Anchor Block Handle               */
  383.   HMQ      hMQ;                    /* Message Queue Handle              */
  384.   HWND     hwndClient;             /* Client Handle                     */
  385.   HWND     hwndFrame;              /* Frame Handle                      */
  386.   QMSG     qmsg;                   /* PM Message Queue Holder           */
  387.   ULONG    flCreateFlags;          /* Window Creation Flags             */
  388.   LONG     lFgnColor;              /* Foreground Color Holder           */
  389.   LONG     lBgnColor;              /* Background Color Holder           */
  390.   HWND     hwndHelp;               /* Help Instance Handle              */
  391.   HELPINIT helpInit;               /* Help Instance Structure           */
  392.   LBOXINFO lboxinfo;               /* List Box Info Structure           */
  393.   BOOL     bWarpV4 = FALSE;        /* OS/2 Warp V4.0 indicator          */
  394.   ULONG    ulVersion;              /* Version Return Variable           */
  395.   LONG     lCount,
  396.            lWidth,
  397.            lHeight;
  398.   ULONG    i;
  399.   PSZ      itemsArray[] = { "Blue Text",  "White Text", "Red Text",
  400.                             "Green Text", "Black Text" };
  401.  
  402.   /**********************************************************************/
  403.   /* Initialize the program for PM, create the message queue, and set   */
  404.   /* the codepage.                                                      */
  405.   /**********************************************************************/
  406.   hAB = WinInitialize( 0 );
  407.   hMQ = WinCreateMsgQueue( hAB, 0 );
  408.   WinSetCp( hMQ, 850 );
  409.  
  410.   /**********************************************************************/
  411.   /* Create a standard frame window, specifying a static text control   */
  412.   /* for the client area.                                               */
  413.   /**********************************************************************/
  414.   flCreateFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_MENU | FCF_SIZEBORDER |
  415.                   FCF_MINMAX | FCF_VERTSCROLL | FCF_HORZSCROLL | FCF_TASKLIST;
  416.  
  417.   hwndFrame = WinCreateStdWindow( HWND_DESKTOP,
  418.                                   0,
  419.                                   &flCreateFlags,
  420.                                   WC_STATIC,
  421.                                   "Frame Extensions",
  422.                                   (WS_VISIBLE | SS_TEXT | DT_CENTER |
  423.                                    DT_VCENTER),
  424.                                   (HMODULE)0L,
  425.                                   FRAME_WND_ID,
  426.                                   &hwndClient );
  427.   if ( !hwndFrame )
  428.     return( TRUE );
  429.  
  430.   /**********************************************************************/
  431.   /* Set the text for the static text control as well as the            */
  432.   /* foreground and background color of the control.                    */
  433.   /**********************************************************************/
  434.   lFgnColor = colorArray[0];
  435.   WinSetPresParam( hwndClient, PP_FOREGROUNDCOLORINDEX, 4UL, &lFgnColor );
  436.   lBgnColor = SYSCLR_DIALOGBACKGROUND;
  437.   WinSetPresParam( hwndClient, PP_BACKGROUNDCOLORINDEX, 4UL, &lBgnColor );
  438.  
  439.   WinSetWindowText( hwndClient, "Frame Extensions Test" );
  440.  
  441.   /**********************************************************************/
  442.   /* Create and associate the help instance.                            */
  443.   /**********************************************************************/
  444.   helpInit.cb                       = sizeof(HELPINIT);
  445.   helpInit.ulReturnCode             = 0;
  446.   helpInit.pszTutorialName          = 0;
  447.   helpInit.phtHelpTable             = (PHELPTABLE)MAKELONG(0, 0xffff);
  448.   helpInit.hmodHelpTableModule      = 0;
  449.   helpInit.hmodAccelActionBarModule = 0;
  450.   helpInit.idAccelTable             = 0;
  451.   helpInit.idActionBar              = 0;
  452.   helpInit.pszHelpWindowTitle       = "Frame Extensions Sample";
  453.   helpInit.fShowPanelId             = CMIC_HIDE_PANEL_ID;
  454.   helpInit.pszHelpLibraryName       = "framectl.hlp";
  455.  
  456.   hwndHelp = WinCreateHelpInstance( hAB, &helpInit );
  457.   if ( !hwndHelp )
  458.     return( TRUE );
  459.  
  460.   if ( !WinAssociateHelpInstance( hwndHelp, hwndFrame ) )
  461.     return( TRUE );
  462.  
  463.   /**********************************************************************/
  464.   /* Use the "new look" help bitmap for OS/2 Warp V4 (aka Merlin) if    */
  465.   /* V4 is detected.                                                    */
  466.   /**********************************************************************/
  467.   ulVersion = WinQueryVersion( hAB );
  468.   if ( ((ulVersion & 0xFF) == 20) &&
  469.        (((ulVersion >> 8) & 0xFF) == 40) )
  470.   {
  471.     bWarpV4 = TRUE;
  472.   }
  473.  
  474.   /**********************************************************************/
  475.   /* Create the help graphic button which we will use as a frame        */
  476.   /* extension on the title bar.                                        */
  477.   /**********************************************************************/
  478.   hwndHelpBtn = WinCreateWindow( hwndFrame,
  479.                                  WC_BUTTON,
  480.                                  ( (bWarpV4) ? "#400" : "#300" ),
  481.                                  (BS_BITMAP | BS_PUSHBUTTON | BS_NOBORDER |
  482.                                   BS_NOPOINTERFOCUS | BS_AUTOSIZE | BS_HELP |
  483.                                   WS_CLIPSIBLINGS | WS_VISIBLE),
  484.                                  0L, 0L, -1L, -1L,
  485.                                  hwndFrame,
  486.                                  HWND_TOP,
  487.                                  HELP_BUTTON_ID,
  488.                                  (PVOID)NULL,
  489.                                  (PVOID)NULL );
  490.   if ( !hwndHelpBtn )
  491.     return( TRUE );
  492.  
  493.   /**********************************************************************/
  494.   /* Create the drop down combo box which we will use as a frame        */
  495.   /* extension on the menu bar.                                         */
  496.   /**********************************************************************/
  497.   hwndComboBox = WinCreateWindow( hwndFrame,
  498.                                  WC_COMBOBOX,
  499.                                  (PSZ)NULL,
  500.                                  (CBS_DROPDOWNLIST |  WS_VISIBLE),
  501.                                  0L, 0L, -1L, -1L,
  502.                                  hwndFrame,
  503.                                  HWND_TOP,
  504.                                  COMBOBOX_ID,
  505.                                  (PVOID)NULL,
  506.                                  (PVOID)NULL );
  507.   if ( !hwndComboBox )
  508.     return( TRUE );
  509.  
  510. #if 0
  511.   lboxinfo.lItemIndex = LIT_END;
  512.   lboxinfo.ulItemCount = 5;
  513.  
  514.   lCount = (LONG)WinSendMsg( hwndComboBox, LM_INSERTMULTITEMS,
  515.                              &lboxinfo, itemsArray[0] );
  516. #endif
  517.  
  518.   /**********************************************************************/
  519.   /* Populate the drop down combo box.                                  */
  520.   /**********************************************************************/
  521.   for (i = 0; i < 5; i++)
  522.   {
  523.     WinSendMsg( hwndComboBox, LM_INSERTITEM, (MPARAM)LIT_END, itemsArray[i] );
  524.   }
  525.  
  526.   WinSendMsg( hwndComboBox, LM_SELECTITEM, 0L, (MPARAM)TRUE );
  527.  
  528.   /**********************************************************************/
  529.   /* Subclass the frame control.  The subclass procedure is where we    */
  530.   /* will add the frame extensions during processing of WM_FORMATFRAME. */
  531.   /**********************************************************************/
  532.   DefFrameWndProc = WinSubclassWindow( hwndFrame, (PFNWP)FrameWndProc );
  533.  
  534.   if ( !DefFrameWndProc )
  535.     return( TRUE );
  536.  
  537.   /**********************************************************************/
  538.   /* Indicate to PM that the frame needs updating.                      */
  539.   /**********************************************************************/
  540.   WinSendMsg( hwndFrame, WM_UPDATEFRAME, (MPARAM)~0, NULL );
  541.  
  542.   /**********************************************************************/
  543.   /* Position (center on the desktop), size, and show the frame window. */
  544.   /**********************************************************************/
  545.   lWidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
  546.   lHeight = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
  547.   WinSetWindowPos( hwndFrame,
  548.                    HWND_TOP,
  549.                    (lWidth - FRAME_WIDTH)/ 2,
  550.                    (lHeight - FRAME_HEIGHT)/ 2,
  551.                    FRAME_WIDTH,
  552.                    FRAME_HEIGHT,
  553.                    SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ACTIVATE );
  554.  
  555.   /**********************************************************************/
  556.   /* Message dispatch loop.                                             */
  557.   /**********************************************************************/
  558.   while ( WinGetMsg( hAB, &qmsg, (HWND)NULL, 0, 0 ) )
  559.     WinDispatchMsg( hAB, &qmsg );
  560.  
  561.   /**********************************************************************/
  562.   /* Termination processing                                             */
  563.   /**********************************************************************/
  564.   WinDestroyHelpInstance( hwndHelp );
  565.   WinDestroyWindow( hwndFrame );
  566.   WinDestroyMsgQueue( hMQ );
  567.   WinTerminate( hAB );
  568.   return( FALSE );
  569. }
  570.  
  571.