解决了datatree的‘死节点’问题

2016-02-19 21:31 5 1 收藏

有一种朋友不在生活里,却在生命力;有一种陪伴不在身边,却在心间。图老师即在大家的生活中又在身边。这么贴心的服务你感受到了吗?话不多说下面就和大家分享解决了datatree的‘死节点’问题吧。

【 tulaoshi.com - 编程语言 】

  //问题描述见 howto 一文,代码最终版本见下文

  

  //标蓝色部分为datatree所要求的,即前文提供的解决方案,但并不奏效

  procedure TScriptProperty.DataTreeDragDrop(Sender: TBaseVirtualTree;
    Source: TObject; DataObject: IDataObject; Formats: TFormatArray;
    Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode);
  var
    pnode2: PAdminNode;
    data: PInt;
    Node2: PVirtualNode;
    sql: string;

    changeList: TStringList;
    FocusNode: PVirtualNode;
    TargetNode: PVirtualNode;
    Temp:PVirtualNode;
    i: Integer;
    left,right,targe:Integer;
  begin
    Effect := DROPEFFECT_NONE;
    if (Source is TBaseVirtualTree) then
    begin
      Node2 := (Source as TBaseVirtualTree).GetFirstSelected;
      data := (Source as TBaseVirtualTree).GetNodeData(Node2);
      pnode2 := Pointer(data^);

      FocusNode := Sender.GetFirstSelected;
      TargetNode := Sender.DropTargetNode;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

      left :=LeftBracketIndex(FocusNode);
      right:=RightBracketIndex(FocusNode);
      if TargetNode nil then
        targe := TargetNode.Index
      else
        targe := -1;
      if (Source as TBaseVirtualTree).Name = 'DataTree' then
      begin
        if DataTree.DropTargetNode = nil then Exit;
        if DataTree.DropTargetNode.Index = 0 then Exit;
        changeList := TStringList.Create;

        DataTree.BeginUpdate;

  //块拖动问题

        if (left0) and (right0)and (leftLeftBracketIndex(TargetNode))and (right RightBracketIndex (TargetNode)) then  //后两个条件解决了同一块类不能移动的问题
        begin
          if  right targe then
          begin
             if (LeftStr(stringlist.Strings[targe],5)='While') or (LeftStr(stringlist.Strings[targe],3)='for') then
                Exit;
             for i:=right+ 1 to targe do
                 changeList.Add(stringlist.Strings[i]);
             for i:=left-1 to right do
                 changeList.Add(stringlist.Strings[i]);
             for i:=left-1 to targe do
                 stringlist.Strings[i]:= changeList.Strings[i-left+1];
          end;

          if  (left-1) targe then
          begin
            if (stringlist.Strings[targe]='{')  then
                exit;
            for i:=left-1 to right do
                changeList.Add(stringlist.Strings[i]);
            for i:=targe to left-2 do
                changeList.Add(stringlist.Strings[i]);
            for i:=targe to right do
                stringlist.Strings[i]:= changeList.Strings[i-targe];
          end;
        end
        else
        begin
          if FocusNode.Index TargetNode.Index then
          begin
            if (stringlist.Strings[TargetNode.Index]='{')  then
                exit;
            changeList.Add(stringlist.Strings[FocusNode.index]);
            for i:=TargetNode.Index to FocusNode.Index-1 do
                changeList.Add(stringlist.Strings[i]);
            for i:=TargetNode.Index to FocusNode.Index do
                stringlist.Strings[i]:= changeList.Strings[i-TargetNode.Index];
          end;

  //行拖动问题   

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

       if FocusNode.Index TargetNode.Index then
          begin
            if (LeftStr(stringlist.Strings[TargetNode.Index],5)='While') or (LeftStr(stringlist.Strings[TargetNode.Index],3)='for') then
                Exit;
            for i:=FocusNode.Index+1 to targetnode.Index do
                changeList.add(stringlist.Strings[i]);
            changeList.Add(stringlist.Strings[FocusNode.index]);
            for i:=FocusNode.Index to TargetNode.Index do
                stringlist.Strings[i]:= changeList.Strings[i-FocusNode.Index];
          end;
        end;
        changeList.Free;
        DataTree.EndUpdate;
      
        self.DataTree.RootNodeCount:=stringlist.Count;
        DataTree.Refresh;
        Exit;
      end
      else if pnode2.typename = 'MobileUserAgent' then
      begin
        if targe 0 then
          stringlist.Insert(targe, CreateUserAgentCode(pnode2.data))
        else
          stringlist.Append(CreateUserAgentCode(pnode2.data));
        self.DataTree.RootNodeCount:=stringlist.Count;
        DataTree.Refresh;
        Exit;
      end

  //脚本拖动问题
      else
      begin
        if application.MessageBox('Are you sure to replace current script?', 'Message', MB_OKCANCEL) = IDCancel then
          exit;

        sql := 'Select texts from systemobjects where itemid=''' + pnode2.id + '''';
        currentdatabase.ExeuteSQlQurey(pnode2, sql, @GetScriptFromDB);
        Self.SetScript(pnode2.texts);
        Exit;
      end;
    end;
  end;

  『绝对原创 飞飞于北京 2005-08-31』

来源:https://www.tulaoshi.com/n/20160219/1626399.html

延伸阅读
标签: 头屑 头发护理
解决头屑多的问题 解决头屑多的问题 1、洋葱去头屑 头屑多怎么办?我们常吃的洋葱就是一种很好的去头屑方法,如果用洋葱去头屑呢?首先我们要选择最新鲜的洋葱,因为只有新鲜的洋葱才能够剂出丰富的葱汁来。我们用小工具将洋葱捣碎,之后把捣碎的洋葱用干净的纱布包裹好,用其中的洋葱汁来擦拭头发,让洋葱汁充分地吸...
标签: flash教程
使用以下的方法,使SWF文件强制不从浏览器读本地的缓存。或强制其SWF文件每次都去 读取最新的媒体文件 确保每次都读取最新的SWF文件 。 1:使用"Expires"标头 这是在HTML文件中告诉浏览器不读取本地缓存 在<head </head 中间加以下代码 <!-- BEGIN INSERT -- <META HTTP-EQUIV="Expires" CONTENT="Mon, 04 Dec 1999...
标签: 电脑入门
我安装了Windows 98和 Windows XP 的双系统,今天系统无法正常开机了,弹出NTLDR is missing的信息,请问如何解决? NTLDR是Windows XP启动时的一个重要引导文件。上面的提示信息说明你的电脑中该文件已经丢失,可以直接从其他同版本系统中的C盘拷贝一个过来或是直接从Windows XP安装光盘中提取一个出来存放到你的C盘中即可,如果怕麻烦,直接...
标签: Web开发
在ajax发送请求前加上xmlHTTP.setRequestHeader("If-Modified-Since","0"); 在url家一个随即数什么的,我用了下,不是很好用。 具体代码如下: 以下是代码: html head titleMy first ajax programe/title meta http-equiv="Content-Type" content="text/html; charset=utf-8" script language="javascript" type="text/javascript" !--...
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.util; import java.io.UnsupportedEncodingException; import java.sql.*; /** * * @author swing */ public class DbUtility {     private Connection conn = null;     private ResultSe...

经验教程

713

收藏

68
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部