fm_newname.~pas

来自「realworld source code」· ~PAS 代码 · 共 71 行

~PAS
71 行
字号
unit FM_NewName;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, xmldom, XMLIntf, msxmldom, XMLDoc, ComCtrls, RzTreeVw;

type
  TFMNewName = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FMNewName: TFMNewName;

implementation
uses
 FM_RSS;
{$R *.dfm}

procedure TFMNewName.Button1Click(Sender: TObject);

var
  ItemsParent:TTreeNode;
  XMLNode:IXMLNode;
  j,I:integer;
  SList:TStringList;
  XMLDocu1:TXMLDocument;
begin
 j:=0;
 I:=0;
 SList:=TStringList.Create;
 SList.Clear;
 ItemsParent:=FMRSS.RzTreeView2.Selected.Parent;
    j:=FMRSS.RzTreeView2.Selected.Index;
    while ItemsParent<>nil do
     begin
      SList.Add(inttostr(ItemsParent.index));
      ItemsParent:=ItemsParent.Parent;
     end;
    SList.Delete(SList.Count-1);
    XMLDocu1:=TXMLDocument.Create(self);
    XMLDocu1.FileName:=ExtractFilePath(Application.ExeName)+'Favorite.xml';
    XMLDocu1.Active:=True;
    XMLNode:=XMLDocu1.Node.ChildNodes.Nodes[0];
    if SList.Text<>'' then
     begin
      while SList.Text <>'' do
       begin
        XMLNode:=XMLNode.ChildNodes.Nodes[strtoint(SList.Strings[SList.Count-1])];
        SList.Delete(SList.Count-1);
       end;
      XMLNode.ChildNodes.Nodes[j].Attributes['Name']:=Edit1.Text;
     end
    else
      XMLNode.ChildNodes.Nodes[j].Attributes['Name']:=Edit1.Text;
   XMLDocu1.SaveToFile(ExtractFilePath(Application.ExeName)+'Favorite.xml');
   FMRSS.RzTreeView2.Selected.Text:=Edit1.Text;
   XMLDocu1.Free;
end;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?