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 >
Wrap
Text File
|
1994-04-21
|
4KB
|
141 lines
#define INCL_WIN
#define INCL_GPI
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CLS_CLIENT "WindowClass"
MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd,
ULONG ulMsg,
MPARAM mpParm1,
MPARAM mpParm2 ) ;
INT main ( VOID )
{
HAB habAnchor ;
HMQ hmqQueue ;
ULONG ulFlags ;
HWND hwndFrame ;
HWND hwndClient ;
QMSG qmMsg ;
/* basic PM stuff */
habAnchor = WinInitialize ( 0 ) ;
hmqQueue = WinCreateMsgQueue ( habAnchor, 0 ) ;
WinRegisterClass ( habAnchor,
CLS_CLIENT,
ClientWndProc,
0,
0 ) ;
ulFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST ;
hwndFrame = WinCreateStdWindow ( HWND_DESKTOP,
WS_VISIBLE,
&ulFlags,
CLS_CLIENT,
"Titlebar",
0,
NULLHANDLE,
0,
&hwndClient ) ;
if ( hwndFrame ) {
while( WinGetMsg ( habAnchor,
&qmMsg,
NULLHANDLE,
0,
0 ))
WinDispatchMsg ( habAnchor, &qmMsg ) ;
WinDestroyWindow ( hwndFrame ) ;
} /* endif */
WinDestroyMsgQueue ( hmqQueue ) ;
WinTerminate ( habAnchor ) ;
return 0 ;
}
MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd,
ULONG ulMsg,
MPARAM mpParm1,
MPARAM mpParm2 )
{
HPS hpsPaint ;
RECTL rclPaint ;
/* BINGO - for OS/2 2.x, use RGB2 structure instead of RGB */
RGB2 rgbColor ;
BOOL bSuccess ;
HWND hwndTitle ;
HWND hwndFrame ;
switch ( ulMsg ) {
/* titlebar is not valid until after WM_CREATE is done */
case WM_CREATE:
WinPostMsg( hwndWnd, WM_USER+1, MPVOID, MPVOID ) ;
break;
case WM_USER+1:
rgbColor.bBlue = 200 ;
rgbColor.bGreen = 10 ;
rgbColor.bRed = 5 ;
/* get the frame window handle */
hwndFrame = WinQueryWindow( hwndWnd, QW_PARENT ) ;
/* get the titlebar window handle */
hwndTitle = WinWindowFromID( hwndFrame, FID_TITLEBAR ) ;
/* change the color of the titlebar when active */
bSuccess = WinSetPresParam( hwndTitle,
PP_ACTIVECOLOR,
sizeof ( RGB2 ),
(PVOID)&rgbColor ) ;
rgbColor.bBlue = 200 ;
rgbColor.bGreen = 10 ;
rgbColor.bRed = 5 ;
/* change the color of the titlebar text background when active */
bSuccess = WinSetPresParam( hwndTitle,
PP_ACTIVETEXTBGNDCOLOR,
sizeof ( RGB2 ),
(PVOID)&rgbColor ) ;
rgbColor.bBlue = 255 ;
rgbColor.bGreen = 255 ;
rgbColor.bRed = 255 ;
/* change the color of the titlebar text foreground when active */
bSuccess = WinSetPresParam( hwndTitle,
PP_ACTIVETEXTFGNDCOLOR,
sizeof ( RGB2 ),
(PVOID)&rgbColor ) ;
break;
case WM_PAINT:
/* clear the screen */
hpsPaint = WinBeginPaint( hwndWnd, NULLHANDLE, &rclPaint ) ;
GpiErase( hpsPaint ) ;
WinEndPaint( hpsPaint ) ;
break;
default:
return WinDefWindowProc ( hwndWnd,
ulMsg,
mpParm1,
mpParm2 ) ;
} /* endswitch */
return MRFROMSHORT ( FALSE ) ;
}