Самоучитель по Delphi 7 для профессионалов




5.6.


Приложение Mini-Registry browser А вот и весь его исходный код: 

Листинг 5.1. Приложение Mini-Registry-browser, главный модуль 

unit main;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, Grids, Outline, ComCtrls, ImgList, ExtCtrls;

type

TForml = class(TForm) 

TreeViewl: TTreeView; 

ListViewl: TListView;

  ImageListl: TImageList; 

Splitterl: TSplitter;

procedure FormCreate(Sender: TObject);

procedure TreeViewlChange(Sender: TObject; Node: TTreeNode);

procedure FormDestroy(Sender: TObject);

procedure TreeViewlExpanded(Sender: TObject; Node: TTreeNode);

procedure TreeViewlGetlmagelndex(Sender: TObject; Node: TTreeNode); 

private

{ Private declarations }

 public

{ Public declarations }

procedure ShowSubKeys(ParentNode: TTreeNode;depth: Integer);

 function GetFullNodeName(Node: TTreeNode):string;

  end;

var

Forml: TForml;

implementation

uses registry;

{$R *.DFM}

var reg : TRegistry;

procedure TForml.FormCreate(Sender: TObject);

 var root : TTreeNode;

 begin

Reg := TRegistry.Create;

 ListViewl.ViewStyle := vsReport; 

with ListViewl do 

begin

with Columns.Add do

 begin

Width := ListViewl.Width div 3-2; 

Caption := 'Name';

  end;

with Columns.Add do

 begin

Width := ListViewl.Width div 3*2-2; 

Caption := 'Value';

 end;

  end;

TreeViewl.Items.Clear;

 Reg.RootKey := HKEY_LOCAL_MACHINE;

Root := TreeViewl.Items.Add(nil,'HKEY_LOCAL_MACHINE');

 TreeViewl.Items.AddChildtroot,'');

  end;

procedure TForml.FormDestroy(Sender: TObject);

 begin

Reg.Free; 

end;

function TForml.GetFullNodeName(Node: TTreeNode):string; 

var CurNode : TTreeNode;

 begin

Result:=''; CurNode := Node;

while CurNode.Parentonil do

begin

Result:= '\'+CurNode.Text + Result; 

CurNode := CurNode.Parent;

end; 

end;

procedure TForml.TreeViewlChange(Sender: TObject; Node: TTreeNode);




Содержание  Назад  Вперед