Re:EnumWindows proc - where am I going wrong?
Hi all,
I am trying to produce a component that lists all running windows (a bit
like the 'Close Program' window that appears after a 3-fingered salute on
Win98. I am using EnumWindows but it doesn't appear to operate as my
reading of the Win32 help files describe. The following code is a
simplification of what I was trying, and illustrates the problem:
function EnumWindowsProcedure(TheHWind : Thandle; TheLParam : lParam) :
boolean;
begin
Form1.memo1.lines.add(inttostr(integer(TheHWind)));
result := TRUE;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
TheEnumWindowsProcPointer : pointer;
begin
Memo1.Clear;
TheEnumWindowsProcPointer := @EnumWindowsProcedure;
if EnumWindows(TheEnumWindowsProcPointer,0) then
Memo1.lines.add('completed');
end;
The button code outputs around 150 lines to the Memo (via the
EnumWindowsProcedure) but all of them have the same argument in TheHWind.
I expected a few less calls, and all with different handles.
What am I doing wrong?
Mike.