📄 config.cpp
字号:
// Config.cpp : implementation file
//
#include "stdafx.h"
#include "LinkPLC.h"
#include "Config.h"
#include "PropPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CConfig dialog
CConfig::CConfig(CWnd* pParent /*=NULL*/)
: CDialog(CConfig::IDD, pParent)
{
//{{AFX_DATA_INIT(CConfig)
//}}AFX_DATA_INIT
}
void CConfig::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CConfig)
DDX_Control(pDX, IDC_LIST2, m_MyListCtrl_Cnt1);
DDX_Control(pDX, IDC_LIST1, m_MyListCtrl_Cnt);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CConfig, CDialog)
//{{AFX_MSG_MAP(CConfig)
ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList1)
ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST2, OnEndlabeleditList2)
ON_NOTIFY(LVN_KEYDOWN, IDC_LIST1, OnKeydownList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConfig message handlers
BOOL CConfig::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CRect rect;
m_MyListCtrl_Cnt.GetClientRect(rect);
LV_COLUMN lvcolumn;
lvcolumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
lvcolumn.fmt = LVCFMT_LEFT;
lvcolumn.pszText = "Label";
lvcolumn.iSubItem = 0;
lvcolumn.cx = rect.Width(); // SubItem is twice as large
m_MyListCtrl_Cnt.InsertColumn(0, &lvcolumn); // assumes return value is OK.
m_MyListCtrl_Cnt.SetBkColor(RGB(50,50,100));
m_MyListCtrl_Cnt.SetTextBkColor(RGB(50,50,100));
m_MyListCtrl_Cnt.SetTextColor(RGB(255,255,255));
m_MyListCtrl_Cnt1.GetClientRect(rect);
lvcolumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
lvcolumn.fmt = LVCFMT_LEFT;
lvcolumn.pszText = "Data Register";
lvcolumn.iSubItem = 0;
lvcolumn.cx = rect.Width(); // SubItem is twice as large
m_MyListCtrl_Cnt1.InsertColumn(0, &lvcolumn); // assumes return value is OK.
m_MyListCtrl_Cnt1.SetBkColor(RGB(50,50,100));
m_MyListCtrl_Cnt1.SetTextBkColor(RGB(50,50,100));
m_MyListCtrl_Cnt1.SetTextColor(RGB(255,255,255));
// CPropPage1 *mParent=(CPropPage1 *)GetParent();
for (int i=0 ; i<mItemCount ; i++)
{
m_MyListCtrl_Cnt.InsertItem(i,mComment[i]);
m_MyListCtrl_Cnt1.InsertItem(i,mDevice[i]);
}
m_MyListCtrl_Cnt.InsertItem(i,"...");
m_MyListCtrl_Cnt1.InsertItem(i,"...");
// SetWindowText("fhfdhdfhdfhdf");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CConfig::OnEndlabeleditList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
if(pDispInfo->item.iItem == mItemCount)//Chen dong
{
mComment[pDispInfo->item.iItem]=new char[100];
mDevice[pDispInfo->item.iItem]=new char[20];
mItemCount++;
m_MyListCtrl_Cnt.InsertItem(pDispInfo->item.iItem+1,"...");
m_MyListCtrl_Cnt1.InsertItem(pDispInfo->item.iItem+1,"...");
}
m_MyListCtrl_Cnt.SetItemText(pDispInfo->item.iItem,pDispInfo->item.iSubItem,pDispInfo->item.pszText);
strcpy(mComment[pDispInfo->item.iItem],pDispInfo->item.pszText);
*pResult = 0;
}
void CConfig::OnEndlabeleditList2(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
m_MyListCtrl_Cnt1.SetItemText(pDispInfo->item.iItem,pDispInfo->item.iSubItem,pDispInfo->item.pszText);
strcpy(mDevice[pDispInfo->item.iItem],pDispInfo->item.pszText);
*pResult = 0;
}
void CConfig::OnKeydownList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
if(pLVKeyDow->wVKey==VK_DELETE)
{
POSITION pos = m_MyListCtrl_Cnt.GetFirstSelectedItemPosition();
int nItem;
if (pos != NULL)//selected
{
nItem = m_MyListCtrl_Cnt.GetNextSelectedItem(pos);// get selected item
for( int i=nItem ; i<mItemCount-1 ; i++)
{
mComment[i]=mComment[i+1];
mDevice[i]=mDevice[i+1];
}
mItemCount--;
m_MyListCtrl_Cnt.DeleteItem(nItem);
m_MyListCtrl_Cnt1.DeleteItem(nItem);
}
}
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -