ProgInd.cpp
Upload User: xrc9201
Upload Date: 2013-02-04
Package Size: 35k
Code Size: 3k
Development Platform:

Visual C++

  1. // ProgInd.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ProgInd.h"
  5. #include "Filler.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CProgressIndicator
  13. CProgressIndicator::CProgressIndicator( CFiller * pFiller ) : m_pFiller( pFiller )
  14. {
  15. // Step 1 - Set m_bCreated to FALSE
  16. m_bCreated = FALSE;
  17. // Step 2 - Check and create m_pFiller
  18. if( m_pFiller == NULL )
  19. {
  20. m_pFiller  = new CLToRFiller;
  21. m_bCreated = TRUE;
  22. }
  23. // Step 3 - Validate m_pFiller
  24. ASSERT( m_pFiller != NULL );
  25. }
  26. CProgressIndicator::~CProgressIndicator()
  27. {
  28. // Step 1 - Check and delete m_pFiller
  29. if( m_bCreated == TRUE )
  30. {
  31. delete m_pFiller;
  32. }
  33. }
  34. BEGIN_MESSAGE_MAP(CProgressIndicator, CWnd)
  35. //{{AFX_MSG_MAP(CProgressIndicator)
  36. ON_WM_PAINT()
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CProgressIndicator methods
  41. CFiller * CProgressIndicator::GetFiller()
  42. {
  43. // Step 1 - Return m_pFiller
  44. return m_pFiller;
  45. }
  46. INT CProgressIndicator::SetFiller( CFiller * pFiller )
  47. {
  48. // Step 1 - Validate pFiller
  49. ASSERT( pFiller != NULL );
  50. // Step 2 - Check and delete m_pFiller
  51. if( m_bCreated == TRUE )
  52. {
  53. delete m_pFiller;
  54. m_bCreated = FALSE;
  55. }
  56. // Step 3 - Set m_pFiller to the parameter passed
  57. m_pFiller = pFiller;
  58. return SUCCESS;
  59. }
  60. INT CProgressIndicator::SetText( LPCSTR lpszText )
  61. {
  62. // Step 1 - Delegate and forward this to CFiller object
  63. INT nRetVal = m_pFiller->SetFillerText( lpszText );
  64. Invalidate();
  65. return nRetVal;
  66. }
  67. INT CProgressIndicator::SetRange( INT nMinRange, INT nMaxRange )
  68. {
  69. // Step 1 - Delegate and forward this to CFiller object
  70. return m_pFiller->SetFillerRange( nMinRange, nMaxRange );
  71. }
  72. INT CProgressIndicator::GetPos()
  73. {
  74. // Step 1 - Delegate and forward this to CFiller object
  75. return m_pFiller->GetFillerPos();
  76. }
  77. INT CProgressIndicator::SetPos( INT nPos )
  78. {
  79. // Step 1 - Delegate and forward this to CFiller object
  80. INT nOldPos = m_pFiller->SetFillerPos( nPos );
  81. Invalidate();
  82. return nOldPos;
  83. }
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CProgressIndicator message handlers
  86. void CProgressIndicator::OnPaint() 
  87. {
  88. CPaintDC dc(this); // device context for painting
  89. // Step 1 - Get the client Rectangle
  90. CRect Rect;
  91. GetClientRect( & Rect );
  92. // Step 2 - Call DoFill to do the filling, based on the current situation
  93. m_pFiller->DoFill( this, Rect );
  94. }