MMView.cpp
资源名称:MM.zip [点击查看]
上传用户:jyxwjx
上传日期:2020-03-13
资源大小:221k
文件大小:4k
源码类别:
多显示器编程
开发平台:
Visual C++
- // MMView.cpp : CMMView 努贰胶狼 备泅
- //
- #include "stdafx.h"
- #include "MM.h"
- #include "MMDoc.h"
- #include "MMView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // CMMView
- IMPLEMENT_DYNCREATE(CMMView, CView)
- BEGIN_MESSAGE_MAP(CMMView, CView)
- // 钎霖 牢尖 疙飞涝聪促.
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- // CMMView 积己/家戈
- CMMView::CMMView()
- {
- // TODO: 咯扁俊 积己 内靛甫 眠啊钦聪促.
- }
- CMMView::~CMMView()
- {
- }
- BOOL CMMView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: CREATESTRUCT cs甫 荐沥窍咯 咯扁俊辑
- // Window 努贰胶 肚绰 胶鸥老阑 荐沥钦聪促.
- return CView::PreCreateWindow(cs);
- }
- // CMMView 弊府扁
- void CMMView::OnDraw(CDC* pDC)
- {
- CMMDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CRect rcClient;
- GetClientRect(rcClient);
- pDC->FillSolidRect(rcClient,RGB(128,128,128));
- CRect rcFull(0,0,0,0);
- CRect rcMonitor;
- MONITORINFOEX MonitorInfoEx;
- for(int i=0;i<theApp.m_infoMonitor.aryMonitors.GetCount();i++)
- {
- MonitorInfoEx=((MONITORINFOEX)theApp.m_infoMonitor.aryMonitors.GetAt(i));
- rcMonitor=MonitorInfoEx.rcMonitor;
- rcFull.UnionRect(rcFull,rcMonitor);
- }
- int nWidth=rcClient.Width()*2/3;
- int nHeight=rcClient.Height()*2/3;
- double fW=double(nWidth)/rcFull.Width();
- double fH=double(nHeight)/rcFull.Height();
- double fZ;
- if(rcClient.Height()>rcClient.Width())
- {
- if(rcFull.Height()>rcFull.Width())
- {
- fZ = min(fW,fH);
- }
- else
- {
- fZ = fW;
- }
- }
- else
- {
- if(rcFull.Height()>rcFull.Width())
- {
- fZ = fH;
- }
- else
- {
- fZ = min(fW,fH);
- }
- }
- int nLeft=(rcClient.Width()-rcFull.Width()*fZ)/2;
- int nTop=(rcClient.Height()-rcFull.Height()*fZ)/2;
- CRect rcDraw;
- CRect rcDraw2;
- CString strText;
- for(int i=0;i<theApp.m_infoMonitor.aryMonitors.GetCount();i++)
- {
- MonitorInfoEx=((MONITORINFOEX)theApp.m_infoMonitor.aryMonitors.GetAt(i));
- rcMonitor=MonitorInfoEx.rcMonitor;
- rcDraw.left=rcMonitor.left*fZ;
- rcDraw.top=rcMonitor.top*fZ;
- rcDraw.right=rcDraw.left+rcMonitor.Width()*fZ;
- rcDraw.bottom=rcDraw.top+rcMonitor.Height()*fZ;
- rcDraw.OffsetRect(nLeft,nTop);
- pDC->Rectangle(rcDraw);
- rcDraw.DeflateRect(2,2);
- int nOldMode=pDC->SetBkMode(TRANSPARENT);
- strText.Format("(%d,%d)",rcMonitor.left,rcMonitor.top);
- pDC->DrawText(strText,rcDraw,DT_LEFT|DT_TOP|DT_SINGLELINE);
- strText.Format("(%d,%d)",rcMonitor.right,rcMonitor.bottom);
- pDC->DrawText(strText,rcDraw,DT_RIGHT|DT_BOTTOM|DT_SINGLELINE);
- strText.Format("%drn(%d,%d)",i+1,rcMonitor.Width(),rcMonitor.Height());
- pDC->DrawText(strText,rcDraw2,DT_CALCRECT);
- rcDraw.OffsetRect(0,-(rcDraw2.Height()+5));
- pDC->DrawText(strText,rcDraw,DT_CENTER|DT_VCENTER);
- pDC->SetBkMode(nOldMode);
- }
- }
- // CMMView 牢尖
- BOOL CMMView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // 扁夯利牢 霖厚
- return DoPreparePrinting(pInfo);
- }
- void CMMView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: 牢尖窍扁 傈俊 眠啊 檬扁拳 累诀阑 眠啊钦聪促.
- }
- void CMMView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: 牢尖 饶 沥府 累诀阑 眠啊钦聪促.
- }
- // CMMView 柳窜
- #ifdef _DEBUG
- void CMMView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CMMView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CMMDoc* CMMView::GetDocument() const // 叼滚弊登瘤 臼篮 滚傈篮 牢扼牢栏肺 瘤沥邓聪促.
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMMDoc)));
- return (CMMDoc*)m_pDocument;
- }
- #endif //_DEBUG
- // CMMView 皋矫瘤 贸府扁