EGMDIClient.cpp
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 24k
Category:

Graph program

Development Platform:

Visual C++

  1. #include "StdAfx.h"
  2. #include "EGMDIClient.h"
  3. #include "NewTheme.h"
  4. #include "EGMenu.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. #define TABS_HEIGHT 24
  11. #define TABS_BKGND RGB(247,243,233)
  12. #define PADDING 3
  13. #define WM_RECALC_BUTTONS WM_USER + 1
  14. #include <algorithm>
  15. #include <functional>
  16. //////////////////////////////////////////////////////////////////////////// 
  17. // Registry keys used for saving/restoring the state
  18. static TCHAR szSection[]      = _T( "MDIClient" );
  19. static TCHAR szDisplayMode[]  = _T( "DisplayMode" );
  20. static TCHAR szBkColor[]      = _T( "BkColor" );
  21. static TCHAR szFileName[]     = _T( "FileName" );
  22. static TCHAR szOriginX[]      = _T( "OriginX" );
  23. static TCHAR szOriginY[]      = _T( "OriginY" );
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CEGMDITabBtn
  26. void CEGMDITabBtn::Copy( const CEGMDITabBtn & tab ) {
  27. m_hWnd = tab.m_hWnd;
  28. m_nWidth = tab.m_nWidth;
  29. m_nLeft = tab.m_nLeft;
  30. m_clrColor = tab.m_clrColor;
  31. }
  32. CEGMDITabBtn::CEGMDITabBtn( HWND hWnd ) {
  33. m_hWnd = hWnd;
  34. m_nWidth = 0;
  35. m_clrColor = themeData.GetNewColor();
  36. }
  37. CEGMDITabBtn::CEGMDITabBtn( const CEGMDITabBtn & tab ) {
  38. Copy( tab );
  39. }
  40. CEGMDITabBtn & CEGMDITabBtn::operator=( const CEGMDITabBtn & tab ) {
  41. Copy( tab );
  42. return *this;
  43. }
  44. CString CEGMDITabBtn::GetTitle() { 
  45. CString szTitle;
  46. GetWindowText( m_hWnd, szTitle.GetBuffer(100), 100 );
  47. szTitle.ReleaseBuffer();
  48. return szTitle; 
  49. }
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CEGMDIClient
  52. static int CALLBACK EnumFontFamProc(ENUMLOGFONT FAR *lpelf,
  53.                              NEWTEXTMETRIC FAR *lpntm,
  54.                              int FontType,
  55.                              LPARAM lParam)
  56. {
  57.     UNUSED_ALWAYS(lpelf);
  58.     UNUSED_ALWAYS(lpntm);
  59.     UNUSED_ALWAYS(FontType);
  60.     UNUSED_ALWAYS(lParam);
  61.     return 0;
  62. }
  63. CEGMDIClient::CEGMDIClient()
  64. {   
  65. Reset();
  66. m_bAutoSaveRestore = FALSE;
  67. m_bShowTabs = FALSE;
  68.   m_cxEdge = 6;
  69. m_cxControls = 45;
  70. m_nWidth = 0;
  71. m_bPriorEnabled = FALSE;
  72. m_bPriorHover = FALSE;
  73. m_bPriorPressed = FALSE;
  74. m_bNextEnabled = FALSE;
  75. m_bNextHover = FALSE;
  76. m_bNextPressed = FALSE;
  77. m_bCloseEnabled = TRUE;
  78. m_bCloseHover = FALSE;
  79. m_bClosePressed = FALSE;
  80. m_cxOffset = 0;
  81. m_cxBtnsAvailable = 0;
  82. m_cxBtnsTotal = 0;
  83. m_bTabDrag = FALSE;
  84. }
  85. CEGMDIClient::~CEGMDIClient()
  86. {
  87. }
  88. void CEGMDIClient::PreSubclassWindow()
  89. {
  90. CWnd::PreSubclassWindow();
  91. if ( m_bAutoSaveRestore == TRUE )
  92. RestoreState();
  93. m_oldWndProc = (WNDPROC)::GetWindowLongPtr( m_hWnd, GWLP_WNDPROC );
  94. }
  95. void CEGMDIClient::Reset()
  96. {
  97. m_ptOrigin.x = m_ptOrigin.y = 0;
  98. m_sizeImage.cx = m_sizeImage.cy = 0;
  99. m_eDisplayMode = dispTile;
  100. m_strFileName.Empty();      
  101. SetBkColor( themeData.clrAppWorkSpace );
  102. m_bitmap.DeleteObject();
  103. if ( IsWindow( m_hWnd ) )
  104. Invalidate();
  105. }
  106. BOOL CEGMDIClient::SetBitmap( LPCTSTR lpszFileName, UINT uFlags )
  107. {
  108. HANDLE handle = ::LoadImage( AfxGetInstanceHandle(),
  109. lpszFileName,
  110. IMAGE_BITMAP,
  111. 0, 0,
  112. uFlags | LR_LOADFROMFILE );
  113. if ( !handle )    // There were some problems during loading the image
  114. return FALSE;
  115. m_bitmap.DeleteObject();
  116. m_bitmap.Attach( (HBITMAP)handle );
  117. if ( IsWindow( m_hWnd ) )
  118. Invalidate();
  119. m_strFileName = lpszFileName;
  120. BITMAP bi;
  121. m_bitmap.GetBitmap( &bi );
  122. m_sizeImage.cx = bi.bmWidth;
  123. m_sizeImage.cy = bi.bmHeight;
  124. return TRUE;
  125. }
  126. BOOL CEGMDIClient::SetBitmap( UINT nBitmapID, COLORMAP* pClrMap, int nCount )
  127. {
  128. m_bitmap.DeleteObject();
  129. if ( pClrMap == NULL )  // Load normal
  130. {
  131. if ( m_bitmap.LoadBitmap( nBitmapID ) == FALSE )
  132. return FALSE;
  133. }
  134. else                    // Load mapped 
  135. {      
  136. if ( m_bitmap.LoadMappedBitmap( nBitmapID, 0, pClrMap, nCount ) == FALSE )
  137. return FALSE;
  138. }
  139. BITMAP bi;
  140. m_bitmap.GetBitmap( &bi );
  141. m_sizeImage.cx = bi.bmWidth;
  142. m_sizeImage.cy = bi.bmHeight;
  143. if ( IsWindow( m_hWnd ) )
  144. Invalidate();
  145. return TRUE;
  146. }
  147. void CEGMDIClient::SetBkColor( COLORREF clrValue )
  148. {
  149. m_clrBackground = clrValue;
  150. m_brush.DeleteObject();
  151. m_brush.CreateSolidBrush( m_clrBackground );
  152. if ( IsWindow( m_hWnd ) )
  153. Invalidate();
  154. }
  155. void CEGMDIClient::SetDisplayMode( CEGMDIClient::DisplayModesEnum eDisplayMode )
  156. {
  157. m_eDisplayMode = eDisplayMode;      
  158. if ( IsWindow( m_hWnd ) )
  159. Invalidate();
  160. }
  161. void CEGMDIClient::SaveState()
  162. {
  163. AfxGetApp()->WriteProfileInt( szSection, szDisplayMode, GetDisplayMode() );
  164. AfxGetApp()->WriteProfileInt( szSection, szBkColor, GetBkColor() );
  165. AfxGetApp()->WriteProfileString( szSection, szFileName, GetFileName() );
  166. AfxGetApp()->WriteProfileInt( szSection, szOriginX, GetOrigin().x );
  167. AfxGetApp()->WriteProfileInt( szSection, szOriginY, GetOrigin().y );   
  168. }
  169. void CEGMDIClient::RestoreState()
  170. {   
  171. m_eDisplayMode = (DisplayModesEnum)AfxGetApp()->GetProfileInt( szSection, szDisplayMode, dispTile );      
  172. m_ptOrigin.x = AfxGetApp()->GetProfileInt( szSection, szOriginX, 0 );
  173. m_ptOrigin.y = AfxGetApp()->GetProfileInt( szSection, szOriginY, 0 );
  174. SetBkColor( AfxGetApp()->GetProfileInt( szSection, szBkColor, themeData.clrAppWorkSpace ) );
  175. CString str = AfxGetApp()->GetProfileString( szSection, szFileName, _T( "" ) );
  176. if ( str.GetLength() )
  177. SetBitmap( str );
  178. }
  179. BEGIN_MESSAGE_MAP(CEGMDIClient, CWnd)
  180.    ON_WM_DESTROY()
  181.    ON_WM_PAINT()
  182.    ON_WM_SIZE()
  183.    ON_WM_ERASEBKGND()
  184.  ON_MESSAGE( WM_MDICREATE, OnMDICreate )
  185.  ON_MESSAGE( WM_MDIDESTROY, OnMDIDestroy )
  186.  ON_MESSAGE( WM_MDINEXT, OnMDINext )
  187.  ON_MESSAGE( WM_MDIACTIVATE, OnMDIActivate )
  188.  ON_MESSAGE( WM_RECALC_BUTTONS, OnRecalcButtons )
  189.  ON_WM_NCLBUTTONDOWN()
  190.  ON_WM_NCLBUTTONUP()
  191.  ON_WM_LBUTTONUP()
  192.  ON_WM_NCMOUSEMOVE()
  193.  ON_WM_CANCELMODE()
  194.  ON_WM_MOUSEMOVE()
  195.  ON_WM_STYLECHANGED( )
  196.  ON_WM_NCCALCSIZE()
  197.  ON_WM_NCPAINT( )
  198.  ON_WM_NCHITTEST()
  199. END_MESSAGE_MAP()
  200. /////////////////////////////////////////////////////////////////////////////
  201. // CEGMDIClient message handlers
  202. void CEGMDIClient::OnPaint() 
  203. {
  204. CPaintDC dc( this );
  205. CRect rc;
  206. GetClientRect( rc );
  207. if ( !(HBITMAP)m_bitmap )   // If no bitmap is selected
  208. dc.FillRect( rc, &m_brush );
  209. if ( (HBITMAP)m_bitmap )
  210. {
  211. CDC* pDC;
  212. CDC memDC;
  213. CBitmap bmp; 
  214. BOOL bDrawOnMemDC = ( GetDisplayMode() != dispTile ) ? TRUE : FALSE;
  215. if ( bDrawOnMemDC )
  216. {
  217. if ( GetDisplayMode() != dispStretch )
  218. bmp.CreateCompatibleBitmap( &dc, rc.right, rc.bottom );
  219. else
  220. bmp.CreateCompatibleBitmap( &dc, m_sizeImage.cx, m_sizeImage.cy );
  221. memDC.CreateCompatibleDC( &dc );
  222. memDC.SelectObject( &bmp );
  223. pDC = &memDC;
  224. }
  225. else
  226. pDC = &dc;      
  227. switch ( GetDisplayMode() )
  228. {
  229. case dispCustom:
  230. {
  231. pDC->FillRect( rc, &m_brush );               
  232. pDC->DrawState( m_ptOrigin, m_sizeImage, &m_bitmap, DST_BITMAP | DSS_NORMAL );
  233. }
  234. break;
  235. case dispCenter:
  236. {
  237. pDC->FillRect( rc, &m_brush );
  238. CPoint point( ( rc.Width() - m_sizeImage.cx ) / 2, 
  239. ( rc.Height() - m_sizeImage.cy ) / 2 );
  240. pDC->DrawState( point, m_sizeImage, &m_bitmap, DST_BITMAP | DSS_NORMAL );
  241. }
  242. break;
  243. case dispTile:
  244. {
  245. CPoint point;
  246. for ( point.y = 0; point.y < rc.Height(); point.y += m_sizeImage.cy )
  247. for ( point.x = 0; point.x < rc.Width(); point.x += m_sizeImage.cx )
  248. pDC->DrawState( point, m_sizeImage, &m_bitmap, DST_BITMAP | DSS_NORMAL );
  249. }
  250. break;
  251. case dispStretch:
  252. {
  253. memDC.DrawState( CPoint(0,0), m_sizeImage, &m_bitmap, DST_BITMAP | DSS_NORMAL );
  254. dc.SetStretchBltMode( COLORONCOLOR );
  255. dc.StretchBlt( 0, 0, rc.right, rc.bottom, &memDC, 
  256. 0, 0, m_sizeImage.cx, m_sizeImage.cy, SRCCOPY );
  257. }
  258. return;
  259. }
  260. if ( bDrawOnMemDC == TRUE )
  261. dc.BitBlt( 0, 0, rc.right, rc.bottom, pDC, 0, 0, SRCCOPY );
  262. }
  263. }
  264. BOOL CEGMDIClient::OnEraseBkgnd( CDC* /*pDC*/ ) 
  265. {   
  266.    return TRUE;    // Return TRUE so background is not erased   
  267. }
  268. void CEGMDIClient::OnSize( UINT nType, int cx, int cy )
  269. {
  270. if ( nType != SIZE_MINIMIZED && GetDisplayMode() != dispTile )   // Force repainting if center mode is selected
  271. Invalidate();
  272. CWnd::OnSize( nType, cx, cy );
  273. }
  274. void CEGMDIClient::OnDestroy()
  275. {   
  276. if ( m_bAutoSaveRestore == TRUE )
  277. SaveState();
  278. CWnd::OnDestroy();
  279. }
  280. LRESULT CEGMDIClient::OnMDICreate ( WPARAM wParam, LPARAM lParam ) {
  281. LRESULT res = m_oldWndProc( m_hWnd, WM_MDICREATE, wParam, lParam );
  282. if( res ) {
  283. m_lstTabBtns.push_back( CEGMDITabBtn( (HWND)res ) );
  284. m_hWndActive = (HWND)res;
  285. PostMessage( WM_RECALC_BUTTONS, 2 );
  286. }
  287. return res;
  288. }
  289. LRESULT CEGMDIClient::OnMDIDestroy ( WPARAM wParam, LPARAM lParam ) {
  290. LRESULT res = m_oldWndProc( m_hWnd, WM_MDIDESTROY, wParam, lParam );
  291. CEGMDITabBtnsIt itToDestroy = find_if( m_lstTabBtns.begin(), m_lstTabBtns.end(), MatchWndBtn( (HWND)wParam ) );
  292. if ( itToDestroy != m_lstTabBtns.end() )
  293. m_lstTabBtns.erase( itToDestroy );
  294. if ( m_bShowTabs ) {
  295. if ( NULL == ::GetWindow( m_hWnd, GW_CHILD ) ) {
  296. m_bShowTabs = FALSE;
  297. PostMessage( WM_RECALC_BUTTONS, 1 );
  298. } else {
  299. m_hWndActive = (HWND)::SendMessage( m_hWnd, WM_MDIGETACTIVE, 0, 0 );
  300. PostMessage( WM_RECALC_BUTTONS );
  301. }
  302. }
  303. return res;
  304. }
  305. LRESULT CEGMDIClient::OnMDINext ( WPARAM wParam, LPARAM lParam ) {
  306. //LRESULT res = m_oldWndProc( m_hWnd, WM_MDINEXT, wParam, lParam );
  307. if ( m_lstTabBtns.size() == 1 )
  308. return 0L;
  309. CEGMDITabBtnsIt itActive = find_if( m_lstTabBtns.begin(), m_lstTabBtns.end(), MatchWndBtn( (HWND)wParam ) );
  310. if ( itActive == m_lstTabBtns.end() )
  311. return 0L;
  312. if( lParam == 0 ) {
  313. // forward
  314. if( itActive->m_hWnd != m_lstTabBtns.back().m_hWnd ) {
  315. ++itActive;
  316. } else {
  317. itActive = m_lstTabBtns.begin();
  318. }
  319. } else {
  320. // backward
  321. if( itActive->m_hWnd != m_lstTabBtns.front().m_hWnd ) {
  322. --itActive;
  323. } else {
  324. itActive = --m_lstTabBtns.end();
  325. }
  326. }
  327. if ( itActive->m_nLeft < 0 ) {
  328. m_cxOffset -= -itActive->m_nLeft;
  329. } else if ( m_cxBtnsAvailable < ( itActive->m_nLeft + itActive->m_nWidth ) ) {
  330. m_cxOffset += ( itActive->m_nLeft + itActive->m_nWidth ) - m_cxBtnsAvailable;
  331. }
  332. ActivateMDI( itActive->m_hWnd );
  333. m_hWndActive = itActive->m_hWnd;
  334. return 0L;
  335. }
  336. LRESULT CEGMDIClient::OnMDIActivate ( WPARAM wParam, LPARAM lParam ) {
  337. LRESULT res = m_oldWndProc( m_hWnd, WM_MDIACTIVATE, wParam, lParam );
  338. m_hWndActive = (HWND)wParam;
  339. OnRecalcButtons( 0, 0 );
  340. return res;
  341. }
  342. void CEGMDIClient::OnNcCalcSize(
  343.    BOOL bCalcValidRects,
  344.    NCCALCSIZE_PARAMS* lpncsp ) 
  345. {
  346. CWnd::OnNcCalcSize( bCalcValidRects, lpncsp );
  347. if ( m_bShowTabs ) {
  348. lpncsp[0].rgrc->top += TABS_HEIGHT;
  349. lpncsp[0].rgrc->right -= 2;
  350. lpncsp[0].rgrc->left += 2;
  351. lpncsp[0].rgrc->bottom -= 2;
  352. CRect rc (*lpncsp[0].rgrc);
  353. rc.OffsetRect( -rc.TopLeft() );
  354. CalcButtons( &rc );
  355. }
  356. }
  357. void CEGMDIClient::OnStyleChanged( int nStyleType, LPSTYLESTRUCT lpStyleStruct ) {
  358. m_hWndActive = (HWND)::SendMessage( m_hWnd, WM_MDIGETACTIVE, 0, (LPARAM) &m_bShowTabs );
  359. m_bShowTabs = !m_bShowTabs;
  360. }
  361. void CEGMDIClient::OnNcPaint() {
  362. CWnd::OnNcPaint();
  363. if ( m_bShowTabs ) {
  364. // get window DC that is clipped to the non-client area
  365. CWindowDC dc(this);
  366. CRect rectClient;
  367. GetWindowRect(rectClient);
  368. rectClient.OffsetRect( -rectClient.TopLeft() );
  369. // Draw border
  370. BOOL bOldStyle = CEGMenu::GetMenuDrawMode() == CEGMenu::STYLE_ORIGINAL ||
  371. CEGMenu::GetMenuDrawMode() == CEGMenu::STYLE_ORIGINAL_NOBORDER;
  372. // if ( !bOldStyle ) {
  373. CPen pnBorder( PS_SOLID, 1, bOldStyle ? themeData.clrBtnFace : themeData.clr3DShadow );
  374. CPen * pOldPen = dc.SelectObject( &pnBorder );
  375. dc.MoveTo( 0 , 0 );
  376. dc.LineTo( rectClient.right - 1, 0  );
  377. dc.LineTo( rectClient.right - 1, rectClient.bottom - 1 );
  378. dc.LineTo( 0, rectClient.bottom - 1 );
  379. dc.LineTo( 0, 0 );
  380. CPen pnBorder2( PS_SOLID, 1, themeData.clrBtnFace );
  381. dc.SelectObject( &pnBorder2 );
  382. dc.MoveTo( rectClient.right - 2, 1  );
  383. dc.LineTo( rectClient.right - 2, rectClient.bottom - 2 );
  384. dc.LineTo( 1, rectClient.bottom - 2 );
  385. dc.LineTo( 1, 0 );
  386. dc.SelectObject( pOldPen );
  387. CRect rcTabs = rectClient;
  388. rcTabs.top = 1;
  389. rcTabs.bottom = rcTabs.top + TABS_HEIGHT - 1;
  390. CSurface surface;
  391. // tabs
  392. rcTabs.left = 2;
  393. rcTabs.right = rectClient.right - m_cxControls - m_cxEdge - 2;
  394. DrawTabs( surface.Lock( &dc, &rcTabs ), surface.GetBounds() );
  395. surface.Release();
  396. // controls
  397. rcTabs.left = rectClient.right - m_cxControls - m_cxEdge - 2;
  398. rcTabs.right = rectClient.right - 2;
  399. DrawControls( surface.Lock( &dc, &rcTabs ), surface.GetBounds() );
  400. surface.Release();
  401. }
  402. }
  403. void CEGMDIClient::DrawTabs( CDC * pDC, LPRECT lprcBounds ) {
  404. ASSERT( NULL != lprcBounds );
  405. if( m_lstTabBtns.empty() )
  406. return;
  407. CEGMDITabBtnsIt it, itFirst = m_lstTabBtns.begin(),
  408. itLast = m_lstTabBtns.end();
  409. COLORREF clrActive = themeData.clrBtnFace;
  410. for( it = itFirst; it != itLast; ++it ) {
  411. if ( it->m_hWnd == m_hWndActive ) {
  412. clrActive = it->m_clrColor;
  413. break;
  414. }
  415. }
  416. themeData.DrawTabCtrlBK( pDC, lprcBounds, ALIGN_TOP, TRUE, clrActive );
  417. // Draw buttons  
  418. CRect rcButton( *lprcBounds );
  419. rcButton.top+=2;
  420. int nOldBkMode = pDC->SetBkMode(TRANSPARENT);
  421. // CFont* pOldFont = pDC->SelectObject( &m_fntThin );
  422. for( it = itFirst; it != itLast; ++it ) {
  423. CEGMDITabBtn btn = (*it);
  424. BOOL bSelected = ( btn.m_hWnd == m_hWndActive );
  425. int nWidth = btn.m_nWidth;
  426. rcButton.left = btn.m_nLeft;
  427. rcButton.right = rcButton.left + nWidth;
  428. themeData.DrawTab( pDC, &rcButton, NULL, (TCHAR*)(LPCTSTR)btn.GetTitle(), ALIGN_TOP, STYLE_COOL | ( bSelected ? STYLE_ACTIVE : 0 ), btn.m_clrColor );
  429. }
  430. // pDC->SelectObject( pOldFont );
  431. }
  432. void CEGMDIClient::DrawControls( CDC * pDC, LPRECT lprcBounds ) {
  433. ASSERT( NULL != lprcBounds );
  434. CEGMDITabBtnsIt it, itFirst = m_lstTabBtns.begin(),
  435. itLast = m_lstTabBtns.end();
  436. COLORREF clrActive = themeData.clrBtnFace;
  437. for( it = itFirst; it != itLast; ++it ) {
  438. if ( it->m_hWnd == m_hWndActive ) {
  439. clrActive = it->m_clrColor;
  440. break;
  441. }
  442. }
  443. themeData.DrawTabCtrlBK( pDC, lprcBounds, ALIGN_TOP, TRUE, clrActive );
  444. CRect rc( *lprcBounds );
  445. CPen pnCross( PS_SOLID, 1, themeData.clr3DShadow );
  446. CPen * pOldPen = pDC->SelectObject( &pnCross );
  447. // Draw cross
  448. rc = m_rcClose;
  449. rc.OffsetRect( -( m_nWidth - ( lprcBounds->right - lprcBounds->left ) ), 0 );
  450. themeData.DrawX( pDC, &rc ); 
  451. rc.OffsetRect( -1, 0 );
  452. themeData.DrawX( pDC, &rc ); 
  453. if ( m_bCloseHover && m_bClosePressed ) {
  454. themeData.DrawPressedRect( pDC, &rc );
  455. } else if ( m_bCloseHover && !m_bClosePressed ) {
  456. themeData.DrawHoverRect( pDC, &rc );
  457. }
  458. // Draw arrows
  459. CBrush brEnabled, brDisabled, * pbrOld;
  460. brEnabled.CreateSolidBrush( themeData.clr3DShadow );
  461. brDisabled.CreateStockObject( NULL_BRUSH );
  462. rc = m_rcNext;
  463. rc.OffsetRect( -( m_nWidth - ( lprcBounds->right - lprcBounds->left ) ), 0 );
  464. POINT pts[3];
  465. pts[0].x = rc.left; pts[0].y = rc.top;
  466. pts[1].x = rc.left; pts[1].y = rc.bottom;
  467. pts[2].x = rc.left + 4; pts[2].y = rc.bottom - 4;
  468. if( m_bNextEnabled ) {
  469. pbrOld = pDC->SelectObject( &brEnabled );
  470. } else {
  471. pbrOld = pDC->SelectObject( &brDisabled );
  472. }
  473. pDC->Polygon( pts, 3);
  474. if ( m_bNextHover ) {
  475. rc.top = m_rcClose.top;
  476. rc.bottom = m_rcClose.bottom;
  477. rc.left -= 4;
  478. rc.right = rc.left + m_rcClose.Width();
  479. if ( m_bNextPressed ) {
  480. themeData.DrawPressedRect( pDC, &rc );
  481. } else {
  482. themeData.DrawHoverRect( pDC, &rc );
  483. }
  484. }
  485. rc = m_rcPrior;
  486. rc.OffsetRect( -( m_nWidth - ( lprcBounds->right - lprcBounds->left ) ), 0 );
  487. pts[0].x = rc.right; pts[0].y = rc.top;
  488. pts[1].x = rc.right; pts[1].y = rc.bottom;
  489. pts[2].x = rc.right - 4; pts[2].y = rc.bottom - 4;
  490. if( m_bPriorEnabled ) {
  491. pDC->SelectObject( &brEnabled );
  492. } else {
  493. pDC->SelectObject( &brDisabled );
  494. }
  495. pDC->Polygon( pts, 3);
  496. if ( m_bPriorHover ) {
  497. rc.top = m_rcClose.top;
  498. rc.bottom = m_rcClose.bottom;
  499. rc.left += 2;
  500. rc.right = rc.left + m_rcClose.Width();
  501. if ( m_bPriorPressed ) {
  502. themeData.DrawPressedRect( pDC, &rc );
  503. } else {
  504. themeData.DrawHoverRect( pDC, &rc );
  505. }
  506. }
  507. pDC->SelectObject( pbrOld );
  508. pDC->SelectObject( pOldPen );
  509. }
  510. void CEGMDIClient::CalcButtons( LPRECT lprcBounds ) {
  511. ASSERT( lprcBounds != NULL );
  512. // 暑铕滂磬螓 觏铒铌 蜞狍