home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sftick.zip / adv / titlebar / WIN1.C < prev    next >
Text File  |  1994-04-21  |  4KB  |  140 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.    RGB   rgbColor ;
  72.    BOOL  bSuccess ;
  73.    HWND  hwndTitle ;
  74.    HWND  hwndFrame ;
  75.  
  76.    switch ( ulMsg ) {
  77.  
  78.    /* titlebar is not valid until after WM_CREATE is done  */
  79.    case WM_CREATE:
  80.       WinPostMsg( hwndWnd, WM_USER+1, MPVOID, MPVOID ) ;
  81.       break;
  82.  
  83.    case WM_USER+1:
  84.  
  85.       rgbColor.bBlue  = 200 ;
  86.       rgbColor.bGreen = 10 ;
  87.       rgbColor.bRed   = 5 ;
  88.  
  89.  
  90.       /* get the frame window handle */
  91.       hwndFrame = WinQueryWindow( hwndWnd, QW_PARENT ) ;
  92.  
  93.       /* get the titlebar window handle */
  94.       hwndTitle = WinWindowFromID( hwndFrame, FID_TITLEBAR ) ;
  95.  
  96.       /* change the color of the titlebar when active */
  97.       bSuccess = WinSetPresParam( hwndTitle,
  98.                                   PP_ACTIVECOLOR,
  99.                                   sizeof ( RGB ),
  100.                                   (PVOID)&rgbColor ) ;
  101.       rgbColor.bBlue  = 200 ;
  102.       rgbColor.bGreen = 10 ;
  103.       rgbColor.bRed   = 5 ;
  104.  
  105.       /* change the color of the titlebar text background when active */
  106.       bSuccess = WinSetPresParam( hwndTitle,
  107.                                   PP_ACTIVETEXTBGNDCOLOR,
  108.                                   sizeof ( RGB ),
  109.                                   (PVOID)&rgbColor ) ;
  110.  
  111.       rgbColor.bBlue  = 255 ;
  112.       rgbColor.bGreen = 255 ;
  113.       rgbColor.bRed   = 255 ;
  114.  
  115.       /* change the color of the titlebar text foreground when active */
  116.       bSuccess = WinSetPresParam( hwndTitle,
  117.                                   PP_ACTIVETEXTFGNDCOLOR,
  118.                                   sizeof ( RGB ),
  119.                                   (PVOID)&rgbColor ) ;
  120.  
  121.  
  122.       break;
  123.  
  124.    case WM_PAINT:
  125.       /* clear the screen */
  126.       hpsPaint = WinBeginPaint( hwndWnd, NULLHANDLE, &rclPaint ) ;
  127.       GpiErase( hpsPaint ) ;
  128.       WinEndPaint( hpsPaint ) ;
  129.       break;
  130.  
  131.    default:
  132.       return WinDefWindowProc ( hwndWnd,
  133.                                 ulMsg,
  134.                                 mpParm1,
  135.                                 mpParm2 ) ;
  136.    } /* endswitch */
  137.  
  138.    return MRFROMSHORT ( FALSE ) ;
  139. }
  140.