MyPicSta.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // MyPicSta.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "MyPicSta.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // MyPicSta
  13. MyPicSta::MyPicSta()
  14. {
  15. m_pImg=NULL;
  16. }
  17. MyPicSta::~MyPicSta()
  18. {
  19. }
  20. BEGIN_MESSAGE_MAP(MyPicSta, CStatic)
  21. //{{AFX_MSG_MAP(MyPicSta)
  22. ON_WM_PAINT()
  23. ON_WM_CREATE()
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. /////////////////////////////////////////////////////////////////////////////
  27. // MyPicSta message handlers
  28. void MyPicSta::SetImage(Image *img)
  29. {
  30. m_pImg=img;
  31. }
  32. void MyPicSta::OnPaint()
  33. {
  34. CPaintDC dc(this); // device context for painting
  35. try
  36. {
  37. if(m_pImg==NULL)
  38. return;
  39. // TODO: Add your message handler code here
  40. CRect rc;
  41. GetClientRect(rc);
  42. Graphics graph(m_pbmp);
  43. graph.Clear(Color(255,0,0,0));
  44. Rect desRect(0, 0, rc.Width (), rc.Height ());
  45. graph.DrawImage(m_pImg, desRect, 0,0,m_pImg->GetWidth(),m_pImg->GetHeight(),UnitPixel);
  46. Graphics graph2(dc.GetSafeHdc ());
  47. graph2.DrawImage(m_pbmp,0,0);
  48. }
  49. catch(...)
  50. {
  51. }
  52. // Do not call CStatic::OnPaint() for painting messages
  53. }
  54. int MyPicSta::OnCreate(LPCREATESTRUCT lpCreateStruct)
  55. {
  56. if (CStatic::OnCreate(lpCreateStruct) == -1)
  57. return -1;
  58. // TODO: Add your specialized creation code here
  59. return 0;
  60. }