📄 connectdlg.cpp
字号:
// ConnectDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DemoClient.h"
#include "ConnectDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CConnectDlg dialog
CConnectDlg::CConnectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CConnectDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CConnectDlg)
m_strNodeName = _T("");
m_strServerName = _T("");
m_strServerList = _T("");
m_bVer1 = FALSE;
m_bUseRegistry = FALSE;
//}}AFX_DATA_INIT
}
void CConnectDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CConnectDlg)
DDX_Control(pDX, IDC_EDIT_SERVERNAME, m_edServerName);
DDX_Control(pDX, IDC_SERVERLIST, m_lbServerList);
DDX_Text(pDX, IDC_EDIT_NODENAME, m_strNodeName);
DDV_MaxChars(pDX, m_strNodeName, 18);
DDX_Text(pDX, IDC_EDIT_SERVERNAME, m_strServerName);
DDV_MaxChars(pDX, m_strServerName, 40);
DDX_LBString(pDX, IDC_SERVERLIST, m_strServerList);
DDX_Check(pDX, IDC_CK_Ver1, m_bVer1);
DDX_Check(pDX, IDC_CK_REGISTRY, m_bUseRegistry);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CConnectDlg, CDialog)
//{{AFX_MSG_MAP(CConnectDlg)
ON_BN_CLICKED(ID_FIND, OnFind)
ON_LBN_DBLCLK(IDC_SERVERLIST, OnDblclkServerlist)
ON_LBN_SELCHANGE(IDC_SERVERLIST, OnSelchangeServerlist)
ON_BN_CLICKED(IDC_CK_Ver1, OnCKVer1)
ON_BN_CLICKED(IDC_CK_REGISTRY, OnCkRegistry)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConnectDlg message handlers
void CConnectDlg::OnFind()
{
// TODO: Add your control notification handler code here
CWaitCursor wait;
UpdateData();
m_lbServerList.ResetContent();
int i,nCount;
char buf[100];
if (m_bUseRegistry)
{
nCount = KOC_GetServerCount_UseRegistry(m_strNodeName);
}
else
{
nCount = KOC_GetServerCount(m_strNodeName,!m_bVer1);
}
if ( nCount == -1)
{
MessageBox("Can't get Server List. Please check your system configuration .","Error",MB_ICONSTOP);
return;
}
for (i=0;i<nCount;i++)
{
KOC_GetServerName(i,buf,100);
m_lbServerList.AddString(buf);
}
}
BOOL CConnectDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
OnFind();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CConnectDlg::OnDblclkServerlist()
{
// TODO: Add your control notification handler code here
OnOK();
}
void CConnectDlg::OnSelchangeServerlist()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//m_strServerName = m_strServerList;
m_edServerName.SetWindowText(m_strServerList);
//UpdateData(FALSE);
}
void CConnectDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData();
m_strServerName.TrimLeft();
m_strServerName.TrimRight();
m_strNodeName.TrimLeft();
m_strNodeName.TrimRight();
if (m_strServerName.IsEmpty())
{
AfxMessageBox("OPC Server Name is Empty!");
return;
}
CDialog::OnOK();
}
void CConnectDlg::OnCKVer1()
{
// TODO: Add your control notification handler code here
OnFind();
}
void CConnectDlg::OnCkRegistry()
{
// TODO: Add your control notification handler code here
OnFind();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -