📄 mainfrm.cpp
字号:
/////////////////////////////////////////////////////////////////////////////
//
// OPC DataAccess VC++ Client: MainFrm.CPP
// (Source File)
//
/////////////////////////////////////////////////////////////////////////////
//
// Author: Raphael Imhof
// Initial Date: 11/04/98
// $Workfile: MainFrm.cpp $
// $Revision: 2 $
// $Date: 5/02/01 6:32p $
// Target System: Microsoft Windows NT 4.0
// Environment: Visual C++ 5.0 / OPC DataAccess 1.0/2.0
// Remarks:
//
/////////////////////////////////////////////////////////////////////////////
//
// Description: implementation of the CMainFrame class
//
//
/////////////////////////////////////////////////////////////////////////////
//
// History of Changes (Please remove very old comments and blank lines!)
// $Log: /IDK/OPCServer/clients/VC++/InfoServerExplorer/MainFrm.cpp $
//
// 2 5/02/01 6:32p Schmickley
// Corrections to allow running under VC 6.0 debug.
//
// 1 7/27/99 5:23p Imhof
//
// 1 7/27/99 5:19p Imhof
//
// 7 2/08/99 7:21p Imhof
// Added menu item under view for show/hide the output bar.
//
// 6 1/15/99 6:43p Imhof
// Updated legal notice.
//
// 5 12/11/98 5:58p Imhof
// Made modifications for OPC 2.0.
//
// 4 11/10/98 2:20p Imhof
// Added file header's.
//
//
// $Nokeywords:$ (To avoid useless search while checking in.)
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998, Siemens Building Technologies, Inc. Landis Division
//
// SIEMENS BUILDING TECHNOLOGIES, INC. IS PROVIDING THE FOLLOWING
// EXAMPLES OF CODE AS SAMPLE ONLY.
//
// SIEMENS BUILDING TECHNOLOGIES, INC. MAKES NO REPRESENTATIONS
// OR WARRANTIES OF ANY KIND WITH RESPECT TO THE VALIDTY OF THE
// CODES OR DESIRED RESULTS AND DISCLAIMS ALL SUCH
// REPRESENTATIONS AND WARRANTIES, INCLUDING FOR EXAMPLE,
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE. SIEMENS BUILIDNG TECHNOLOGIES, INC. DOES NOT
// REPRESENT OR WARRANT THAT THE FOLLOWING CODE SAMPLES ARE
// ACCURATE, VALID, COMPLETE OR CURRENT.
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "InfoServerExplorer.h"
#include "MainFrm.h"
#include "InfoServerExplorerDoc.h"
#include "BrowserView.h"
#include "ContentView.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_MESSAGE(WM_SHUTDOWN_MSG, OnShutdownMsg)
ON_COMMAND(ID_VIEW_OUTPUT_BAR, OnViewOutputBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT_BAR, OnUpdateViewOutputBar)
//}}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.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\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 or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
//output bar
if (!m_wndOutputBar.Create(this, &m_OutPutBarDlg, CString("Output Bar"), IDD_OUTPUTBAR, CBRS_FLOAT_MULTI | CBRS_ALIGN_ANY | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
{
TRACE0("Failed to create dialogbar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndOutputBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
ShowControlBar(&m_wndOutputBar, TRUE, FALSE);
DockControlBar(&m_wndOutputBar, AFX_IDW_DOCKBAR_BOTTOM );
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFrameWnd::PreCreateWindow(cs);
}
void CMainFrame::OnViewOutputBar()
{
// TODO: Add your command handler code here
ShowControlBar(&m_wndOutputBar, (m_wndOutputBar.GetStyle() & WS_VISIBLE) == 0, FALSE);
//most common use
DockControlBar(&m_wndOutputBar, AFX_IDW_DOCKBAR_BOTTOM );
}
void CMainFrame::OnUpdateViewOutputBar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck((m_wndOutputBar.GetStyle() & WS_VISIBLE) != 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)
{
BOOL bRet = m_wndSplitter.CreateStatic(this, 1, 2);
bRet |= m_wndSplitter.CreateView(0,0, RUNTIME_CLASS(CBrowserView), CSize(260, 100), pContext);
bRet |= m_wndSplitter.CreateView(0,1, RUNTIME_CLASS(CContentView), CSize(700, 100), pContext);
return bRet;
}
CBrowserView* CMainFrame::GetBrowserView()
{
return (CBrowserView*) m_wndSplitter.GetPane(0,0);
}
CContentView* CMainFrame::GetContentView()
{
return (CContentView*) m_wndSplitter.GetPane(0,1);
}
COutputBar& CMainFrame::GetOutPutBar()
{
return m_OutPutBarDlg;
}
/////////////////////////////////////////////////////////////////////////////
// User defined messages handlers
LONG CMainFrame::OnShutdownMsg(UINT wparam ,LONG lparam)
{
const CString szMsg = _T("Server is about to shut down for the following reason: ");
//here instead of in COPCShutDownRequest::ShutdownRequest() to avoid a critical section.
CInfoServerExplorerDoc* pDoc = (CInfoServerExplorerDoc*) GetActiveDocument();
pDoc->GetInfoServer()->SetConnected(FALSE);
AfxMessageBox((LPCTSTR) (szMsg + m_sLastShutdownReason));
m_sLastShutdownReason = _T("");
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// Members
void CMainFrame::SetLastShutdownReason(LPCWSTR szReason)
{
USES_CONVERSION;
m_sLastShutdownReason = OLE2A(szReason);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -