📄 propdlg.cpp
字号:
// PropDlg.cpp : implementation file
//
#include "stdafx.h"
#include "VCOPCClient.h"
#include "PropDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropDlg dialog
extern void GetVarStr(VARIANT* pValue, char* buf);
CPropDlg::CPropDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPropDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPropDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CPropDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPropDlg)
DDX_Control(pDX, IDC_LIST1, m_listProp);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPropDlg, CDialog)
//{{AFX_MSG_MAP(CPropDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropDlg message handlers
BOOL CPropDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_listProp.ModifyStyle(NULL, LVS_REPORT | LVS_SORTASCENDING ,0);
m_listProp.SetExtendedStyle(LVS_EX_FULLROWSELECT);
while( m_listProp.DeleteColumn( 0 ) );
m_listProp.InsertColumn( 0, _T("ID"), LVCFMT_LEFT , 40, 0 );
m_listProp.InsertColumn( 1, _T("描述"), LVCFMT_LEFT, 160, 1 );
m_listProp.InsertColumn( 2, _T("值"), LVCFMT_RIGHT, 110, 1 );
CListCtrl& list = m_pView->GetListCtrl();
GROUPITEM* pTag = NULL;
POSITION pos = list.GetFirstSelectedItemPosition();
if ( pos )
{
int nItem = list.GetNextSelectedItem(pos);
CString strItem = list.GetItemText(nItem, 0);
pTag = (GROUPITEM*)list.GetItemData(nItem);
int nPropCount = NumberOfItemProperties(pTag->hServer, strItem);
if (nPropCount > 0)
{
for( int i = 0; i < nPropCount; ++i)
{
DWORD PropertyID;
VARTYPE vartype;
char buf[255];
GetItemPropertyDescription(pTag->hServer, i, &PropertyID,
&vartype, buf, 255);
VARIANT var;
VariantInit(&var);
ReadPropertyValue(pTag->hServer, strItem, PropertyID, &var);
CString strID = "";
strID.Format("%d", PropertyID);
int nItem = m_listProp.InsertItem(0, strID);
m_listProp.SetItemText(nItem, 1, buf);
GetVarStr(&var, buf);
m_listProp.SetItemText(nItem, 2, buf);
VariantClear(&var);
}
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -