Repository navigation
Expand file tree
/
Copy pathWindowTool.pas
More file actions
71 lines (58 loc) · 1.5 KB
/
Copy pathWindowTool.pas
File metadata and controls
71 lines (58 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
unit WindowTool;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm_WINTOOL = class(TForm)
Panel1: TPanel;
Button1: TButton;
Panel2: TPanel;
ListBox1: TListBox;
Edit1: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function EnumWndProc(AWnd:HWND;AlParam:LPARAM):Boolean;stdcall;
var
Form_WINTOOL: TForm_WINTOOL;
implementation
{$R *.dfm}
function EnumWndProc(AWnd: HWND; AlParam: LPARAM):Boolean;stdcall;
var
WndCaption: array[0..254] of Char;
PID:DWORD;
begin
if IsWindowVisible(AWnd) then
begin
GetWindowThreadProcessId(AWnd,@PID);
GetWindowText(AWnd, @WndCaption, 254);
if WndCaption[0]<>chr(0) then
Form_WINTOOL.ListBox1.Items.AddObject(Format('%s',[WndCaption]),TObject(AWnd));
end;
Result := True;
end;
procedure TForm_WINTOOL.Button1Click(Sender: TObject);
begin
ListBox1.Clear ;
EnumWindows(@EnumWndProc,0);
end;
procedure TForm_WINTOOL.Button2Click(Sender: TObject);
var
AWnd: HWND;
begin
AWnd:=LongWord(ListBox1.Items.Objects[ListBox1.ItemIndex]);
SetWindowPos(AWnd,0,0,0,0,0,1);
end;
procedure TForm_WINTOOL.ListBox1Click(Sender: TObject);
begin
if ListBox1.ItemIndex=-1 then Exit;
Edit1.Text:=ListBox1.Items[ListBox1.ItemIndex];
end;
end.