home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////
- // ExtToolBar.cpp : implementation file
- /////////////////////////////////////////////////////////////////////////////
-
- #include "stdafx.h"
- #include "ExtToolBar.h"
- #include "Resource.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CExtToolBar
- /////////////////////////////////////////////////////////////////////////////
-
- #define WM_AFTER_MOVE WM_USER
-
- BEGIN_MESSAGE_MAP(CExtToolBar, CToolBar)
- //{{AFX_MSG_MAP(CExtToolBar)
- ON_WM_MOVE()
- //}}AFX_MSG_MAP
- ON_MESSAGE( WM_AFTER_MOVE, OnAfterMove )
- END_MESSAGE_MAP()
-
- WNDPROC CExtToolBar::m_lpfnOldWndProcParent = NULL;
- CDC CExtToolBar::m_dcBackground;
- CBitmap CExtToolBar::m_bmpBackground;
-
- /////////////////////////////////////////////////////////////////////////////
- // CExtToolBar: construction
- /////////////////////////////////////////////////////////////////////////////
-
- CExtToolBar::CExtToolBar()
- {
- if( NULL == (HBITMAP) m_bmpBackground )
- {
- //m_bmpBackground.LoadBitmap( IDB_TBBACK2 );
- }
-
- if( NULL == (HDC) m_dcBackground )
- {
- m_dcBackground.CreateCompatibleDC( NULL );
- m_dcBackground.SelectObject( &m_bmpBackground );
- }
-
- m_bParentSubclassed = FALSE;
- }
-
- /////////////////////////////////////////////////////////////////////////////
-
- CExtToolBar::~CExtToolBar()
- {
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CExtToolBar message handlers
- /////////////////////////////////////////////////////////////////////////////
-
- void CExtToolBar::OnMove(int x, int y)
- {
- CToolBar::OnMove(x, y);
- PostMessage( WM_AFTER_MOVE );
- }
-
- /////////////////////////////////////////////////////////////////////////////
-
- LRESULT CExtToolBar::OnAfterMove( WPARAM, LPARAM )
- {
- HWND hwndParent = ::GetParent( m_hWnd );
- HWND hwndFrame = ::GetParent( hwndParent );
-
- if( ::IsWindow( hwndFrame ) )
- {
- if( !m_bParentSubclassed )
- {
- m_lpfnOldWndProcParent = (WNDPROC) ::GetWindowLong( hwndParent, GWL_WNDPROC );
- ::SetWindowLong( hwndParent, GWL_WNDPROC, (LONG) ParentWindowProc );
-
- m_bParentSubclassed = TRUE;
- }
-
- CRgn rgn;
- rgn.CreateRectRgn( 0, 0, 2000, 2000 );
-
- ShowWindow( SW_HIDE );
- ShowWindow( SW_SHOW );
- ::RedrawWindow( hwndFrame, NULL, (HRGN) rgn, RDW_FRAME|RDW_ERASE|RDW_ERASENOW|RDW_INVALIDATE|RDW_UPDATENOW);
- }
- return( 0 );
- }
-
- /////////////////////////////////////////////////////////////////////////////
-
- LRESULT CALLBACK CExtToolBar::ParentWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
- {
- LRESULT lResult = (*m_lpfnOldWndProcParent)( hwnd, uMsg, wParam, lParam );
-
- if( WM_ERASEBKGND == uMsg )
- {
- CRect rect;
- ::GetClientRect( hwnd, &rect );
-
- CDC* pDC = CDC::FromHandle( (HDC) wParam );
- ASSERT( NULL != pDC );
-
- pDC->BitBlt( 0,
- 0,
- rect.Width(),
- rect.Height(),
- &m_dcBackground,
- 0,
- 0,
- SRCCOPY );
-
- lResult = 1;
- }
-
- return( lResult );
- }
-