ShowPhoto.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // ShowPhoto.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "dbserver.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. DEVMODE g_dm;
  43. g_dm.dmSize = sizeof(DEVMODE) ;
  44. EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&g_dm);
  45. rc=CRect(0,0,g_dm.dmPelsWidth,g_dm.dmPelsHeight-hei);
  46. MoveWindow(rc);
  47. return TRUE; // return TRUE unless you set the focus to a control
  48. // EXCEPTION: OCX Property Pages should return FALSE
  49. }
  50. extern void RectFitDes(int width, int height, CRect &rc);
  51. void ShowPhoto::OnPaint()
  52. {
  53. CPaintDC dc(this); // device context for painting
  54. // TODO: Add your message handler code here
  55. if(m_pImg)
  56. {
  57. CRect rc;
  58. GetClientRect(rc);
  59. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc);
  60. Graphics dcgraph(dc.GetSafeHdc());
  61. Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ());
  62. dcgraph.DrawImage(m_pImg, destinationRect, 0,0,m_pImg->GetWidth(), m_pImg->GetHeight(),UnitPixel);
  63. }
  64. // Do not call CDialog::OnPaint() for painting messages
  65. }