home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FILEDLG6.ZIP / SOURCE.ZIP / BUTTONS.C next >
C/C++ Source or Header  |  1990-10-12  |  4KB  |  107 lines

  1. /****************************************************************************
  2.  * BUTTONS.C                                                                *
  3.  *                                                                          *
  4.  *  This file contains the functions used to draw the right arrow           *
  5.  *  and left arrow buttons.                                                 *
  6.  *                                                                          *
  7.  *  Modifications -                                                         *
  8.  *      11-Oct-1990 : Initial version.                                      *
  9.  ****************************************************************************/
  10.  
  11. #define INCL_WINBUTTONS
  12. #define INCL_WINMESSAGEMGR
  13. #define INCL_GPIPRIMITIVES
  14. #define INCL_GPIBITMAPS
  15. #define INCL_WINDIALOGS
  16. #include <os2.h>
  17. #define INCL_ARROWS
  18. #include "tools.h"
  19.  
  20. /****************************************************************************
  21.  * LeftArrow() - Procedure to handle BN_PAINT messages generated by the     *
  22.  *               left arrow button control.                                 *
  23.  ****************************************************************************/
  24. MRESULT LeftArrow( HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2,
  25.                    HBITMAP hbmLeft,HBITMAP hbmLeftPressed,
  26.                    HBITMAP hbmLeftDisabled )
  27.  
  28.     {
  29.         PUSERBUTTON         pUserButton;
  30.         HBITMAP             hbm;
  31.         POINTL              ptl;
  32.         BITMAPINFOHEADER    bmp;
  33.         LONG                clr;
  34.  
  35.         if ( SHORT2FROMMP(mp1) == BN_PAINT )
  36.             {
  37.             pUserButton = (PUSERBUTTON)PVOIDFROMMP(mp2);
  38.  
  39.             if ( pUserButton->fsState & BDS_DISABLED )
  40.                 hbm = hbmLeftDisabled;
  41.             else if ( pUserButton->fsState & BDS_HILITED )
  42.                 hbm = hbmLeftPressed;
  43.             else
  44.                 hbm = hbmLeft;
  45.  
  46.             clr = (pUserButton->fsState & BDS_DEFAULT) ? CLR_BLACK : CLR_DARKGRAY;
  47.  
  48.             ptl.x = 0L; ptl.y = 0L;
  49.             WinDrawBitmap( pUserButton->hps,hbm,NULL,&ptl,
  50.                            clr,CLR_WHITE,DBM_NORMAL );
  51.             GpiQueryBitmapParameters( hbm,&bmp );
  52.             GpiMove( pUserButton->hps,&ptl );
  53.             ptl.x = bmp.cx; ptl.y = bmp.cy;
  54.             GpiSetColor( pUserButton->hps,clr );
  55.             GpiBox( pUserButton->hps,DRO_OUTLINE,&ptl,0L,0L );
  56.             return 0L;
  57.             }
  58.  
  59.         else
  60.             return WinDefDlgProc( hwnd,msg,mp1,mp2 );
  61.     }
  62. /****************************************************************************/
  63.  
  64.  
  65. /****************************************************************************
  66.  * RightArrow() - Procedure to handle BN_PAINT messages generated by the    *
  67.  *                right arrow button control.                               *
  68.  ****************************************************************************/
  69. MRESULT RightArrow( HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2,
  70.                     HBITMAP hbmRight,HBITMAP hbmRightPressed,
  71.                     HBITMAP hbmRightDisabled )
  72.     {
  73.         PUSERBUTTON         pUserButton;
  74.         HBITMAP             hbm;
  75.         POINTL              ptl;
  76.         BITMAPINFOHEADER    bmp;
  77.         LONG                clr;
  78.  
  79.         if ( SHORT2FROMMP(mp1) == BN_PAINT )
  80.             {
  81.             pUserButton = (PUSERBUTTON)PVOIDFROMMP(mp2);
  82.  
  83.             if ( pUserButton->fsState & BDS_DISABLED )
  84.                 hbm = hbmRightDisabled;
  85.             else if ( pUserButton->fsState & BDS_HILITED )
  86.                 hbm = hbmRightPressed;
  87.             else
  88.                 hbm = hbmRight;
  89.  
  90.             clr = (pUserButton->fsState & BDS_DEFAULT) ? CLR_BLACK : CLR_DARKGRAY;
  91.  
  92.             ptl.x = 0L; ptl.y = 0L;
  93.             WinDrawBitmap( pUserButton->hps,hbm,NULL,&ptl,
  94.                            CLR_BLACK,CLR_WHITE,DBM_NORMAL );
  95.             GpiQueryBitmapParameters( hbm,&bmp );
  96.             GpiMove( pUserButton->hps,&ptl );
  97.             ptl.x = bmp.cx; ptl.y = bmp.cy;
  98.             GpiSetColor( pUserButton->hps,clr );
  99.             GpiBox( pUserButton->hps,DRO_OUTLINE,&ptl,0L,0L );
  100.             return 0L;
  101.             }
  102.  
  103.         else
  104.             return WinDefDlgProc( hwnd,msg,mp1,mp2 );
  105.     }
  106. /****************************************************************************/
  107.