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

📄 outputbar.cpp

📁 此文件为VC++开发环境下的OPC client trend 源代码
💻 CPP
字号:
/////////////////////////////////////////////////////////////////////////////
//
//  OPC Trend VC++ Client:	OutputBar.cpp
//							(Source File)
//
/////////////////////////////////////////////////////////////////////////////
//
//          Author: Raphael Imhof
//    Initial Date: 11/04/98
//       $Workfile: OutputBar.cpp $
//       $Revision: 1 $
//           $Date: 7/27/99 5:24p $
//   Target System: Microsoft Windows NT 4.0
//     Environment: Visual C++ 5.0 / OPC DataAccess 1.0 / 2.0
//         Remarks: 
//
/////////////////////////////////////////////////////////////////////////////
//
//     Description: implementation of the COutputBar class.
//					Coolbar content (rich edit).
//					
//
/////////////////////////////////////////////////////////////////////////////
//
//  History of Changes     (Please remove very old comments and blank lines!)
//            $Log: /IDK/OPCServer/clients/VC++/Trend/OutputBar.cpp $
// 
// 1     7/27/99 5:24p Imhof
// 
// 1     7/27/99 5:20p Imhof
// 
// 5     1/15/99 7:04p Imhof
// Updated legal notice.
// 
// 4     11/06/98 5:53p Imhof
// Added header, comment and made some small code changes.
// 
// 
//  $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 "Trend.h"
#include "OutputBar.h"


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

/////////////////////////////////////////////////////////////////////////////
// COutputBar dialog


COutputBar::COutputBar(CWnd* pParent /*=NULL*/)
	: CDialog(COutputBar::IDD, pParent)
{
	//{{AFX_DATA_INIT(COutputBar)
	//}}AFX_DATA_INIT
	AfxInitRichEdit();
}


void COutputBar::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COutputBar)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COutputBar, CDialog)
	//{{AFX_MSG_MAP(COutputBar)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COutputBar message handlers

void COutputBar::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	CRect sz;
	GetClientRect(sz);
	sz.DeflateRect(5,5);
	
	CRichEditCtrl* pedRich = (CRichEditCtrl*) GetDlgItem(IDC_OUTPUTBAR_RICHEDIT);

	if(pedRich != NULL)
	{
		if(pedRich->m_hWnd != NULL)
			pedRich->MoveWindow(sz);
	}
}

void COutputBar::DisplayText(CString sText)
{			
	try
	{
		CRichEditCtrl* pedRich = (CRichEditCtrl*) GetDlgItem(IDC_OUTPUTBAR_RICHEDIT);
		if(NULL != pedRich)
		{
			sText += _T("\n"); //new line
			pedRich->ReplaceSel(sText, FALSE);
		}
		else
		{
			CString sApp;
			sApp.LoadString(AFX_IDS_APP_TITLE);
			::MessageBox(0, sText, sApp, MB_OK | MB_ICONEXCLAMATION);
		}
	}
	catch(...)
	{
		CString sApp;
		sApp.LoadString(AFX_IDS_APP_TITLE);
		
		::MessageBox(0, _T("Exception in COutputBar::DisplayText(CString sText)."), sApp, MB_OK | MB_ICONEXCLAMATION);

		::MessageBox(0, sText, sApp, MB_OK | MB_ICONEXCLAMATION);
	}
}

void COutputBar::DisplayText(CString sText, HRESULT hr)
{
	CString sError;
	if(COutputBar::GetErrorText(hr, sError))
	{
		sText = sText + _T(" returned: ") + sError;
		DisplayText(sText);
	}
}

void COutputBar::DisplayText(HRESULT hr)
{
	CString sError;
	if(COutputBar::GetErrorText(hr, sError))
	{
		DisplayText(sError);
	}
}

BOOL COutputBar::GetErrorText(HRESULT hr, CString& sText)
{
	CTrendApp* pApp = (CTrendApp*) AfxGetApp();
	
	if(!pApp->GetInfoServer()->GetErrorString(hr, sText))
	{
		sText = _T("Unknown error.");
	}
	
	return TRUE;

}

⌨️ 快捷键说明

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