📄 connectdlg.cpp
字号:
// ConnectDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "SuperOPC.h"
#include "ConnectDlg.h"
#include "HotOpcServer.h"
#include ".\connectdlg.h"
// CConnectDlg 对话框
IMPLEMENT_DYNAMIC(CConnectDlg, CDialog)
CConnectDlg::CConnectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CConnectDlg::IDD, pParent)
, m_strSerName(_T(""))
, m_strRemoteName(_T(""))
{
}
CConnectDlg::~CConnectDlg()
{
}
void CConnectDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TREE2, m_trServerList);
DDX_Control(pDX, IDC_EDIT1, m_ceSerNameCtl);
DDX_Text(pDX, IDC_EDIT1, m_strSerName);
DDX_Text(pDX, IDC_EDIT2, m_strRemoteName);
}
BEGIN_MESSAGE_MAP(CConnectDlg, CDialog)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE2, OnTvnSelchangedTree2)
END_MESSAGE_MAP()
// CConnectDlg 消息处理程序
BOOL CConnectDlg::OnInitDialog()
{
CWaitCursor wc;
CDialog::OnInitDialog();
HTREEITEM hRoot = m_trServerList.InsertItem(_T("OPC DA 服务列表"));
CHotOpcServer *pServer;
pServer = new CHotOpcServer();
ASSERT(pServer);
//加1.0
int a = pServer->DisplayComponent(FALSE);
HTREEITEM hParent = m_trServerList.InsertItem(_T("OPC DA 服务1.0"),hRoot);
CString sSer = _T("");
for (int j = 0; j < a ;j++)
{
sSer = pServer->GetServerNameByIndex(j);
m_trServerList.InsertItem(sSer,hParent);
}
//加2.0
a = pServer->DisplayComponent();
hParent = m_trServerList.InsertItem(_T("OPC DA 服务2.0"),hRoot);
sSer = _T("");
for (j = 0; j < a ;j++)
{
sSer = pServer->GetServerNameByIndex(j);
m_trServerList.InsertItem(sSer,hParent);
}
//加通用
a = pServer->GetServerCount();
hParent = m_trServerList.InsertItem(_T("OPC DA 通用服务"),hRoot);
sSer = _T("");
for (j = 0; j < a ;j++)
{
sSer = pServer->GetServerNameByIndex(j);
m_trServerList.InsertItem(sSer,hParent);
}
m_strSerName = sSer;
UpdateData(FALSE);
//
SAFE_DELETE(pServer);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CConnectDlg::OnTvnSelchangedTree2(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
// see if it was a server selection (i.e, has a parent item)
// Update page is server was selected (non-NULL parent item):
if ((m_trServerList.GetParentItem (pNMTreeView->itemNew.hItem) != NULL) &&
m_trServerList.GetChildItem(pNMTreeView->itemNew.hItem) == NULL)
{
// Transfer selection to ProgID edit control:
m_strSerName = m_trServerList.GetItemText (pNMTreeView->itemNew.hItem);
// Update controls:
UpdateData (FALSE);
// Make sure selected server is visible:
m_trServerList.EnsureVisible (pNMTreeView->itemNew.hItem);
}
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -