ShowHeader.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // ShowHeader.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "uphonebox.h"
  5. #include "ShowHeader.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // ShowHeader dialog
  13. ShowHeader::ShowHeader(CWnd* pParent /*=NULL*/)
  14. : CDialog(ShowHeader::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(ShowHeader)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. }
  20. void ShowHeader::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(ShowHeader)
  24. // NOTE: the ClassWizard will add DDX and DDV calls here
  25. //}}AFX_DATA_MAP
  26. }
  27. BEGIN_MESSAGE_MAP(ShowHeader, CDialog)
  28. //{{AFX_MSG_MAP(ShowHeader)
  29. ON_WM_PAINT()
  30. ON_WM_CLOSE()
  31. //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // ShowHeader message handlers
  35. extern void RectFitDes(int width, int height, CRect &rc);
  36. void ShowHeader::OnPaint()
  37. {
  38. CPaintDC dc(this); // device context for painting
  39. // TODO: Add your message handler code here
  40. if (m_pImg)
  41. {
  42. CRect rc;
  43. GetClientRect(rc);
  44. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc);
  45. Graphics dcgraph(dc.GetSafeHdc());
  46. Rect destinationRect(rc.left, rc.top, rc.Width(), rc.Height());
  47. dcgraph.DrawImage(m_pImg, destinationRect, 0, 0, m_pImg->GetWidth(), m_pImg->GetHeight(), UnitPixel);
  48. }
  49. // Do not call CDialog::OnPaint() for painting messages
  50. }
  51. BOOL ShowHeader::OnInitDialog()
  52. {
  53. CDialog::OnInitDialog();
  54. // TODO: Add extra initialization here
  55. *m_pheaderhwnd = this->m_hWnd;
  56. return TRUE; // return TRUE unless you set the focus to a control
  57. // EXCEPTION: OCX Property Pages should return FALSE
  58. }
  59. void ShowHeader::OnClose()
  60. {
  61. // TODO: Add your message handler code here and/or call default
  62. *m_pheaderhwnd = 0;
  63. CDialog::OnCancel();
  64. }