一、保存记录类型在data指针中:

procedure TForm1.getheaditems(pp:TfrxBand;hnode:THeadTreeNode;var i:Integer;var j:Integer;var zh,tmph:Integer;var tree:TTreeView);
type
Trec=record
     text:string;
     left,top,width,height:Integer;
     end;
 TPRec = ^TRec;
var
  h,lh,w,tp,lt,m,firstp:Integer;
  ht:THeadTreeNode;
  currentnode,pnode:TTreeNode;
  hh,ss,firsttext:string;
  ntrec:TPrec;
begin
  firsttext:=hnode.Text;
  ht:=hnode;
  m:=0;
  while True do
  begin
   w:=ht.Width;
   New(ntrec);
   if w>0 then
   begin
      hh:=ht.Text;
      lh:=ht.GetLevel;
      h:=ht.Height;
      if lh=1 then
         i:=0;
      //ss:='left:'+inttostr(j)+',top:'+inttostr(i)+',h:'+inttostr(h)+',w:'+inttostr(w)+',text:'+hh+',level:'+inttostr(lh);
      //Memo1.Lines.Add(ss);
      //build tree
      if lh=1 then
         currentnode:=tree.Items.Add(nil,hh)
      else
      begin
         pnode:=findtreeitem(tree,ht.Host.Text);
         currentnode:=tree.Items.AddChild(pnode,hh);
      end;
      ntrec^.text:=hh;
      ntrec^.Top:=i;
      ntrec^.Left:=j;
      ntrec^.Width:=w;
      ntrec^.Height:=h;
      currentnode.Data:=ntrec;//CreateMemoFun(pp,hh,'leftcolumns',baNone,nil,'',j, i, w, h);
      //ntrec:=TPRec(currentnode.Data);
      with ntrec^ do
      begin
           ss:='nodename:'+hh+',left:'+inttostr(left)+',top:'+inttostr(top)+',width:'+inttostr(width)+',height:'+inttostr(Height)+',level:'+inttostr(lh);
      end;
      Memo1.Lines.Add(ss);
      if m=0 then
         firstp:=i
      else
         i:=firstp;
   end else   //跳过不可见列
      w:=0;

if Assigned(ht.Child) then
    begin
       //tmph:=i;
       i:=i+h;
       getheaditems(pp,ht.Child,i,j,zh,tmph,tree);
    end else
    begin
        j:=j+w;
        zh:=i+h;
        //i:=tmph;
    end;
    ht:=ht.Next;
    m:=m+1;
    if ht.Text=firsttext then
    begin
       Break;
    end;

end;
end;

 
二、消除记录类型:
 
procedure TForm1.Button5Click(Sender: TObject);
type
Trec=record
     text:string;
     left,top,width,height:Integer;
     end;
 TPRec = ^TRec;
var
  tnode,fn:THeadTreeNode;
  level,ss:string;
  i:Integer;
begin
   with TreeView1 do
   begin
      for I := 0 to Items.Count-1 do
      begin
        level:=IntToStr(items[i].Level);
        if assigned(TPRec(items[i].Data)) then
        begin
           dispose(TPRec(items[i].Data));
           Memo1.Lines.Add('已释放指针:'+items[i].Text);
        end;
        ss:='nodename:'+items[i].Text+',level:'+level+',sn:'+inttostr(i);
        Memo1.Lines.Add(ss);
      end;
   end;
end;

在Treeview中节点的data属性中保存记录类型及其消除的办法的更多相关文章

  1. 006——VUE中的内容与属性中使用javascript表达式的方法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. js中的访问器属性中的getter和setter函数实现数据双向绑定

    嗯,之前在读js红宝书的时候,在对象那一章有介绍属性类型.第一种数据类型指的是数据属性,第二种是访问器属性.在初识vue的时候,其双向数据绑定也是基于访问器属性中的getter和setter函数原理来 ...

  3. IE8中li添加float属性,中英数字混合BUG

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. 视图中 jquery 使用data属性

    示例:<input id='username' data-id="{$val['id']}" data-userName="{$val['name']}" ...

  5. jsp <form>表单提交中如何在value属性中写表达式

    <input type="text" name="grop_id" value="<%=rs.getString(2)%>" ...

  6. 多.h项目出现的问题:使用了预编译头依然出现error LNK2005:***obj已在***obj中定义与c++ error C2011: “xxx”:“class”类型重定义解决办法

    使用了预编译头依然出现error LNK2005:***obj已在***obj中定义 造成该问题的可能性比较多,本人将在今后遇到时添加进来,今天先放出本人遇到的一种情况. 多重包含含有变量定义的.h文 ...

  7. PyQt(Python+Qt)入门:Designer组件属性编辑界面中QWidget类相关属性详解

    本文适用人员:本文比较长,适合不理解Qt Designer部件属性的人员阅读或资料查找. 声明: 1.如果有人认为本文是简单的复制粘贴+翻译而成,敬请读本文最后的后记: 2.本文为老猿Python学习 ...

  8. HTML 5:你必须知道的data属性

    原文:All You Need to Know About the HTML5 Data Attribute 译文:你必须知道HTML 5 的Data属性 译者:dwqs HTML 5的Data属性可 ...

  9. html 5实用特性之data属性

    HTML 5之前,我们必须依赖于class和rel属性来存储需要在网站中使用的数据片段,这种做法有时会在网站的外观和实用性之间产生冲突.而HTML 5 Data属性的存在就能很好满足需要. HTML5 ...

随机推荐

  1. PrincetonUniversity-Coursera 算法:算法简单介绍

    Course Overview What is this course? Intermediate-level survey course. Programming and proble solvin ...

  2. reveal end of document

     window - Preferences - Run/Debug - Console 将 Console buffer size (characters)设置大一点

  3. iOS 日志系统 本地日志打包上传到服务器

    日志系统主要包含两个部分 1.本地保存 我们知道NSLog打印的日志一般都是直接输出到控制台,开发人员可以在控制台直接看到实时打印的log,既然可以在控制台输出,那么能否将日志输出到其他地方呢,比如说 ...

  4. cp 命令 简要

    1.cp   1.log   hanDir   将1.log复制到hanDir目录中 2.cp   1.log  -i   hanDir   复制前询问是否覆盖重名文件 3.cp  -a    han ...

  5. nginx 的uri、request_uri 区别

    在nginx中有几个关于uri的变量,包括$uri $request_uri $document_uri,下面看一下他们的区别 : $request_uri: /stat.php?id=1585378 ...

  6. wps文档怎样去除广告

    安装完 WPS 之后右键—属性—打开文件夹位置(如图) 接下来进入 10.1.0.6929 文件夹内,再次进入 office6 文件夹内,找到 wpscenter 应用程序,将其删除.此应用包含定时弹 ...

  7. PHP资源,库,工具大全

    内容包括:库.框架.模板.安全.代码分析.日志.第三方库.配置工具.Web 工具.书籍.电子书.经典博文等等. 大家可以搜索其它语言,如awesome-java的https://github.com/ ...

  8. java代码实现目录结构

    今天用java代码来实现.像我们电脑盘符那样的目录结构.在代码开始之前首先.介绍一下.用.java代码实现目录的思想. 第一步:完成基础的.大家想.我们是如何获取文件的.是不是用File类,直接就获取 ...

  9. 多媒体开发之rtp 打包发流---udp 丢包问题

    http://blog.csdn.net/acs713/article/details/19339707

  10. 细细品味大数据--初识hadoop

    初识hadoop 前言 之前在学校的时候一直就想学习大数据方面的技术,包括hadoop和机器学习啊什么的,但是归根结底就是因为自己太懒了,导致没有坚持多长时间,加上一直为offer做准备,所以当时重心 ...