home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
WILDASS
/
SOURCE
/
FAKECPTN.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-27
|
4KB
|
136 lines
// fakecptn.cpp
//
// implementation file for CFakeWnd
//
// update: 1.00 28-Jul-93 tw
#include <afxwin.h>
#include <afxext.h>
#include "fakecptn.h"
BEGIN_MESSAGE_MAP( CFakeWnd, CFrameWnd )
ON_WM_NCHITTEST()
ON_WM_PAINT()
ON_WM_ACTIVATEAPP()
END_MESSAGE_MAP()
CFakeWnd::CFakeWnd()
{
// create it, using the base classes create fxn
VERIFY( Create( NULL, "FakeCaption",
WS_POPUP | WS_BORDER, CRect(0,0,100,100) ));
// calculate the fake captions size
int cyCaption = GetSystemMetrics( SM_CYCAPTION ) / 3;
m_pRectCaption = new CRect( cyCaption, 0, 100, cyCaption );
ASSERT( m_pRectCaption );
// ... and the close boxes size too
m_pRectSysMenu = new CRect( 0, 0, cyCaption, cyCaption );
ASSERT( m_pRectSysMenu );
}
CFakeWnd::~CFakeWnd()
{
// take care of the alloted objects
delete m_pRectSysMenu;
delete m_pRectCaption;
}
UINT
CFakeWnd::OnNcHitTest( CPoint pnt )
{
// get the client coordinates of the point we`re testing
ScreenToClient( &pnt );
// if we`re in the fake caption bar, tell windows we`re in
// the actual caption bar
if ( m_pRectCaption->PtInRect( pnt ))
{
return HTCAPTION;
}
// if we`re in the closebox, tell windows we are..
if ( m_pRectSysMenu->PtInRect( pnt ))
{
return HTSYSMENU;
}
// base class will do the rest
return CFrameWnd::OnNcHitTest( pnt );
}
void
CFakeWnd::OnPaint()
{
// select a color according to focus
COLORREF col = ( GetFocus() == this ) ? GetSysColor( COLOR_ACTIVECAPTION )
: GetSysColor( COLOR_INACTIVECAPTION );
// paint the caption
CBrush brushCaption;
VERIFY( brushCaption.CreateSolidBrush( col ));
CPaintDC dc( this );
dc.FillRect( *m_pRectCaption, &brushCaption );
// paint the menu box
CBrush brushMenu;
VERIFY( brushMenu.CreateSolidBrush( GetSysColor( COLOR_MENU )));
dc.FillRect( *m_pRectSysMenu, &brushMenu );
// paint the boxes logo
CBrush brushCloseSign;
VERIFY( brushCloseSign.CreateSolidBrush( RGB( 255, 255, 255 )));
CRect rectCloseSign( 2,
(m_pRectSysMenu->Height()/2)-1,
m_pRectSysMenu->Width()-2,
(m_pRectSysMenu->Height()/2)+1 );
dc.FillRect( rectCloseSign, &brushCloseSign );
CPen penBlack;
VERIFY( penBlack.CreatePen( PS_SOLID, 0, RGB( 0, 0, 0) ));
// paint the black separator lines
CPen * pPenOrig;
VERIFY( pPenOrig = dc.SelectObject( &penBlack ));
dc.MoveTo( rectCloseSign.TopLeft() );
CPoint pntTopRight = rectCloseSign.TopLeft() + CSize( rectCloseSign.Width(), 0 );
VERIFY( dc.LineTo( pntTopRight ));
VERIFY( dc.LineTo( rectCloseSign.BottomRight() ));
CPoint pntBottomLeft = rectCloseSign.BottomRight() - CSize( rectCloseSign.Width(), 0 );
VERIFY( dc.LineTo( pntBottomLeft ));
VERIFY( dc.LineTo( rectCloseSign.TopLeft() ));
dc.MoveTo( 0, m_pRectSysMenu->bottom );
VERIFY( dc.LineTo( m_pRectCaption->right, m_pRectSysMenu->bottom ));
dc.MoveTo( m_pRectSysMenu->right, m_pRectSysMenu->bottom );
VERIFY( dc.LineTo( m_pRectSysMenu->right, m_pRectSysMenu->top-1 ));
dc.SelectObject( pPenOrig );
}
void
CFakeWnd::OnActivateApp( BOOL bActive, HTASK /*hTask*/ )
{
// if activation state changes, take care
// the caption bar is redrawn - or it will stay in
// the state it was before; remember this is _not_
// an ordinary caption bar so nobody else will take care of it...
TRACE("OnACtivateApp called\n");
CRect rectClient;
GetClientRect( &rectClient );
InvalidateRect( rectClient );
}