mirror of
https://github.com/ngeor/Chameleon.git
synced 2025-12-19 09:53:43 +01:00
refactor: Move logic of populating the information tree to Results form
This commit is contained in:
parent
64ee641bd2
commit
3c412959b6
122
frmMain.pas
122
frmMain.pas
@ -51,9 +51,6 @@ type
|
|||||||
procedure GenerateDfmFile(const filename, frmname: string; wnd: HWND;
|
procedure GenerateDfmFile(const filename, frmname: string; wnd: HWND;
|
||||||
PasList: TStrings);
|
PasList: TStrings);
|
||||||
procedure GeneratePasFile(const filename, frmname: string; PasList: TStrings);
|
procedure GeneratePasFile(const filename, frmname: string; PasList: TStrings);
|
||||||
procedure GetWinInfo(wnd: HWND; ParentNode: TTreeNode);
|
|
||||||
procedure GetWinInfoStyle(wnd: HWND; ParentNode: TTreeNode);
|
|
||||||
procedure GetWinInfoExtendedStyle(wnd: HWND; ParentNode: TTreeNode);
|
|
||||||
procedure EnableSavePas;
|
procedure EnableSavePas;
|
||||||
procedure EnableWndInput;
|
procedure EnableWndInput;
|
||||||
public
|
public
|
||||||
@ -65,125 +62,10 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses frmResults, Writers, DfmEngine, StyleNames, about1;
|
uses frmResults, Writers, DfmEngine, about1;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
procedure TMainForm.GetWinInfo(wnd: HWND; ParentNode: TTreeNode);
|
|
||||||
var
|
|
||||||
len, i, cbcount: integer;
|
|
||||||
Text: PChar;
|
|
||||||
class_name: array [0..100] of char;
|
|
||||||
R1, R2: TRect;
|
|
||||||
node1, node2: TTreeNode;
|
|
||||||
childlist: TList;
|
|
||||||
EnumParams: TEnumParams;
|
|
||||||
parentWnd: HWND;
|
|
||||||
itemtext: array [0..300] of char;
|
|
||||||
begin
|
|
||||||
if not IsWindow(wnd) then
|
|
||||||
begin
|
|
||||||
Results.TreeView1.Items.AddChild(ParentNode, 'Handle = (INVALID HANDLE)');
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
childlist := TList.Create;
|
|
||||||
len := GetWindowTextLength(wnd) + 1;
|
|
||||||
GetMem(Text, len);
|
|
||||||
GetWindowText(wnd, Text, len);
|
|
||||||
GetWindowRect(wnd, R1);
|
|
||||||
Windows.GetClientRect(wnd, R2);
|
|
||||||
GetClassName(wnd, class_name, 100);
|
|
||||||
parentWnd := GetParent(wnd);
|
|
||||||
EnumParams.List := childlist;
|
|
||||||
EnumParams.ParentWnd := wnd;
|
|
||||||
EnumChildWindows(wnd, @EnumChildrenProc, integer(@EnumParams));
|
|
||||||
|
|
||||||
with Results.TreeView1.Items do
|
|
||||||
begin
|
|
||||||
AddChild(ParentNode, 'Handle = ' + IntToStr(wnd));
|
|
||||||
AddChild(ParentNode, 'Caption = ' + Text);
|
|
||||||
AddChild(ParentNode, 'Class name = ' + class_name);
|
|
||||||
AddChild(ParentNode, 'Parent Handle = ' + IntToStr(parentWnd));
|
|
||||||
GetWinInfoStyle(wnd, ParentNode);
|
|
||||||
GetWinInfoExtendedStyle(wnd, ParentNode);
|
|
||||||
node1 := AddChild(ParentNode, 'Placement');
|
|
||||||
AddChild(node1, 'Left = ' + IntToStr(R1.Left));
|
|
||||||
AddChild(node1, 'Top = ' + IntToStr(R1.Top));
|
|
||||||
AddChild(node1, 'Width = ' + IntToStr(R1.Right - R1.Left));
|
|
||||||
AddChild(node1, 'Height = ' + IntToStr(R1.Bottom - R1.Top));
|
|
||||||
AddChild(node1, 'ClientWidth = ' + IntToStr(R2.Right));
|
|
||||||
AddChild(node1, 'ClientHeight = ' + IntToStr(R2.Bottom));
|
|
||||||
if (CompareText(class_name, 'COMBOBOX') = 0) then
|
|
||||||
begin
|
|
||||||
node1 := AddChild(ParentNode, '[List Data]');
|
|
||||||
cbcount := SendMessage(wnd, CB_GETCOUNT, 0, 0);
|
|
||||||
for i := 1 to cbcount do
|
|
||||||
begin
|
|
||||||
SendMessage(wnd, CB_GETLBTEXT, i - 1, longint(@itemtext));
|
|
||||||
node2 := AddChild(node1, 'Item #' + IntToStr(i));
|
|
||||||
AddChild(node2, 'Text = ' + itemtext);
|
|
||||||
AddChild(node2, 'Data = ' +
|
|
||||||
IntToStr(SendMessage(wnd, CB_GETITEMDATA, i - 1, 0)));
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if childlist.Count > 0 then
|
|
||||||
begin
|
|
||||||
node1 := AddChild(ParentNode, 'Children information');
|
|
||||||
for i := 1 to childlist.Count do
|
|
||||||
begin
|
|
||||||
node2 := AddChild(node1, 'Child #' + IntToStr(i));
|
|
||||||
GetWinInfo(integer(childlist[i - 1]), node2);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
FreeMem(Text);
|
|
||||||
childlist.Free;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainForm.GetWinInfoStyle(wnd: HWND; ParentNode: TTreeNode);
|
|
||||||
var
|
|
||||||
style: Integer;
|
|
||||||
list: TStringList;
|
|
||||||
node1: TTreeNode;
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
style := GetWindowLong(wnd, GWL_STYLE);
|
|
||||||
list := GetWindowStyleNames(style);
|
|
||||||
|
|
||||||
with Results.TreeView1.Items do
|
|
||||||
begin
|
|
||||||
node1 := AddChild(ParentNode, 'Style');
|
|
||||||
AddChild(node1, 'Value = ' + IntToStr(style));
|
|
||||||
|
|
||||||
for i := 0 to list.Count - 1 do
|
|
||||||
AddChild(node1, list[i]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
list.Free();
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainForm.GetWinInfoExtendedStyle(wnd: HWND; ParentNode: TTreeNode);
|
|
||||||
var
|
|
||||||
style: Integer;
|
|
||||||
list: TStringList;
|
|
||||||
node1: TTreeNode;
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
style := GetWindowLong(wnd, GWL_EXSTYLE);
|
|
||||||
list := GetExtendedWindowStyleNames(style);
|
|
||||||
|
|
||||||
with Results.TreeView1.Items do
|
|
||||||
begin
|
|
||||||
node1 := AddChild(ParentNode, 'Extended Style');
|
|
||||||
AddChild(node1, 'Value = ' + IntToStr(style));
|
|
||||||
|
|
||||||
for i := 0 to list.Count - 1 do
|
|
||||||
AddChild(node1, list[i]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
list.Free();
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainForm.InformationClick(Sender: TObject);
|
procedure TMainForm.InformationClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
wnd: HWND;
|
wnd: HWND;
|
||||||
@ -200,7 +82,7 @@ begin
|
|||||||
|
|
||||||
Results.Show;
|
Results.Show;
|
||||||
Results.TreeView1.Items.Clear;
|
Results.TreeView1.Items.Clear;
|
||||||
GetWinInfo(wnd, nil);
|
Results.GetWinInfo(wnd, nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.BrowsePasClick(Sender: TObject);
|
procedure TMainForm.BrowsePasClick(Sender: TObject);
|
||||||
|
|||||||
123
frmResults.pas
123
frmResults.pas
@ -16,9 +16,10 @@ type
|
|||||||
procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
|
procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
|
||||||
procedure Savelistdata1Click(Sender: TObject);
|
procedure Savelistdata1Click(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
procedure GetWinInfoStyle(wnd: HWND; ParentNode: TTreeNode);
|
||||||
|
procedure GetWinInfoExtendedStyle(wnd: HWND; ParentNode: TTreeNode);
|
||||||
public
|
public
|
||||||
{ Public declarations }
|
procedure GetWinInfo(wnd: HWND; ParentNode: TTreeNode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -26,8 +27,9 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$R *.lfm}
|
uses DfmEngine, StyleNames;
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
procedure TResults.TreeView1Change(Sender: TObject; Node: TTreeNode);
|
procedure TResults.TreeView1Change(Sender: TObject; Node: TTreeNode);
|
||||||
begin
|
begin
|
||||||
@ -63,4 +65,119 @@ begin
|
|||||||
CloseFile(f);
|
CloseFile(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TResults.GetWinInfo(wnd: HWND; ParentNode: TTreeNode);
|
||||||
|
var
|
||||||
|
len, i, cbcount: integer;
|
||||||
|
Text: PChar;
|
||||||
|
class_name: array [0..100] of char;
|
||||||
|
R1, R2: TRect;
|
||||||
|
node1, node2: TTreeNode;
|
||||||
|
childlist: TList;
|
||||||
|
EnumParams: TEnumParams;
|
||||||
|
parentWnd: HWND;
|
||||||
|
itemtext: array [0..300] of char;
|
||||||
|
begin
|
||||||
|
if not IsWindow(wnd) then
|
||||||
|
begin
|
||||||
|
TreeView1.Items.AddChild(ParentNode, 'Handle = (INVALID HANDLE)');
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
childlist := TList.Create;
|
||||||
|
len := GetWindowTextLength(wnd) + 1;
|
||||||
|
GetMem(Text, len);
|
||||||
|
GetWindowText(wnd, Text, len);
|
||||||
|
GetWindowRect(wnd, R1);
|
||||||
|
Windows.GetClientRect(wnd, R2);
|
||||||
|
GetClassName(wnd, class_name, 100);
|
||||||
|
parentWnd := GetParent(wnd);
|
||||||
|
EnumParams.List := childlist;
|
||||||
|
EnumParams.ParentWnd := wnd;
|
||||||
|
EnumChildWindows(wnd, @EnumChildrenProc, integer(@EnumParams));
|
||||||
|
|
||||||
|
with TreeView1.Items do
|
||||||
|
begin
|
||||||
|
AddChild(ParentNode, 'Handle = ' + IntToStr(wnd));
|
||||||
|
AddChild(ParentNode, 'Caption = ' + Text);
|
||||||
|
AddChild(ParentNode, 'Class name = ' + class_name);
|
||||||
|
AddChild(ParentNode, 'Parent Handle = ' + IntToStr(parentWnd));
|
||||||
|
GetWinInfoStyle(wnd, ParentNode);
|
||||||
|
GetWinInfoExtendedStyle(wnd, ParentNode);
|
||||||
|
node1 := AddChild(ParentNode, 'Placement');
|
||||||
|
AddChild(node1, 'Left = ' + IntToStr(R1.Left));
|
||||||
|
AddChild(node1, 'Top = ' + IntToStr(R1.Top));
|
||||||
|
AddChild(node1, 'Width = ' + IntToStr(R1.Right - R1.Left));
|
||||||
|
AddChild(node1, 'Height = ' + IntToStr(R1.Bottom - R1.Top));
|
||||||
|
AddChild(node1, 'ClientWidth = ' + IntToStr(R2.Right));
|
||||||
|
AddChild(node1, 'ClientHeight = ' + IntToStr(R2.Bottom));
|
||||||
|
if (CompareText(class_name, 'COMBOBOX') = 0) then
|
||||||
|
begin
|
||||||
|
node1 := AddChild(ParentNode, '[List Data]');
|
||||||
|
cbcount := SendMessage(wnd, CB_GETCOUNT, 0, 0);
|
||||||
|
for i := 1 to cbcount do
|
||||||
|
begin
|
||||||
|
SendMessage(wnd, CB_GETLBTEXT, i - 1, longint(@itemtext));
|
||||||
|
node2 := AddChild(node1, 'Item #' + IntToStr(i));
|
||||||
|
AddChild(node2, 'Text = ' + itemtext);
|
||||||
|
AddChild(node2, 'Data = ' +
|
||||||
|
IntToStr(SendMessage(wnd, CB_GETITEMDATA, i - 1, 0)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if childlist.Count > 0 then
|
||||||
|
begin
|
||||||
|
node1 := AddChild(ParentNode, 'Children information');
|
||||||
|
for i := 1 to childlist.Count do
|
||||||
|
begin
|
||||||
|
node2 := AddChild(node1, 'Child #' + IntToStr(i));
|
||||||
|
GetWinInfo(integer(childlist[i - 1]), node2);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
FreeMem(Text);
|
||||||
|
childlist.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TResults.GetWinInfoStyle(wnd: HWND; ParentNode: TTreeNode);
|
||||||
|
var
|
||||||
|
style: Integer;
|
||||||
|
list: TStringList;
|
||||||
|
node1: TTreeNode;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
style := GetWindowLong(wnd, GWL_STYLE);
|
||||||
|
list := GetWindowStyleNames(style);
|
||||||
|
|
||||||
|
with TreeView1.Items do
|
||||||
|
begin
|
||||||
|
node1 := AddChild(ParentNode, 'Style');
|
||||||
|
AddChild(node1, 'Value = ' + IntToStr(style));
|
||||||
|
|
||||||
|
for i := 0 to list.Count - 1 do
|
||||||
|
AddChild(node1, list[i]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
list.Free();
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TResults.GetWinInfoExtendedStyle(wnd: HWND; ParentNode: TTreeNode);
|
||||||
|
var
|
||||||
|
style: Integer;
|
||||||
|
list: TStringList;
|
||||||
|
node1: TTreeNode;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
style := GetWindowLong(wnd, GWL_EXSTYLE);
|
||||||
|
list := GetExtendedWindowStyleNames(style);
|
||||||
|
|
||||||
|
with TreeView1.Items do
|
||||||
|
begin
|
||||||
|
node1 := AddChild(ParentNode, 'Extended Style');
|
||||||
|
AddChild(node1, 'Value = ' + IntToStr(style));
|
||||||
|
|
||||||
|
for i := 0 to list.Count - 1 do
|
||||||
|
AddChild(node1, list[i]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
list.Free();
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user