home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / MSGTRACE.ZIP / MyProjects / MsgTrace / MsgTracer / ExtToolBar.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-31  |  3.1 KB  |  123 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // ExtToolBar.cpp : implementation file
  3. /////////////////////////////////////////////////////////////////////////////
  4.  
  5. #include "stdafx.h"
  6. #include "ExtToolBar.h"
  7. #include "Resource.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CExtToolBar
  17. /////////////////////////////////////////////////////////////////////////////
  18.  
  19. #define WM_AFTER_MOVE WM_USER
  20.  
  21. BEGIN_MESSAGE_MAP(CExtToolBar, CToolBar)
  22.     //{{AFX_MSG_MAP(CExtToolBar)
  23.     ON_WM_MOVE()
  24.     //}}AFX_MSG_MAP
  25.     ON_MESSAGE( WM_AFTER_MOVE, OnAfterMove )
  26. END_MESSAGE_MAP()
  27.  
  28. WNDPROC CExtToolBar::m_lpfnOldWndProcParent = NULL;
  29. CDC CExtToolBar::m_dcBackground;
  30. CBitmap CExtToolBar::m_bmpBackground;
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CExtToolBar: construction
  34. /////////////////////////////////////////////////////////////////////////////
  35.  
  36. CExtToolBar::CExtToolBar()
  37. {
  38.     if( NULL == (HBITMAP) m_bmpBackground )
  39.     {
  40.         //m_bmpBackground.LoadBitmap( IDB_TBBACK2 );
  41.     }
  42.  
  43.     if( NULL == (HDC) m_dcBackground )
  44.     {
  45.         m_dcBackground.CreateCompatibleDC( NULL );
  46.         m_dcBackground.SelectObject( &m_bmpBackground );
  47.     }
  48.  
  49.     m_bParentSubclassed = FALSE;
  50. }
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53.  
  54. CExtToolBar::~CExtToolBar()
  55. {
  56. }
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CExtToolBar message handlers
  60. /////////////////////////////////////////////////////////////////////////////
  61.  
  62. void CExtToolBar::OnMove(int x, int y) 
  63. {
  64.     CToolBar::OnMove(x, y);
  65.     PostMessage( WM_AFTER_MOVE );
  66. }
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69.  
  70. LRESULT CExtToolBar::OnAfterMove( WPARAM, LPARAM )
  71. {
  72.     HWND hwndParent = ::GetParent( m_hWnd );
  73.     HWND hwndFrame = ::GetParent( hwndParent );
  74.  
  75.     if( ::IsWindow( hwndFrame ) )
  76.     {
  77.         if( !m_bParentSubclassed )
  78.         {
  79.             m_lpfnOldWndProcParent = (WNDPROC) ::GetWindowLong( hwndParent, GWL_WNDPROC );
  80.             ::SetWindowLong( hwndParent, GWL_WNDPROC, (LONG) ParentWindowProc );
  81.  
  82.             m_bParentSubclassed = TRUE;
  83.         }
  84.  
  85.         CRgn rgn;
  86.         rgn.CreateRectRgn( 0, 0, 2000, 2000 );
  87.  
  88.         ShowWindow( SW_HIDE );
  89.         ShowWindow( SW_SHOW );
  90.         ::RedrawWindow( hwndFrame, NULL, (HRGN) rgn, RDW_FRAME|RDW_ERASE|RDW_ERASENOW|RDW_INVALIDATE|RDW_UPDATENOW);
  91.     }
  92.     return( 0 );
  93. }
  94.  
  95. /////////////////////////////////////////////////////////////////////////////
  96.  
  97. LRESULT CALLBACK CExtToolBar::ParentWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  98. {
  99.     LRESULT lResult = (*m_lpfnOldWndProcParent)( hwnd, uMsg, wParam, lParam );
  100.  
  101.     if( WM_ERASEBKGND == uMsg )
  102.     {
  103.         CRect rect;
  104.         ::GetClientRect( hwnd, &rect );
  105.  
  106.         CDC* pDC = CDC::FromHandle( (HDC) wParam );
  107.         ASSERT( NULL != pDC );
  108.  
  109.         pDC->BitBlt( 0,
  110.                      0,
  111.                      rect.Width(),
  112.                      rect.Height(),
  113.                      &m_dcBackground,
  114.                      0,
  115.                      0,
  116.                      SRCCOPY );
  117.  
  118.         lResult = 1;
  119.     }
  120.  
  121.     return( lResult );
  122. }
  123.