vc++树状控件(TreeCtrl)用法

/添加树状/

HTREEITEM hItem,hChildItem; //定义树状控件的句柄
CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_TREE);//定义一个树状控件的指针指向ID为IDC_TREE的树状控件
hItem = pTree->GetRootItem();//获取树状控件的根节点,赋给句柄hItem  (这里假设“根”下面是“父节点”,“父”下面是“子节点”)
//矩阵ID
int intMatrixID  = InsertMatrixDlg.m_InsertMatrixID;
char sTemid[100]; 
itoa(intMatrixID,sTemid,10);
sID = sTemid;
sID = "北京(ID."+sID+")";
hChildItem= pTree->InsertItem(sID.c_str(),NULL,NULL,hItem);//将hChildItem句柄指向根节点hItem的下级节点,并给这个下级节点命名字符串sID
//创建时间
sCreatTime = InsertMatrixDlg.m_InsertTime;
sCreatTime = "创建时间:" + sCreatTime;
pTree->InsertItem(sCreatTime.c_str(),NULL,NULL,hChildItem);//在父节点hChildItem(单词与假设的没有匹配)下添加子节点,并给子节点命名字符串sCreatTime
//地址
string temp;
temp = InsertMatrixDlg.m_InsertMatrixIP;
char sTemPort[100]; 
itoa(InsertMatrixDlg.m_InsertMatrixPort,sTemPort,10);
sMatrixAdd ="地址:" + temp + ":" + sTemPort;
pTree->InsertItem(sMatrixAdd.c_str(),NULL,NULL,hChildItem);//(添加子节点的兄弟节点)在父节点hChildItem(单词与假设的没有匹配)下添加子节点,并给子节点命名字符串sTemPort
//类型
if (InsertMatrixDlg.m_InsertType == 0 )
{
	sType = "类型:XG-1200平台";
	pTree->InsertItem(sType.c_str(),NULL,NULL,hChildItem);//(添加子节点的兄弟节点)
}
else if (InsertMatrixDlg.m_InsertType == 1 )
{
	sType = "类型:中威平台";
	pTree->InsertItem(sType.c_str(),NULL,NULL,hChildItem);//(添加子节点的兄弟节点)
}
else if (InsertMatrixDlg.m_InsertType == 2 )
{
	sType = "类型:中创平台";
	pTree->InsertItem(sType.c_str(),NULL,NULL,hChildItem);//(添加子节点的兄弟节点)
}
//端口
char sRet1[100],sRet2[100]; 
itoa(m_iniFile.m_nMatPort,sRet1,10);
itoa(InsertMatrixDlg.m_InsertMatrixPort,sRet2,10);
sPort = "端口:";
sPort = sPort + sRet2;
sPort = sPort +"-"+sRet1;
pTree->InsertItem(sPort.c_str(),NULL
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值