MMView.cpp
上传用户:jyxwjx
上传日期:2020-03-13
资源大小:221k
文件大小:4k
源码类别:

多显示器编程

开发平台:

Visual C++

  1. // MMView.cpp : CMMView 努贰胶狼 备泅
  2. //
  3. #include "stdafx.h"
  4. #include "MM.h"
  5. #include "MMDoc.h"
  6. #include "MMView.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #endif
  10. // CMMView
  11. IMPLEMENT_DYNCREATE(CMMView, CView)
  12. BEGIN_MESSAGE_MAP(CMMView, CView)
  13. // 钎霖 牢尖 疙飞涝聪促.
  14. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  15. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  16. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  17. END_MESSAGE_MAP()
  18. // CMMView 积己/家戈
  19. CMMView::CMMView()
  20. {
  21. // TODO: 咯扁俊 积己 内靛甫 眠啊钦聪促.
  22. }
  23. CMMView::~CMMView()
  24. {
  25. }
  26. BOOL CMMView::PreCreateWindow(CREATESTRUCT& cs)
  27. {
  28. // TODO: CREATESTRUCT cs甫 荐沥窍咯 咯扁俊辑
  29. // Window 努贰胶 肚绰 胶鸥老阑 荐沥钦聪促.
  30. return CView::PreCreateWindow(cs);
  31. }
  32. // CMMView 弊府扁
  33. void CMMView::OnDraw(CDC* pDC)
  34. {
  35. CMMDoc* pDoc = GetDocument();
  36. ASSERT_VALID(pDoc);
  37. CRect rcClient;
  38. GetClientRect(rcClient);
  39. pDC->FillSolidRect(rcClient,RGB(128,128,128));
  40. CRect rcFull(0,0,0,0);
  41. CRect rcMonitor;
  42. MONITORINFOEX MonitorInfoEx;
  43. for(int i=0;i<theApp.m_infoMonitor.aryMonitors.GetCount();i++)
  44. {
  45. MonitorInfoEx=((MONITORINFOEX)theApp.m_infoMonitor.aryMonitors.GetAt(i));
  46. rcMonitor=MonitorInfoEx.rcMonitor;
  47. rcFull.UnionRect(rcFull,rcMonitor);
  48. }
  49. int nWidth=rcClient.Width()*2/3;
  50. int nHeight=rcClient.Height()*2/3;
  51. double fW=double(nWidth)/rcFull.Width();
  52. double fH=double(nHeight)/rcFull.Height();
  53. double fZ;
  54. if(rcClient.Height()>rcClient.Width())
  55. {
  56. if(rcFull.Height()>rcFull.Width())
  57. {
  58. fZ = min(fW,fH);
  59. }
  60. else
  61. {
  62. fZ = fW;
  63. }
  64. }
  65. else
  66. {
  67. if(rcFull.Height()>rcFull.Width())
  68. {
  69. fZ = fH;
  70. }
  71. else
  72. {
  73. fZ = min(fW,fH);
  74. }
  75. }
  76. int nLeft=(rcClient.Width()-rcFull.Width()*fZ)/2;
  77. int nTop=(rcClient.Height()-rcFull.Height()*fZ)/2;
  78. CRect rcDraw;
  79. CRect rcDraw2;
  80. CString strText;
  81. for(int i=0;i<theApp.m_infoMonitor.aryMonitors.GetCount();i++)
  82. {
  83. MonitorInfoEx=((MONITORINFOEX)theApp.m_infoMonitor.aryMonitors.GetAt(i));
  84. rcMonitor=MonitorInfoEx.rcMonitor;
  85. rcDraw.left=rcMonitor.left*fZ;
  86. rcDraw.top=rcMonitor.top*fZ;
  87. rcDraw.right=rcDraw.left+rcMonitor.Width()*fZ;
  88. rcDraw.bottom=rcDraw.top+rcMonitor.Height()*fZ;
  89. rcDraw.OffsetRect(nLeft,nTop);
  90. pDC->Rectangle(rcDraw);
  91. rcDraw.DeflateRect(2,2);
  92. int nOldMode=pDC->SetBkMode(TRANSPARENT);
  93. strText.Format("(%d,%d)",rcMonitor.left,rcMonitor.top);
  94. pDC->DrawText(strText,rcDraw,DT_LEFT|DT_TOP|DT_SINGLELINE);
  95. strText.Format("(%d,%d)",rcMonitor.right,rcMonitor.bottom);
  96. pDC->DrawText(strText,rcDraw,DT_RIGHT|DT_BOTTOM|DT_SINGLELINE);
  97. strText.Format("%drn(%d,%d)",i+1,rcMonitor.Width(),rcMonitor.Height());
  98. pDC->DrawText(strText,rcDraw2,DT_CALCRECT);
  99. rcDraw.OffsetRect(0,-(rcDraw2.Height()+5));
  100. pDC->DrawText(strText,rcDraw,DT_CENTER|DT_VCENTER);
  101. pDC->SetBkMode(nOldMode);
  102. }
  103. }
  104. // CMMView 牢尖
  105. BOOL CMMView::OnPreparePrinting(CPrintInfo* pInfo)
  106. {
  107. // 扁夯利牢 霖厚
  108. return DoPreparePrinting(pInfo);
  109. }
  110. void CMMView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  111. {
  112. // TODO: 牢尖窍扁 傈俊 眠啊 檬扁拳 累诀阑 眠啊钦聪促.
  113. }
  114. void CMMView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  115. {
  116. // TODO: 牢尖 饶 沥府 累诀阑 眠啊钦聪促.
  117. }
  118. // CMMView 柳窜
  119. #ifdef _DEBUG
  120. void CMMView::AssertValid() const
  121. {
  122. CView::AssertValid();
  123. }
  124. void CMMView::Dump(CDumpContext& dc) const
  125. {
  126. CView::Dump(dc);
  127. }
  128. CMMDoc* CMMView::GetDocument() const // 叼滚弊登瘤 臼篮 滚傈篮 牢扼牢栏肺 瘤沥邓聪促.
  129. {
  130. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMMDoc)));
  131. return (CMMDoc*)m_pDocument;
  132. }
  133. #endif //_DEBUG
  134. // CMMView 皋矫瘤 贸府扁