chore: Apply Delphi naming conventions

This commit is contained in:
Nikolaos Georgiou 2022-09-06 20:30:21 +02:00
parent 1866eb19b5
commit 91f81c941b

View File

@ -8,59 +8,59 @@ uses
Windows; Windows;
type type
TWndConsumer = procedure (wnd: HWND) of object; TWndConsumer = procedure (Wnd: HWND) of object;
procedure EnumerateChildWindows(wnd: HWND; consumer: TWndConsumer); procedure EnumerateChildWindows(Wnd: HWND; Consumer: TWndConsumer);
implementation implementation
type type
TWindowEnumerator = class TWindowEnumerator = class
private private
wnd: HWND; FWnd: HWND;
consumer: TWndConsumer; FConsumer: TWndConsumer;
class function MyEnumChildrenProc(wnd: HWND; lp: LPARAM): BOOL; static; stdcall; class function MyEnumChildrenProc(Wnd: HWND; Lp: LPARAM): BOOL; static; stdcall;
procedure Add(wnd: HWND); procedure Add(Wnd: HWND);
public public
constructor Create(wnd: HWND; consumer: TWndConsumer); constructor Create(Wnd: HWND; Consumer: TWndConsumer);
procedure Run; procedure Run;
end; end;
procedure EnumerateChildWindows(wnd: HWND; consumer: TWndConsumer); procedure EnumerateChildWindows(Wnd: HWND; Consumer: TWndConsumer);
var var
enumerator: TWindowEnumerator; Enumerator: TWindowEnumerator;
begin begin
enumerator := TWindowEnumerator.Create(wnd, consumer); Enumerator := TWindowEnumerator.Create(Wnd, Consumer);
try try
enumerator.Run; Enumerator.Run;
finally finally
enumerator.Free; Enumerator.Free;
end; end;
end; end;
constructor TWindowEnumerator.Create(wnd: HWND; consumer: TWndConsumer); constructor TWindowEnumerator.Create(Wnd: HWND; Consumer: TWndConsumer);
begin begin
Self.wnd := wnd; FWnd := Wnd;
Self.consumer := consumer; FConsumer := Consumer;
end; end;
procedure TWindowEnumerator.Run; procedure TWindowEnumerator.Run;
begin begin
EnumChildWindows(wnd, @TWindowEnumerator.MyEnumChildrenProc, LPARAM(Self)); EnumChildWindows(FWnd, @TWindowEnumerator.MyEnumChildrenProc, LPARAM(Self));
end; end;
class function TWindowEnumerator.MyEnumChildrenProc(wnd: HWND; lp: LPARAM): BOOL; static; stdcall; class function TWindowEnumerator.MyEnumChildrenProc(Wnd: HWND; Lp: LPARAM): BOOL; static; stdcall;
var var
me: TWindowEnumerator; Me: TWindowEnumerator;
begin begin
me := TWindowEnumerator(lp); Me := TWindowEnumerator(Lp);
me.Add(wnd); Me.Add(Wnd);
Result := True; Result := True;
end; end;
procedure TWindowEnumerator.Add(wnd: HWND); procedure TWindowEnumerator.Add(Wnd: HWND);
begin begin
consumer(wnd); FConsumer(wnd);
end; end;
end. end.