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.

124 lines
4.6 KiB

  1. /*************************************************************************/
  2. /* Copyright (C) 1999 Microsoft Corporation */
  3. /* File: MSMFImg.cpp */
  4. /* Description: Implementation of CMSMFImg Static Image class */
  5. /* Author: David Janecek */
  6. /*************************************************************************/
  7. #include "stdafx.h"
  8. #include "MSMFCnt.h"
  9. #include "MSMFImg.h"
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CMSMFImg
  12. /*************************************************************************/
  13. /* Function: CMSMFImg */
  14. /*************************************************************************/
  15. CMSMFImg::CMSMFImg(){
  16. m_pBackBitmap = new CBitmap;
  17. Init();
  18. }/* end of function CMSMFSldr */
  19. /*************************************************************************/
  20. /* Function: Init */
  21. /* Description: Initializes variable states. */
  22. /*************************************************************************/
  23. void CMSMFImg::Init(){
  24. m_blitType = DISABLE;
  25. m_clrBackColor = ::GetSysColor(COLOR_BTNFACE);
  26. #if 0 // used for getting the windowed case working DJ
  27. m_bWindowOnly = TRUE;
  28. #endif
  29. }/* end of function Init */
  30. /*************************************************************************/
  31. /* Function: ~CMSMFImg */
  32. /* Description: Cleanup the stuff we allocated here rest will be done */
  33. /* in the button destructor. */
  34. /*************************************************************************/
  35. CMSMFImg::~CMSMFImg(){
  36. delete m_pBackBitmap;
  37. Init();
  38. }/* end of function CMSMFSldr */
  39. /*************************************************************************/
  40. /* Function: OnDraw */
  41. /* Description: Does the basic drawing */
  42. /* First draws the background the the thumb at the specific position. */
  43. /*************************************************************************/
  44. HRESULT CMSMFImg::OnDraw(ATL_DRAWINFO& di){
  45. HRESULT hr = S_OK;
  46. BOOL bRet = TRUE;
  47. HDC hdc = di.hdcDraw;
  48. RECT rcClient = *(RECT*)di.prcBounds;
  49. // DRAW THE BACKGROUND
  50. if (!m_pBackBitmap->IsEmpty()){
  51. bRet = m_pBackBitmap->PaintTransparentDIB(hdc, NULL,
  52. &rcClient, m_blitType);
  53. }
  54. else {
  55. COLORREF clr;
  56. ::OleTranslateColor (m_clrBackColor, m_pBackBitmap->GetPal(), &clr);
  57. HBRUSH hbrBack = ::CreateSolidBrush(clr);
  58. ::FillRect(hdc, &rcClient, hbrBack);
  59. ::DeleteObject(hbrBack);
  60. }/* end of if statement */
  61. return (hr);
  62. }/* end of function OnDraw */
  63. /*************************************************************************/
  64. /* Function: PutImage */
  65. /* Description: Sets the image of the background. */
  66. /*************************************************************************/
  67. HRESULT CMSMFImg::PutImage(BSTR strFilename){
  68. HRESULT hr = S_OK;
  69. m_bstrBackFilename = strFilename;
  70. bool fGrayOut = false;
  71. hr = m_pBackBitmap->PutImage(strFilename, m_hRes, GetUnknown(),fGrayOut ,m_blitType);
  72. if(FAILED(hr)){
  73. return(hr);
  74. }/* end of if statement */
  75. InvalidateRgn(); // our helper function
  76. return(hr);
  77. }/* end of function PutImage */
  78. /*************************************************************************/
  79. /* Function: get_Image */
  80. /*************************************************************************/
  81. STDMETHODIMP CMSMFImg::get_Image(BSTR *pstrFilename){
  82. *pstrFilename = m_bstrBackFilename.Copy();
  83. return S_OK;
  84. }/* end of function get_Image */
  85. /*************************************************************************/
  86. /* Function: put_Image */
  87. /*************************************************************************/
  88. STDMETHODIMP CMSMFImg::put_Image(BSTR strFilename){
  89. return (PutImage(strFilename));
  90. }/* end of function put_BackStatic */
  91. /*************************************************************************/
  92. /* End of file: MSMFImg.cpp */
  93. /*************************************************************************/