⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 一个OPC客户端监视程序
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "OpcClientSpy.h"

#include "MainFrm.h"

#include "InfoFormView.h"
#include "TopSplitView.h"
#include "NetInfoDaDlg.h"
#include "DxPropDlg.h"
#include "AlarmEventDlg.h"
#include "ValueMsgView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(IDT_COMPUTER_LIST, OnComputerList)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	/*if (!m_wndDlgBar.Create(this, IDR_MAINFRAME, 
		CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
	{
		TRACE0("Failed to create dialogbar\n");
		return -1;		// fail to create
	}*/

	if (!m_wndReBar.Create(this) ||
		!m_wndReBar.AddBar(&m_wndToolBar) /*||
		!m_wndReBar.AddBar(&m_wndDlgBar)*/)
	{
		TRACE0("Failed to create rebar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Remove this if you don't want tool tips
	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY);

	return 0;
}


/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

//将主界面切成上下两部分。
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	//return CFrameWnd::OnCreateClient(lpcs, pContext);
	if (!m_wndSplitter.CreateStatic(this, 2, 1))
	{
		TRACE0("无法切分窗口\n");
		return FALSE;
	}
	
	CRect rect;
	GetClientRect(&rect);


	if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CTopSplitView), CSize(0, rect.Height()/3*2), pContext))
	{
		TRACE0("无法创建CTopSplitView\n");
		return FALSE;
	}

	if (!m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CInfoFormView), CSize(0,0), pContext))
	{
		TRACE0("无法创建CInfoFormView\n");
		return FALSE;
	}
	
	// Set the left pane as the active view
	CTopSplitView *pView = (CTopSplitView*)m_wndSplitter.GetPane(0, 0); 
	CServerInfoView *m_pServerInfoView = (CServerInfoView *)pView->m_leftRightSplitter.GetPane(0,0);
	SetActiveView(m_pServerInfoView);
	CValueMsgView *pValue = (CValueMsgView *)pView->m_leftRightSplitter.GetPane(0,1);
	pValue->m_pServerView = m_pServerInfoView;
	return TRUE;
}

//显示网络中资源情况
void CMainFrame::OnComputerList() 
{
	CPropertySheet info("网络中所有计算机");
	CNetInfoDaDlg netDa;
	info.AddPage(&netDa);
	CAlarmEventDlg alarmEvent;
	info.AddPage(&alarmEvent);
	CDxPropDlg dxDlg;
	info.AddPage(&dxDlg);
	info.DoModal();
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -