Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7 KiB

  1. // Title.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Title.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. #define COLOR_WHITE RGB(0xFF, 0xFF, 0xFF)
  11. #define COLOR_BLACK RGB(0, 0, 0)
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CStaticTitle
  14. CStaticTitle::CStaticTitle():
  15. m_fInitializedFont( FALSE ),
  16. m_fTipText( FALSE )
  17. {
  18. }
  19. CStaticTitle::~CStaticTitle()
  20. {
  21. }
  22. BEGIN_MESSAGE_MAP(CStaticTitle, CButton)
  23. //{{AFX_MSG_MAP(CStaticTitle)
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CStaticTitle message handlers
  28. //------------------------------------------------------------------------
  29. void CStaticTitle::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
  30. {
  31. // prep the device context
  32. CDC* pdc = CDC::FromHandle(lpDrawItemStruct->hDC);
  33. // get the drawing rect
  34. CRect rect = lpDrawItemStruct->rcItem;
  35. if ( ! m_fInitializedFont )
  36. {
  37. // get the window font
  38. CFont* pfont = GetFont();
  39. LOGFONT logfont;
  40. pfont->GetLogFont( &logfont );
  41. // modify the font - add height
  42. logfont.lfHeight = 32;
  43. logfont.lfWidth = 0;
  44. // set the font back
  45. pfont->CreateFontIndirect( &logfont );
  46. SetFont( pfont, TRUE );
  47. m_fInitializedFont = TRUE;
  48. }
  49. // fill in the background of the rectangle
  50. pdc->FillSolidRect( &rect, GetSysColor(COLOR_3DFACE) );
  51. // draw the text
  52. CString sz;
  53. GetWindowText( sz );
  54. rect.left = 4;
  55. pdc->DrawText( sz, &rect, DT_LEFT|DT_SINGLELINE|DT_VCENTER );
  56. }