ClipUnit.pas
资源名称:srmsrc.zip [点击查看]
上传用户:tj00001
上传日期:2007-01-07
资源大小:672k
文件大小:2k
源码类别:
行业应用
开发平台:
Delphi
- //---------------------------------------------------------------------------
- //(R)CopyRight KivenSoft International ,inc 1999
- //单元名称:剪贴单元
- //程序名称:电子书库
- //作 者:李会文
- //开始时间:1999.07.07
- //最后修改:1999.07.07
- //备注:此单元定义了树形视图中进行剪贴的方式
- //---------------------------------------------------------------------------
- unit ClipUnit;
- interface
- uses
- Windows,CommCtrl, Classes, ComCtrls;
- type
- TSrmClip=class
- private
- FNode:TTreeNode;
- FMode:integer;
- public
- constructor Create;
- procedure Cut(ANode:TTreeNode); //剪切该标题
- procedure Copy(ANode:TTreeNode); //拷贝该标题
- procedure Paste(ANode:TTreeNode); //粘贴该标题
- property Node:TTreeNode read FNode;
- property Mode:integer read FMode;
- end;
- var
- SrmClip:TSrmClip;
- implementation
- uses
- MainUnit;
- constructor TSrmClip.Create;
- begin
- FNode:=nil;
- FMode:=-1;
- end;
- procedure TSrmClip.Cut(ANode:TTreeNode); //剪切该标题
- begin
- FNode:=ANode;
- FMode:=0;
- end;
- procedure TSrmClip.Copy(ANode:TTreeNode); //拷贝该标题
- begin
- FNode:=ANode;
- FMode:=1;
- end;
- procedure TSrmClip.Paste(ANode:TTreeNode); //粘贴该标题
- var
- tmpNode:TTreeNode;
- Ms:TMemoryStream;
- Id:integer;
- begin
- if (FMode=-1) or (FNode=nil) then exit; //无剪切或拷贝时退出
- if FMode=0 then //剪切时
- begin
- FNode.MoveTo(ANode,naAddChildFirst);
- SrmForm.TreeView.Selected:=FNode;
- end
- else if FMode=1 then
- begin
- tmpNode:=SrmForm.TreeView.Items.AddChildObjectFirst
- (ANode,FNode.Text,pointer(-1));
- tmpNode.ImageIndex:=FNode.ImageIndex;
- SrmForm.TreeView.Selected:=tmpNode;
- Srm.ReadItemHead(integer(FNode.Data));
- Ms:=TMemoryStream.Create;
- Srm.ReadItemData(Ms);
- SrmForm.RichEdit.Lines.LoadFromStream(Ms);
- Ms.Free;
- end;
- if SrmForm.TreeView.Selected.Parent=nil then Id:=0
- else Id:=integer(SrmForm.TreeView.Selected.Parent.ItemId);
- SendMessage(SrmForm.TreeView.Handle,TVM_SORTCHILDREN,0,Id);
- FMode:=-1;
- FNode:=nil;
- end;
- end.