📄 prjform.pas
字号:
unit PrjForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls, ExtCtrls, ToolIntf, EditIntf, ExptIntf;
type
TPrjInfoForm = class(TForm)
TreeView1: TTreeView;
ImageList1: TImageList;
procedure TreeView1DblClick(Sender: TObject);
public
UnitsNode, FormsNode: TTreeNode;
procedure UpdateTree;
function FindNode (Text: string): TTreeNode;
end;
var
PrjInfoForm: TPrjInfoForm;
const
stOpen = 1;
stClosed = 2;
// stNot = 3;
stNode = 4;
implementation
{$R *.DFM}
function TPrjInfoForm.FindNode (Text: string): TTreeNode;
var
I: Integer;
begin
Result := nil;
// scans the tree view, looking for the value
for I := 0 to TreeView1.Items.Count - 1 do
if TreeView1.Items [I].Text = Text then
begin
Result := TreeView1.Items [I];
Exit;
end;
end;
procedure TPrjInfoForm.UpdateTree;
var
I, nTot: Integer;
ChildNode: TTreeNode;
FileName: string;
begin
// set the project name in the caption
if ToolServices.GetProjectName = '' then
Caption := 'DDH Demo VCS'
else
begin
Caption := 'DDH Demo VCS - ' +
ToolServices.GetProjectName;
with TreeView1.Items do
begin
Clear;
BeginUpdate;
// add the units node
UnitsNode := AddChild (nil, 'Units');
UnitsNode.StateIndex := stNode;
// add the name of each unit/file
nTot := ToolServices.GetUnitCount;
for I := 0 to nTot - 1 do
begin
FileName := ToolServices.GetUnitName (I);
ChildNode := AddChild (UnitsNode, FileName);
// set the status icon
if ToolServices.IsFileOpen (FileName) then
ChildNode.StateIndex := stOpen
else
ChildNode.StateIndex := stClosed;
end;
// add the forms node
FormsNode := AddChild (nil, 'Forms');
FormsNode.StateIndex := stNode;
// add a node for each form
nTot := ToolServices.GetFormCount;
for I := 0 to nTot - 1 do
begin
FileName := ToolServices.GetFormName (I);
ChildNode := AddChild (FormsNode, FileName);
// set the status icon
if ToolServices.IsFileOpen (FileName) then
ChildNode.StateIndex := stOpen
else
ChildNode.StateIndex := stClosed;
end;
// post the updates
EndUpdate;
end;
// show all the items
TreeView1.FullExpand;
end;
end;
procedure TPrjInfoForm.TreeView1DblClick(Sender: TObject);
begin
// if we are selecting an actual form or unit
if TreeView1.Selected.Level = 1 then
begin
// if the file has been saved to disk
if FileExists (TreeView1.Selected.Text) then
// open it
ToolServices.OpenFile (TreeView1.Selected.Text)
else
// otherwise warn the user
MessageDlg ('The physical file still doesn''t exist',
mtError, [mbOK], 0);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -