ShowPhoto.cpp 1.8 KB

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