zoukankan      html  css  js  c++  java
  • 关于ListView指针Data介绍

    赋值
    type
        PAllHidenDate = ^AllHidenDate;
        AllHidenDate = record
            PriceID: Integer;
            OrderNumber: string;
            State: Integer;
            PriceData: WideString;
        end;

    var
        HidenData: PAllHidenDate;

    begin
        with lvDataViewAll.Items.Add do
        begin

            HidenData := New(PAllHidenDate);
            HidenData.PriceID := StrToIntDef(Node.Attributes['PriceID'], 0);
            HidenData.State := StrToIntDef(Node.Attributes['State'], 1);
            HidenData.OrderNumber := Node.Attributes['PriceNumber'];
            HidenData.PriceData := Node.XML;
            Data := HidenData;
        end;
    end;

    释放Data:
    procedure TOrderQuotation.lvDataViewAllDeletion(Sender: TObject; Item:
        TListItem);
    var
        HidenData : PAllHidenDate;
    begin
        if Item.Data = nil then Exit;
        HidenData := Item.Data ;
        Dispose(HidenData);
    end;


    释放内存时需要和赋值时的指针类型相同,不然会出错内存泄漏

    PViewItemState = ^TViewItemState;
    TViewItemState = Record
      ViewItemid: Integer;
    end;

    var
      nLoop: integer;
      li: TListItem;
      pp: PViewItemState;
    begin
      for nLoop:=0 to 10 do
      begin
        li:=ListView1.items.add;
        li.caption:=IntToStr(nLoop);
        new(pp);
        li.Data:=pp;
      end;
    end;

    需释放内存

    var
    I : integer;
    begin
      for I := 0 to TreeView.Items.Count - 1 do
      begin
        Dispose(TreeView.Items[I].Data);
        TreeView.Items[I].Data := nil;
      end;
    end; 

  • 相关阅读:
    pikachu靶场-File Inclusion(文件包含漏洞)
    pikachu靶场-RCE(远程代码、命令执行漏洞)
    pikachu靶场-Sql Inject(SQL 注入)
    pikachu靶场-CSRF
    pikachu靶场-XSS
    pikachu靶场-暴力破解
    OSPF 高级配置
    OSPF 多区域配置
    动态路由 RIP
    Linux PXE + Kickstart 自动装机
  • 原文地址:https://www.cnblogs.com/mingdep/p/2313189.html
Copyright © 2011-2022 走看看