home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / wps / browse / pmbrowse.c < prev    next >
C/C++ Source or Header  |  1999-05-11  |  30KB  |  713 lines

  1. /*
  2.  *
  3.  *
  4.  *   Module Name: PMBROWSE
  5.  *
  6.  *   OS/2 Work Place Shell Sample Program
  7.  *
  8.  *   Copyright (C) 1993 IBM Corporation
  9.  *
  10.  *       DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  11.  *       sample code created by IBM Corporation. This sample code is not
  12.  *       part of any standard or IBM product and is provided to you solely
  13.  *       for  the purpose of assisting you in the development of your
  14.  *       applications.  The code is provided "AS IS", without
  15.  *       warranty of any kind.  IBM shall not be liable for any damages
  16.  *       arising out of your use of the sample code, even if they have been
  17.  *       advised of the possibility of such damages.
  18.  *
  19.  */
  20. #define  INCL_WIN
  21. #define  INCL_DOS
  22. #define  INCL_DOSNMPIPES
  23. #define  INCL_DOSERRORS
  24. #define  INCL_GPILCIDS
  25. #define  INCL_GPIPRIMITIVES
  26. #include <os2.h>
  27.  
  28. #include <stdlib.h>
  29. #include <stdio.h>
  30. #include <string.h>
  31.  
  32. #include "browse.ih"
  33. #include "pmbrowse.h"
  34.  
  35. /*********************/
  36. /* Defined Constants */
  37. /*********************/
  38. #define  MAX_TITLE_LENGTH     128
  39.  
  40. /***********************/
  41. /* Function Prototypes */
  42. /***********************/
  43. static VOID SetSysMenu( HWND hDlg);
  44.  
  45. /*
  46.  *
  47.  *  BrowseWndProc
  48.  *
  49.  *  DESCRIPTION:
  50.  *
  51.  *    Processes messages for the Browse-O-Matic client window.
  52.  *
  53.  */
  54. MRESULT EXPENTRY BrowseWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  55. {
  56.    switch( msg){
  57.  
  58.       case WM_CREATE:
  59.          {
  60.             CHAR          pszTitle[ MAX_TITLE_LENGTH];
  61.             PBROWSEDATA   pWindowData;
  62.  
  63.             pWindowData = (PBROWSEDATA)mp1;
  64.             WinSetWindowPtr( hwnd, QWL_USER, pWindowData);
  65.  
  66.             /*******************/
  67.             /* Load the object */
  68.             /*******************/
  69.             _LoadObject( pWindowData->somSelf,
  70.                         pWindowData->pszObjectName, &pWindowData->ulFileLength,
  71.                                    &pWindowData->pBuffer, &pWindowData->pLines,
  72.                                              &pWindowData->usNumberOfTextLines,
  73.                                           &pWindowData->usNumberOfTextColumns);
  74.  
  75.             _GetLinesAndColumns( pWindowData->somSelf, pWindowData->bDisplay,
  76.                         &pWindowData->sTotalLines, &pWindowData->sTotalColumns,
  77.                                              pWindowData->usNumberOfTextLines,
  78.                                             pWindowData->usNumberOfTextColumns,
  79.                                                     pWindowData->ulFileLength);
  80.  
  81.             /*********************************************/
  82.             /* Get the window handle for the scroll bars */
  83.             /*********************************************/
  84.             pWindowData->hwndVscroll = WinWindowFromID( WinQueryWindow( hwnd,
  85.                                                    QW_PARENT), FID_VERTSCROLL);
  86.             pWindowData->hwndHscroll = WinWindowFromID( WinQueryWindow( hwnd,
  87.                                                    QW_PARENT), FID_HORZSCROLL);
  88.  
  89.             /*************************/
  90.             /* Save font information */
  91.             /*************************/
  92.             WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0);
  93.  
  94.             /*****************/
  95.             /* Get the focus */
  96.             /*****************/
  97.             WinSetFocus( HWND_DESKTOP, hwnd);
  98.  
  99.             /*****************************************************/
  100.             /* Create the title for the Browse-O-Matic title bar */
  101.             /*****************************************************/
  102.             if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE)
  103.                sprintf( pszTitle, "Object: %s    (%d Bytes)",
  104.                         pWindowData->pszObjectName, pWindowData->ulFileLength);
  105.             else
  106.                sprintf( pszTitle, "Object: %s    (%hd Lines)",
  107.                          pWindowData->pszObjectName, pWindowData->sTotalLines);
  108.  
  109.             /************************************************/
  110.             /* Register the current open view of the object */
  111.             /************************************************/
  112.             _wpAddToObjUseList( pWindowData->somSelf, &(pWindowData->UseItem));
  113.             _wpRegisterView( pWindowData->somSelf, WinQueryWindow( hwnd,
  114.                                                          QW_PARENT), pszTitle);
  115.          }
  116.          break;
  117.  
  118.       case WM_CLOSE:
  119.          {
  120.             HWND        hwndFrame;
  121.             PBROWSEDATA pWindowData;
  122.  
  123.             pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);
  124.             hwndFrame = WinQueryWindow( hwnd, QW_PARENT);
  125.  
  126.             /*****************************************************/
  127.             /* Save the window info - size, location, and fonts. */
  128.             /*****************************************************/
  129.             WinStoreWindowPos( APPL_NAME, pWindowData->pszApplKey, hwndFrame);
  130.  
  131.             /**********************************************************/
  132.             /* Free the window data and unload the file system object */
  133.             /**********************************************************/
  134.             if( pWindowData){
  135.                if( pWindowData->pszObjectName)
  136.                   _wpFreeMem( pWindowData->somSelf,
  137.                                            ( PBYTE)pWindowData->pszObjectName);
  138.                _wpFreeMem( pWindowData->somSelf, ( PBYTE)pWindowData);
  139.             }
  140.  
  141.             _UnloadObject( pWindowData->somSelf, pWindowData->pBuffer,
  142.                                                           pWindowData->pLines);
  143.  
  144.             _wpDeleteFromObjUseList( pWindowData->somSelf,
  145.                                                         &pWindowData->UseItem);
  146.             /*******************/
  147.             /* Kill the window */
  148.             /*******************/
  149.             WinPostMsg( hwnd, WM_QUIT, 0, 0 );
  150.             WinDestroyWindow( hwndFrame);
  151.          }
  152.          break;
  153.  
  154.       /*******************************************************************/
  155.       /* The font characteristics have changed. This happens when a font */
  156.       /* from the font palette is dropped on the client window.          */
  157.       /*******************************************************************/
  158.       case WM_PRESPARAMCHANGED:
  159.          {
  160.             PBROWSEDATA pWindowData;
  161.  
  162.             pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);
  163.  
  164.             if( (ULONG)mp1 == PP_FONTNAMESIZE){
  165.  
  166.                /***********************************************/
  167.                /* Get the new font information and redraw the */
  168.                /* window with the new font/font size.         */
  169.                /***********************************************/
  170.                WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0);
  171.                WinSendMsg( hwnd, WM_SIZE, 0, MPFROM2SHORT(
  172.                        pWindowData->sClientWidth, pWindowData->sClientHeight));
  173.             }
  174.          }
  175.          break;
  176.  
  177.       case WM_SIZE:
  178.          {
  179.             PBROWSEDATA pWindowData;
  180.  
  181.             pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);
  182.  
  183.             /***************************************/
  184.             /* Save client window size information */
  185.             /***************************************/
  186.             pWindowData->sClientWidth = SHORT1FROMMP( mp2);
  187.             pWindowData->sClientHeight = SHORT2FROMMP( mp2);
  188.             pWindowData->sPageHeight = pWindowData->sClientHeight/
  189.                                                       pWindowData->sCharHeight;
  190.             pWindowData->sPageWidth = pWindowData->sClientWidth  /
  191.                                                        pWindowData->sCharWidth;
  192.  
  193.             /**************************************/
  194.             /* Set the ranges for the scroll bars */
  195.             /**************************************/
  196.             WinPostMsg( pWindowData->hwndVscroll, SBM_SETSCROLLBAR,
  197.                          (MPARAM)pWindowData->sCurrentLine, MPFROM2SHORT( 0,
  198.                          pWindowData->sTotalLines - pWindowData->sPageHeight));
  199.             WinPostMsg( pWindowData->hwndHscroll, SBM_SETSCROLLBAR,
  200.                         (MPARAM)pWindowData->sCurrentColumn, MPFROM2SHORT( 0,
  201.                         pWindowData->sTotalColumns - pWindowData->sPageWidth));
  202.  
  203.             /*************************************/
  204.             /* Set scroll bar thumb control size */
  205.             /*************************************/
  206.             WinPostMsg( pWindowData->hwndVscroll, SBM_SETTHUMBSIZE,
  207.                                         MPFROM2SHORT( pWindowData->sPageHeight,
  208.                                         pWindowData->sTotalLines), (MPARAM) 0);
  209.             WinPostMsg( pWindowData->hwndHscroll, SBM_SETTHUMBSIZE,
  210.                                       MPFROM2SHORT( pWindowData->sPageWidth,
  211.                                       pWindowData->sTotalColumns), (MPARAM) 0);
  212.  
  213.             /************************************************************/
  214.             /* If the all the lines and/or columns can fit in the new   */
  215.             /* sized window, set the sCurrentLine and/or sCurrentColumn */
  216.             /* to the top/right side.                                   */
  217.             /************************************************************/
  218.             if( pWindowData->sPageHeight >= pWindowData->sTotalLines)
  219.                pWindowData->sCurrentLine = 0;
  220.  
  221.             if( pWindowData->sPageWidth >= pWindowData->sTotalColumns)
  222.                pWindowData->sCurrentColumn = 0;
  223.  
  224.             /********************************************/
  225.             /* Repaint window with new size information */
  226.             /********************************************/
  227.             WinInvalidateRect( hwnd, NULL, FALSE);
  228.          }
  229.          return( 0);
  230.  
  231.       case WM_PAINT:
  232.          {
  233.             HPS         hps;
  234.             CHAR        pszText[255];
  235.             UINT        nLength = 0;
  236.             RECTL       rect;
  237.             POINTL      point;
  238.             SHORT       sLine;
  239.             SHORT       sTopLine;
  240.             SHORT       sBottomLine;
  241.             SHORT       sLinesFromTop;
  242.             PBROWSEDATA pWindowData;
  243.  
  244.             pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);
  245.  
  246.             hps = WinBeginPaint( hwnd, NULLHANDLE, &rect);
  247.  
  248.             /*******************************************/
  249.             /* Clear the area that needs to be redrawn */
  250.             /*******************************************/
  251.             GpiErase( hps);
  252.  
  253.             /********************************/
  254.             /* Determine first clipped line */
  255.             /********************************/
  256.             sLinesFromTop = ( pWindowData->sClientHeight - rect.yTop) /
  257.                                                       pWindowData->sCharHeight;
  258.             rect.yTop = pWindowData->sClientHeight -
  259.                                    ( pWindowData->sCharHeight * sLinesFromTop);
  260.  
  261.             /***************************************************************/
  262.             /* Determine the first position to write at. NOTE: PM handles  */
  263.             /* clipping for point.x < 0. Any characters written before the */
  264.             /* the first column or after the last column are clipped.      */
  265.             /***************************************************************/
  266.             point.y = rect.yTop - pWindowData->sCharHeight +
  267.                                                    pWindowData->sCharDescender;
  268.             point.x = pWindowData->sCurrentColumn*pWindowData->sCharWidth * -1;
  269.  
  270.             /***********************************************/
  271.             /* Determine the top and bottom lines to write */
  272.             /***********************************************/
  273.             sTopLine    = rect.yTop    / pWindowData->sCharHeight;
  274.             sBottomLine = rect.yBottom / pWindowData->sCharHeight;
  275.  
  276.             /*********************************************************/
  277.             /* Make sure that we aren't trying to display more lines */
  278.             /* then are available.                                   */
  279.             /*********************************************************/
  280.             if( pWindowData->sPageHeight - sBottomLine + 1 >
  281.                           pWindowData->sTotalLines - pWindowData->sCurrentLine)
  282.                sBottomLine=pWindowData->sPageHeight-(pWindowData->sTotalLines -
  283.                                                 pWindowData->sCurrentLine) + 1;
  284.  
  285.             /********************************/
  286.             /* Redraw the invalid rectangle */
  287.             /********************************/
  288.             for( sLine = sTopLine; sLine >= sBottomLine; sLine--){
  289.  
  290.                /*******************************************/
  291.                /* Get the line of text or hex information */
  292.                /* that we are going to write.             */
  293.                /*******************************************/
  294.                if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE)
  295.                   nLength = _GetHexLine( pWindowData->somSelf,
  296.                      pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine
  297.                            +1, pWindowData->pBuffer, pWindowData->ulFileLength,
  298.                                                                       pszText);
  299.                else
  300.                   nLength = _GetTextLine( pWindowData->somSelf,
  301.                        pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine
  302.                                              +1, pWindowData->pLines, pszText);
  303.  
  304.                /******************/
  305.                /* Write the text */
  306.                /******************/
  307.                if( nLength != 0)
  308.                   GpiCharStringAt( hps, &point, nLength, pszText);
  309.  
  310.                point.y -= pWindowData->sCharHeight;
  311.             }
  312.  
  313.             WinEndPaint( hps);
  314.          }
  315.          return( 0);
  316.  
  317.       /*******************************************/
  318.       /* Keyboard support for scrolling and help */
  319.       /*******************************************/
  320.       case WM_CHAR:
  321.  
  322.          /****************************************/
  323.          /* Show general help if user selects F1 */
  324.          /****************************************/
  325.          if( CHARMSG( &msg)->vkey == VK_F1){
  326.             PBROWSEDATA pWindowData;
  327.  
  328.             pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);
  329.             _wpDisplayHelp( pWindowData->somSelf, PANEL_MAIN,
  330.                             "browse.hlp");
  331.             return 0;
  332.          }
  333.  
  334.          if( (CHARMSG( &msg)->fs & KC_KEYUP))
  335.             return 0;
  336.  
  337.          switch( CHARMSG( &msg)->vkey){
  338.  
  339.             case VK_UP:
  340.                WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEUP));
  341.                return 0;
  342.  
  343.             case VK_DOWN:
  344.                WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEDOWN));
  345.                return 0;
  346.  
  347.             case VK_RIGHT:
  348.                /************************************************************/
  349.                /* Ctrl-Right scrolls one page to the right. Right scrolls  */
  350.                /* to the right.                                            */
  351.                /************************************************************/
  352.                if( (CHARMSG( &msg)->fs & KC_CTRL))
  353.                   WinPostMsg( hwnd, WM_HSCROLL, 0,
  354.                                                 MPFROM2SHORT(0, SB_PAGERIGHT));
  355.                else
  356.                   WinPostMsg( hwnd, WM_HSCROLL, 0,
  357.                                                 MPFROM2SHORT(0, SB_LINERIGHT));
  358.                return 0;
  359.  
  360.             case VK_LEFT:
  361.                /*********************************************************/
  362.                /* Ctrl-Left scrolls one page to the left. Left scrolls  */
  363.                /* to the Left.                                          */
  364.                /*********************************************************/
  365.                if( (CHARMSG( &msg)->fs & KC_CTRL))
  366.                   WinPostMsg( hwnd, WM_HSCROLL, 0,
  367.                                                 MPFROM2SHORT( 0, SB_PAGELEFT));
  368.                else
  369.                   WinPostMsg( hwnd, WM_HSCROLL, 0,
  370.                                                 MPFROM2SHORT( 0, SB_LINELEFT));
  371.                return 0;
  372.  
  373.             case VK_PAGEUP:
  374.                WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEUP));
  375.                return 0;
  376.  
  377.             case VK_PAGEDOWN:
  378.                WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEDOWN));
  379.                return 0;
  380.  
  381.             case VK_HOME:
  382.                {
  383.                   PBROWSEDATA pWindowData;
  384.  
  385.                   pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);
  386.  
  387.                   /*********************************************************/
  388.                   /* Ctrl-Home positions at the first line, Home positions */
  389.                   /* at the beginning of the current line.                 */
  390.                   /*********************************************************/
  391.                   if( (CHARMSG( &msg)->fs & KC_CTRL)){
  392.                      WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0,
  393.                                           MPFROM2SHORT( 0, SB_SLIDERPOSITION));
  394.                      WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
  395.                                                            MPFROMSHORT( 0), 0);
  396.                   }
  397.                   else{
  398.                      WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0,
  399.                                           MPFROM2SHORT( 0, SB_SLIDERPOSITION));
  400.                      WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
  401.                                                            MPFROMSHORT( 0), 0);
  402.                   }
  403.                   return 0;
  404.                }
  405.  
  406.             case VK_END:
  407.                {
  408.                   PBROWSEDATA pWindowData;
  409.  
  410.                   pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);
  411.  
  412.                   /*********************************************************/
  413.                   /* Ctrl-End positions at the last line, End positions at */
  414.                   /* the end of the current line.                          */
  415.                   /*********************************************************/
  416.                   if( (CHARMSG( &msg)->fs & KC_CTRL)){
  417.                      WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0, MPFROM2SHORT(
  418.                            pWindowData->sTotalLines - pWindowData->sPageHeight,
  419.                                                            SB_SLIDERPOSITION));
  420.                      WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
  421.                       MPFROMSHORT( pWindowData->sTotalLines -
  422.                                                  pWindowData->sPageHeight), 0);
  423.                   }
  424.                   else{
  425.                      WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0, MPFROM2SHORT(
  426.                           pWindowData->sTotalColumns - pWindowData->sPageWidth,
  427.                                                            SB_SLIDERPOSITION));
  428.                      WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
  429.                                       MPFROMSHORT( pWindowData->sTotalColumns -
  430.                                                   pWindowData->sPageWidth), 0);
  431.                   }
  432.                   return 0;
  433.                }
  434.          }
  435.          break;
  436.  
  437.       /******************/
  438.       /* Scroll Up/Down */
  439.       /******************/
  440.       case WM_VSCROLL:
  441.          {
  442.             PBROWSEDATA pWindowData;
  443.  
  444.             pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);
  445.  
  446.             switch( SHORT2FROMMP( mp2)){
  447.  
  448.                case SB_LINEUP:
  449.                   if( pWindowData->sCurrentLine > 0){
  450.                      pWindowData->sCurrentLine--;
  451.  
  452.                      WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
  453.                                          (MPARAM)pWindowData->sCurrentLine, 0);
  454.  
  455.                      WinScrollWindow( hwnd, 0, pWindowData->sCharHeight * -1,
  456.                                NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
  457.                   }
  458.                   return( 0);
  459.  
  460.                case SB_LINEDOWN:
  461.                   if( pWindowData->sCurrentLine < pWindowData->sTotalLines -
  462.                                                      pWindowData->sPageHeight){
  463.                      pWindowData->sCurrentLine++;
  464.  
  465.                      WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
  466.                                          (MPARAM)pWindowData->sCurrentLine, 0);
  467.  
  468.                      WinScrollWindow( hwnd, 0, pWindowData->sCharHeight, NULL,
  469.                                      NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
  470.                   }
  471.                   return( 0);
  472.  
  473.                case SB_PAGEUP:
  474.                   if( pWindowData->sCurrentLine > 0){
  475.                      pWindowData->sCurrentLine = max( 0,
  476.                          pWindowData->sCurrentLine - pWindowData->sPageHeight);
  477.                      WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
  478.                                           (MPARAM)pWindowData->sCurrentLine,0);
  479.                      WinInvalidateRect( hwnd, NULL, FALSE);
  480.                   }
  481.                   return( 0);
  482.  
  483.                case SB_PAGEDOWN:
  484.                   if( pWindowData->sCurrentLine < pWindowData->sTotalLines -
  485.                                                      pWindowData->sPageHeight){
  486.                      pWindowData->sCurrentLine= min( pWindowData->sTotalLines -
  487.                           pWindowData->sPageHeight, pWindowData->sCurrentLine +
  488.                                                      pWindowData->sPageHeight);
  489.                      WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
  490.                                           (MPARAM)pWindowData->sCurrentLine,0);
  491.                      WinInvalidateRect( hwnd, NULL, FALSE);
  492.                   }
  493.                   return( 0);
  494.  
  495.                case SB_SLIDERPOSITION:
  496.                   /***********************************************************/
  497.                   /* Can't change current line if all the text fits in the   */
  498.                   /* window.                                                 */
  499.                   /***********************************************************/
  500.                   if( pWindowData->sTotalLines > pWindowData->sPageHeight){
  501.                      pWindowData->sCurrentLine = SHORT1FROMMP( mp2);
  502.                      WinInvalidateRect( hwnd, NULL, FALSE);
  503.                   }
  504.                   return( 0);
  505.             }
  506.          }
  507.          break;
  508.  
  509.  
  510.       /*********************/
  511.       /* Scroll Right/Left */
  512.       /*********************/
  513.       case WM_HSCROLL:
  514.          {
  515.             PBROWSEDATA pWindowData;
  516.  
  517.             pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER);
  518.  
  519.             switch( SHORT2FROMMP( mp2)){
  520.  
  521.                case SB_LINELEFT:
  522.                   if( pWindowData->sCurrentColumn > 0){
  523.                      pWindowData->sCurrentColumn = max( 0,
  524.                                               pWindowData->sCurrentColumn - 1);
  525.                      WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
  526.                                         (MPARAM)pWindowData->sCurrentColumn,0);
  527.                      WinScrollWindow( hwnd, pWindowData->sCharWidth, 0, NULL,
  528.                                      NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
  529.                   }
  530.                   return( 0);
  531.  
  532.                case SB_LINERIGHT:
  533.                   if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns -
  534.                                                       pWindowData->sPageWidth){
  535.                      pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns,
  536.                                               pWindowData->sCurrentColumn + 1);
  537.                      WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
  538.                                        (MPARAM)pWindowData->sCurrentColumn, 0);
  539.                      WinScrollWindow( hwnd, pWindowData->sCharWidth * -1, 0,
  540.                                NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
  541.                   }
  542.                   return( 0);
  543.  
  544.                case SB_PAGELEFT:
  545.                   if( pWindowData->sCurrentColumn > 0){
  546.                      pWindowData->sCurrentColumn = max( 0,
  547.                         pWindowData->sCurrentColumn - pWindowData->sPageWidth);
  548.                      WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
  549.                                        (MPARAM)pWindowData->sCurrentColumn, 0);
  550.                      WinInvalidateRect( hwnd, NULL, FALSE);
  551.                   }
  552.                   return( 0);
  553.  
  554.                case SB_PAGERIGHT:
  555.                   if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns -
  556.                                                       pWindowData->sPageWidth){
  557.                      pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns
  558.                        - pWindowData->sPageWidth, pWindowData->sCurrentColumn +
  559.                                                       pWindowData->sPageWidth);
  560.                      WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
  561.                                        (MPARAM)pWindowData->sCurrentColumn, 0);
  562.                      WinInvalidateRect( hwnd, NULL, FALSE);
  563.                   }
  564.                   return( 0);
  565.  
  566.                case SB_SLIDERPOSITION:
  567.                   /***********************************************************/
  568.                   /* Can't change current column if all the text fits in the */
  569.                   /* window.                                                 */
  570.                   /***********************************************************/
  571.                   if( pWindowData->sTotalColumns > pWindowData->sPageWidth){
  572.                      pWindowData->sCurrentColumn = SHORT1FROMMP( mp2);
  573.                      WinInvalidateRect( hwnd, NULL, FALSE);
  574.                   }
  575.                   return( 0);
  576.             }
  577.          }
  578.          break;
  579.  
  580.       /*****************************/
  581.       /* Get font size information */
  582.       /*****************************/
  583.       case IDL_SETFONTINFO:
  584.          {
  585.             HPS         hps;
  586.             FONTMETRICS fm;
  587.             PBROWSEDATA pWindowData;
  588.  
  589.             pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER);
  590.  
  591.             hps = WinGetPS( hwnd);
  592.             GpiQueryFontMetrics( hps, sizeof( fm), &fm);
  593.             WinReleasePS( hps);
  594.  
  595.             /***********************************************************/
  596.             /* The character width is average of the average uppercase */
  597.             /* and average lower case widths.                          */
  598.             /***********************************************************/
  599.             pWindowData->sCharWidth     = (SHORT)fm.lMaxCharInc;
  600.             pWindowData->sCharHeight    = (SHORT)fm.lMaxBaselineExt;
  601.             pWindowData->sCharDescender = (SHORT)fm.lMaxDescender;
  602.          }
  603.          return( 0);
  604.  
  605.       /*********************************************/
  606.       /* Display no help available message to user */
  607.       /*********************************************/
  608.       case HM_HELPSUBITEM_NOT_FOUND:
  609.          return( ( MRESULT)FALSE);
  610.  
  611.       /**************************************/
  612.       /* Return name of help for keys panel */
  613.       /**************************************/
  614.       case HM_QUERY_KEYS_HELP:
  615.          return( ( MRESULT)PANEL_HELPKEYS);
  616.    }
  617.  
  618.    /********************************************************/
  619.    /* Let the default window procedure process the message */
  620.    /********************************************************/
  621.    return( WinDefWindowProc( hwnd, msg, mp1, mp2));
  622. }
  623.  
  624. /*
  625.  *
  626.  *  OpenFilterProc
  627.  *
  628.  *  DESCRIPTION:
  629.  *
  630.  *    Processes messages for the open file dialog box
  631.  *
  632.  */
  633. MRESULT EXPENTRY
  634. OpenFilterProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  635. {
  636.    return( WinDefFileDlgProc( hwnd, msg, mp1, mp2));
  637. }
  638.  
  639. /*
  640.  *
  641.  *  AboutBoxDlgProc
  642.  *
  643.  *  DESCRIPTION:
  644.  *
  645.  *    Processes messages for the product information dialog box
  646.  *
  647.  */
  648. MRESULT EXPENTRY
  649. AboutBoxDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  650. {
  651.    switch(msg)
  652.    {
  653.       case WM_INITDLG:
  654.          SetSysMenu(hwnd);       /* system menu for this dialog  */
  655.          return MRFROMSHORT(FALSE);
  656.  
  657.       case WM_COMMAND:
  658.            /* no matter what the command, close the dialog */
  659.          WinDismissDlg(hwnd, TRUE);
  660.          break;
  661.  
  662.       default:
  663.          return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  664.    }
  665.  
  666.    return (MRESULT)NULL;
  667. }
  668.  
  669. /*
  670.  *
  671.  *  SetSysMenu
  672.  *
  673.  *  DESCRIPTION:
  674.  *
  675.  *    Set dialog box so only move and close are active.
  676.  *
  677.  */
  678. static VOID
  679. SetSysMenu( HWND hDlg)
  680. {
  681.     HWND     hSysMenu;
  682.     MENUITEM Mi;
  683.     ULONG    Pos;
  684.     MRESULT  Id;
  685.     SHORT    cItems;
  686.  
  687.     /******************************************************************/
  688.     /*  We only want Move and Close in the system menu.               */
  689.     /******************************************************************/
  690.     hSysMenu = WinWindowFromID(hDlg, FID_SYSMENU);
  691.     WinSendMsg( hSysMenu, MM_QUERYITEM
  692.               , MPFROM2SHORT(SC_SYSMENU, FALSE), MPFROMP((PCH) & Mi));
  693.     Pos = 0L;
  694.     cItems = (SHORT)WinSendMsg( Mi.hwndSubMenu, MM_QUERYITEMCOUNT,
  695.                                 (MPARAM)NULL, (MPARAM)NULL);
  696.     while( cItems--){
  697.  
  698.         Id = WinSendMsg( Mi.hwndSubMenu, MM_ITEMIDFROMPOSITION
  699.                           , MPFROMLONG(Pos), (MPARAM)NULL);
  700.         switch (SHORT1FROMMR(Id))
  701.         {
  702.         case SC_MOVE:
  703.         case SC_CLOSE:
  704.             Pos++;  /* Don't delete that one. */
  705.             break;
  706.         default:
  707.             WinSendMsg( Mi.hwndSubMenu, MM_DELETEITEM
  708.                       , MPFROM2SHORT((USHORT)Id, TRUE), (MPARAM)NULL);
  709.         }
  710.     }
  711. }
  712.  
  713.