VC:CTreeCtrl-程序员宅基地

技术标签: 数据结构与算法  

(创建图像链表、加载位图并添加到图像链表中、创建视图控件、设置视图控件图像链表、创建要插入树视图的结构体并设置属性及获取返回的句柄作为节点继续操作。。。)

1、基本知识:

       HICON hIcon[3];

       int n;

       m_imagelist.Create(16,16,0,8,8);

       //m_imagelist.Create(32,32,0,8,8);

       hIcon[0]=AfxGetApp()->LoadIcon(IDI_ICON1);

       hIcon[1]=AfxGetApp()->LoadIcon(IDI_ICON2);

       hIcon[2]=AfxGetApp()->LoadIcon(IDI_ICON3);

       hIcon[3]=AfxGetApp()->LoadIcon(IDI_ICON4);

 

 

       for(n=0;n<4;n++)

       {

              m_imagelist.Add(hIcon[n]);

       }

       CTreeCtrl * pTree=(CTreeCtrl *)GetDlgItem(IDC_TREE1);

       pTree->SetImageList(&m_imagelist,TVSIL_NORMAL);

       TV_INSERTSTRUCT tvinsert;

       tvinsert.hParent=NULL;

       tvinsert.hInsertAfter=TVI_LAST;

       tvinsert.item.mask=TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_TEXT;

 

       //tvinsert.item.hItem=NULL;

       tvinsert.item.hItem=TVI_ROOT;

       tvinsert.item.state=0;

       tvinsert.item.stateMask=0;

       tvinsert.item.cchTextMax=6;

       tvinsert.item.iSelectedImage=3;

       tvinsert.item.cChildren=0;

       tvinsert.item.lParam=0;

       //第一层

       tvinsert.item.pszText="学校";

       tvinsert.item.iImage=0;

       HTREEITEM hDad=pTree->InsertItem(&tvinsert);

       //第二层

       tvinsert.hParent=hDad;

       tvinsert.item.pszText="计算机系";

       tvinsert.item.iImage=1;

       HTREEITEM hDad21=pTree->InsertItem(&tvinsert);

       tvinsert.item.pszText="管理系";

       HTREEITEM hDad22=pTree->InsertItem(&tvinsert);

      

       //第三层

       //第二层第一个项目的两个子项目

              tvinsert.hParent=hDad21;

       tvinsert.item.pszText="网络工程";

       tvinsert.item.iImage=2;

       HTREEITEM hDad211=pTree->InsertItem(&tvinsert);

       tvinsert.item.pszText="软件工程";

       HTREEITEM hDad212=pTree->InsertItem(&tvinsert);

       //第二层第二个项目的两个子项目

              tvinsert.hParent=hDad22;

       tvinsert.item.pszText="电子商务";

       tvinsert.item.iImage=2;

       HTREEITEM hDad221=pTree->InsertItem(&tvinsert);

       /*

                     CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);

              ASSERT(pCtrl != NULL);

 

              // Insert a root item using the structure. We must

              // initialize a TVINSERTSTRUCT structure and pass its

              // address to the call.

 

              TVINSERTSTRUCT tvInsert;

              tvInsert.hParent = NULL;

              tvInsert.hInsertAfter = NULL;

              tvInsert.item.mask = TVIF_TEXT;

              tvInsert.item.pszText = _T("United States");

 

              HTREEITEM hCountry = pCtrl->InsertItem(&tvInsert);

 

              // Insert subitems of that root. Pennsylvania is

              // a state in the United States, so its item will be a child

              // of the United States item. We won't set any image or states,

              // so we supply only the TVIF_TEXT mask flag. This

              // override provides nearly complete control over the

              // insertion operation without the tedium of initializing

              // a structure. If you're going to add lots of items

              // to a tree, you might prefer the structure override

              // as it affords you a performance win by allowing you

              // to initialize some fields of the structure only once,

              // outside of your insertion loop.

 

              HTREEITEM hPA = pCtrl->InsertItem(TVIF_TEXT,

                 _T("Pennsylvania"), 0, 0, 0, 0, 0, hCountry, NULL);

 

              // Insert the "Washington" item and assure that it is

              // inserted after the "Pennsylvania" item. This override is

              // more appropriate for conveniently inserting items with

              // images.

 

              HTREEITEM hWA = pCtrl->InsertItem(_T("Washington"),

                 0, 0, hCountry, hPA);

 

              // We'll add some cities under each of the states.

              // The override used here is most appropriate

              // for inserting text-only items.

 

              pCtrl->InsertItem(_T("Pittsburgh"), hPA, TVI_SORT);

              pCtrl->InsertItem(_T("Harrisburg"), hPA, TVI_SORT);

              pCtrl->InsertItem(_T("Altoona"), hPA, TVI_SORT);

 

              pCtrl->InsertItem(_T("Seattle"), hWA, TVI_SORT);

              pCtrl->InsertItem(_T("Kalaloch"), hWA, TVI_SORT);

              pCtrl->InsertItem(_T("Yakima"), hWA, TVI_SORT);

 

                       */

转载于:https://www.cnblogs.com/shenchao/archive/2012/10/17/2728636.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/acass424022/article/details/101929663

智能推荐

Jenkins邮件推送配置_jenkins foxmail邮件推送-程序员宅基地

文章浏览阅读1.4k次,点赞26次,收藏6次。注意认证的邮箱密码不是QQ密码而是授权码,初次设置(如果使用手机号验证)的话需要花3毛钱发送短信到腾讯进行认证才能设置,按提示操作即可。温馨提醒:为了你的帐户安全,请不要告诉他人你的授权码,更改QQ帐号密码会触发授权码过期,需要重新获取新的授权码登录。勾选:【通过发送测试邮件测试配置】,然后填入接收测试邮件的邮箱,点击【Test configuration】按钮。注意Job中配置的内容会覆盖之前system中的配置,如果缺省的话就使用system中的配置。pop.qq.com,使用SSL,端口号995。_jenkins foxmail邮件推送

文件上传下载篇(前端JSP,后端SSM),注解多多,简单明了,复制就能用。(内含源码)_jsp传到ssm-程序员宅基地

文章浏览阅读2.6w次,点赞34次,收藏65次。Echarts之柱状图动态加载数据篇我搭建好的环境,有兴趣的小伙伴可以运行看下效果(里面还有饼状图和柱状图的实现)老规矩,先上效果:前台代码:<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %><%@ taglib p..._jsp传到ssm

00000000000000000000000-程序员宅基地

文章浏览阅读819次。111事实生生死死生生死死生生死死_00000000000000000000000

Apollo自动驾驶系统概述(文末参与活动赠送百度周边)_apollo智能驾驶介绍-程序员宅基地

文章浏览阅读560次,点赞5次,收藏2次。参与活动领取奖励_apollo智能驾驶介绍

机器学习实践系列之:OpenCV光流目标跟踪_opencv光流法目标追踪-程序员宅基地

文章浏览阅读136次。我们通过计算连续帧之间的像素变化来估计物体的运动。通过使用OpenCV的光流算法,我们能够实时地跟踪视频序列中的目标。这是一个基本的目标跟踪示例,你可以根据自己的需求进行修改后的标题:机器学习实践系列之:OpenCV光流目标跟踪。在机器学习和计算机视觉的领域中,目标跟踪是一个重要的任务,它涉及到在视频序列中准确地追踪目标的位置和运动。光流是一种常用的技术,它可以通过分析连续帧之间的像素变化来估计物体的运动。我们将使用Python编程语言来编写代码,并使用OpenCV的光流算法来计算物体的运动。_opencv光流法目标追踪

MapReduce程序开发中的FileInputFormat与TextInputFormat_fileinputformat和text-程序员宅基地

文章浏览阅读7k次,点赞7次,收藏11次。2016年4月3日20:17:44 MapReduce程序开发中的FileInputFormat与TextInputFormat 在MapReduce程序的开发过程中,往往需要用到FileInputFormat与TextInputFormat,但是这两个类究竟是用来做什么的,在源代码的追踪过程中,我们会发现TextInputFormat这个类继承自FileIn_fileinputformat和text

随便推点

CentOS系统时区修改(Linux时间同步)解决系统时间与本地时间不同步_centos时间不同步-程序员宅基地

文章浏览阅读937次。CentOS系统时区修改(Linux时间同步)解决系统时间与本地时间不同步。_centos时间不同步

iview导航菜单updateOpened和updateActiveName的使用-程序员宅基地

文章浏览阅读1.7k次。先看官方文档: iview导航菜单这里主要遇到的问题有两个:1. 点击回到首页(B按钮)时需要取消选中当前选中的菜单项(全部不选中),这里用到的是updateActiveName方法2. 点击收起菜单(A按钮)时,关闭所有展开的子菜单(只展示一级菜单),这里要用到的是updateOpened方法截图如下:先看下这两个方法的文档说明,直接看不是很清楚到..._updateactivename

论文解析:区域和强度可控的GAN用于工业图像缺陷生成,数据扩充,分割_区域和强度可控的gan用于工业图像缺陷生成论文下载-程序员宅基地

文章浏览阅读2.8k次,点赞4次,收藏36次。前言论文地址:IEEE TII Region- and Strength-Controllable GAN for Defect Generation and Segmentation in Industrial Images摘要计算机视觉的深度学习 (DL) 基于海量、多样化和注释良好的训练集取得了显着的成果。 然而,很难收集涵盖所有可能特征的缺陷数据集,尤其是对于小而弱的缺陷。 因此,提出了一种缺陷区域和强度可控的缺陷图像生成方法。 被视为使用生成对抗网络 (GAN) 的图像修复,生成的缺陷区域_区域和强度可控的gan用于工业图像缺陷生成论文下载

【附源码】计算机毕业设计SSM享约拍平台_约拍小程序源码-程序员宅基地

文章浏览阅读496次。项目运行环境配置:(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。项目技术:等等组成,B/S模式 + Maven管理等等。环境需要1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可4._约拍小程序源码

pytorch Parameter 设置 可学习参数_pytorch学习一个参数-程序员宅基地

文章浏览阅读1.7w次,点赞8次,收藏51次。一般来说,pytorch 的Parameter是一个tensor,但是跟通常意义上的tensor有些不一样1)通常意义上的tensor 仅仅是数据2)而Parameter所对应的tensor 除了包含数据之外,还包含一个属性:requires_grad(=True/False)在Parameter所对应的tensor中获取纯数据,可以通过以下操作:param_d..._pytorch学习一个参数

ListView回收机制相关分析_listview 被回收了-程序员宅基地

文章浏览阅读508次。原文地址:http://www.cnblogs.com/qiengo/p/3628235.htmlListView结构关系首先理清listview的层级关系,使用Google Online Draw 画出继承关系图如下:图中单独画出Scrollview是为了说明该ViewGroup并没有自带回收机制,如果要是Scrollview显示大_listview 被回收了