📄 set3view.cpp
字号:
// Set3View.cpp : implementation file
//
#include "stdafx.h"
#include "CDMS.h"
#include "Set3View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSet3View
IMPLEMENT_DYNCREATE(CSet3View, CFormView)
CSet3View::CSet3View()
: CFormView(CSet3View::IDD)
{
//{{AFX_DATA_INIT(CSet3View)
//}}AFX_DATA_INIT
m_pMainFrame = NULL;
InitCobArray();
}
CSet3View::~CSet3View()
{
}
void CSet3View::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSet3View)
DDX_Control(pDX, IDC_STATIC2, m_cMP2);
DDX_Control(pDX, IDC_STATIC1, m_cMP1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSet3View, CFormView)
//{{AFX_MSG_MAP(CSet3View)
ON_WM_PAINT()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSet3View diagnostics
#ifdef _DEBUG
void CSet3View::AssertValid() const
{
CFormView::AssertValid();
}
void CSet3View::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSet3View message handlers
void CSet3View::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
/*----隐藏滚动条----*/
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 0;
SetScrollSizes(MM_TEXT, sizeTotal);
/*----隐藏滚动条----*/
//<-------------获取主框架指针------------->
m_pMainFrame = (CMainFrame*)AfxGetMainWnd();
//<-------------保存窗口指针------------->
m_pMainFrame->m_hViewSet3 = this->m_hWnd;
for(int i=0;i<2;i++)
{
((CLabel*)m_staticArray.GetAt(i))->ShowWindow(FALSE);
}
}
void CSet3View::InitCobArray()
{
m_staticArray.SetSize(2);
m_staticArray.SetAt(0,&m_cMP1);
m_staticArray.SetAt(1,&m_cMP2);
}
void CSet3View::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
// TODO: Add your specialized code here and/or call the base class
if(bActivate)
{
//设置当前活动视图标志
m_pMainFrame->SetCurActiveView(VIEW_TYPE_SET3);//
}
CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
LRESULT CSet3View::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
switch(message)
{
case UM_ACTIVATE_VIEW3:
this->GetParentFrame()->ActivateFrame();
break;
case UM_COLLECTCOMPLETE:
for(int i=0; i<1024; i++)
{
m_nData[i] = m_pMainFrame->m_nOriginalData[2][i];
}
DrawBackgroundOfTimeDomainWave();
break;
}
return CFormView::WindowProc(message, wParam, lParam);
}
void CSet3View::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
DrawBackgroundOfTimeDomainWave(); //画时域波形背景
// Do not call CFormView::OnPaint() for painting messages
}
//画时域波形背景
void CSet3View::DrawBackgroundOfTimeDomainWave()
{
CWnd* pWnd = (CWnd*)GetDlgItem(IDC_SET3TIME);
CDC *pDC = pWnd->GetDC();
CRect rect;
pWnd->GetClientRect(rect);
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
CBitmap *oldBitmap;
oldBitmap=dcMemory.SelectObject(&(((CCDMSApp*) AfxGetApp())->m_BlackBitmap));
CPen *oldPen;
oldPen=dcMemory.SelectObject(&(((CCDMSApp*) AfxGetApp())->m_GrayPen));
dcMemory.FillRect(&rect,&(((CCDMSApp*) AfxGetApp())->m_BlackBrush));
double x,y;
x=rect.Width()/8.0;
y=rect.Height()/4.0;
for(int i=1;i<11;i++)
{
dcMemory.MoveTo((int)(x*i),0);
dcMemory.LineTo((int)(x*i),rect.Height());
}
for( i=0;i<2;i++)
{
dcMemory.MoveTo(0,rect.Height()/2-(int)(y*i));
dcMemory.LineTo(rect.Width(),rect.Height()/2-(int)(y*i));
dcMemory.MoveTo(0,rect.Height()/2+(int)(y*i));
dcMemory.LineTo(rect.Width(),rect.Height()/2+(int)(y*i));
}
dcMemory.SelectObject(&(((CCDMSApp*) AfxGetApp())->m_GreenPen));
dcMemory.MoveTo(0,(int)m_nData[0]);
for( i = 0; i<1024; i++ )
{
dcMemory.LineTo(4*i,(int)m_nData[i]);
}
pDC->BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&dcMemory,0,0,SRCCOPY);
dcMemory.SelectObject(oldPen);
dcMemory.SelectObject(oldBitmap);
pWnd->ReleaseDC(pDC);
::DeleteObject(&oldPen);
::DeleteObject(&oldBitmap);
}
void CSet3View::OnDestroy()
{
m_pMainFrame->m_hViewSet3 = NULL;
CFormView::OnDestroy();
// TODO: Add your message handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -