home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sftick.zip / adv / titlebar / good / WIN1.C < prev    next >
Text File  |  1994-04-21  |  4KB  |  141 lines

  1. #define INCL_WIN
  2. #define INCL_GPI
  3. #include <os2.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. #define CLS_CLIENT               "WindowClass"
  9.  
  10. MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd,
  11.                                  ULONG ulMsg,
  12.                                  MPARAM mpParm1,
  13.                                  MPARAM mpParm2 ) ;
  14.  
  15. INT main ( VOID )
  16. {
  17.    HAB         habAnchor ;
  18.    HMQ         hmqQueue ;
  19.    ULONG       ulFlags ;
  20.    HWND        hwndFrame ;
  21.    HWND        hwndClient ;
  22.    QMSG        qmMsg ;
  23.  
  24.    /* basic PM stuff */
  25.    habAnchor = WinInitialize ( 0 ) ;
  26.    hmqQueue = WinCreateMsgQueue ( habAnchor, 0 ) ;
  27.  
  28.    WinRegisterClass ( habAnchor,
  29.                       CLS_CLIENT,
  30.                       ClientWndProc,
  31.                       0,
  32.                       0 ) ;
  33.  
  34.    ulFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
  35.              FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST ;
  36.  
  37.    hwndFrame = WinCreateStdWindow ( HWND_DESKTOP,
  38.                                     WS_VISIBLE,
  39.                                     &ulFlags,
  40.                                     CLS_CLIENT,
  41.                                     "Titlebar",
  42.                                     0,
  43.                                     NULLHANDLE,
  44.                                     0,
  45.                                     &hwndClient ) ;
  46.  
  47.  
  48.    if ( hwndFrame ) {
  49.       while( WinGetMsg ( habAnchor,
  50.                          &qmMsg,
  51.                          NULLHANDLE,
  52.                          0,
  53.                          0 ))
  54.          WinDispatchMsg ( habAnchor, &qmMsg ) ;
  55.  
  56.       WinDestroyWindow ( hwndFrame ) ;
  57.    } /* endif */
  58.  
  59.    WinDestroyMsgQueue ( hmqQueue ) ;
  60.    WinTerminate ( habAnchor ) ;
  61.    return 0 ;
  62. }
  63.  
  64. MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd,
  65.                                  ULONG ulMsg,
  66.                                  MPARAM mpParm1,
  67.                                  MPARAM mpParm2 )
  68. {
  69.    HPS   hpsPaint ;
  70.    RECTL rclPaint ;
  71.    /* BINGO - for OS/2 2.x, use RGB2 structure instead of RGB */
  72.    RGB2  rgbColor ;
  73.    BOOL  bSuccess ;
  74.    HWND  hwndTitle ;
  75.    HWND  hwndFrame ;
  76.  
  77.    switch ( ulMsg ) {
  78.  
  79.    /* titlebar is not valid until after WM_CREATE is done  */
  80.    case WM_CREATE:
  81.       WinPostMsg( hwndWnd, WM_USER+1, MPVOID, MPVOID ) ;
  82.       break;
  83.  
  84.    case WM_USER+1:
  85.  
  86.       rgbColor.bBlue  = 200 ;
  87.       rgbColor.bGreen = 10 ;
  88.       rgbColor.bRed   = 5 ;
  89.  
  90.  
  91.       /* get the frame window handle */
  92.       hwndFrame = WinQueryWindow( hwndWnd, QW_PARENT ) ;
  93.  
  94.       /* get the titlebar window handle */
  95.       hwndTitle = WinWindowFromID( hwndFrame, FID_TITLEBAR ) ;
  96.  
  97.       /* change the color of the titlebar when active */
  98.       bSuccess = WinSetPresParam( hwndTitle,
  99.                                   PP_ACTIVECOLOR,
  100.                                   sizeof ( RGB2 ),
  101.                                   (PVOID)&rgbColor ) ;
  102.       rgbColor.bBlue  = 200 ;
  103.       rgbColor.bGreen = 10 ;
  104.       rgbColor.bRed   = 5 ;
  105.  
  106.       /* change the color of the titlebar text background when active */
  107.       bSuccess = WinSetPresParam( hwndTitle,
  108.                                   PP_ACTIVETEXTBGNDCOLOR,
  109.                                   sizeof ( RGB2 ),
  110.                                   (PVOID)&rgbColor ) ;
  111.  
  112.       rgbColor.bBlue  = 255 ;
  113.       rgbColor.bGreen = 255 ;
  114.       rgbColor.bRed   = 255 ;
  115.  
  116.       /* change the color of the titlebar text foreground when active */
  117.       bSuccess = WinSetPresParam( hwndTitle,
  118.                                   PP_ACTIVETEXTFGNDCOLOR,
  119.                                   sizeof ( RGB2 ),
  120.                                   (PVOID)&rgbColor ) ;
  121.  
  122.  
  123.       break;
  124.  
  125.    case WM_PAINT:
  126.       /* clear the screen */
  127.       hpsPaint = WinBeginPaint( hwndWnd, NULLHANDLE, &rclPaint ) ;
  128.       GpiErase( hpsPaint ) ;
  129.       WinEndPaint( hpsPaint ) ;
  130.       break;
  131.  
  132.    default:
  133.       return WinDefWindowProc ( hwndWnd,
  134.                                 ulMsg,
  135.                                 mpParm1,
  136.                                 mpParm2 ) ;
  137.    } /* endswitch */
  138.  
  139.    return MRFROMSHORT ( FALSE ) ;
  140. }
  141.