with Win32;
with Win32.Windef;
package Callbacks is
function EnumProc (hwnd : Win32.Windef.HWND;
lParam : Win32.LPARAM) return Win32.BOOL;
pragma convention (STDCALL, EnumProc);
end Callbacks;
with Win32;
with Win32.Windef;
with Win32.Winuser;
with Interfaces.C;
with Text_IO;
package body Callbacks is
use type Win32.Int;
-- The function will be called for each top level window
function EnumProc (hwnd : Win32.Windef.HWND;
lParam : Win32.LPARAM) return Win32.BOOL is
nb : Win32.INT := 0;
buffer : Win32.Char_Array(1..200);
begin
nb := Win32.WinUser.GetClassName (hwnd,
Win32.Addr(buffer),
buffer'Length);
if nb /= 0 then
Text_IO.Put_Line ("ClassName = '" &
Interfaces.C.To_Ada(Win32.To_C(buffer)) &
"'");
end if;
return Win32.TRUE;
end EnumProc;
end Callbacks;
with Win32;
with Win32.WinUser;
with Callbacks;
procedure Test_EnumWindows is
res : Win32.BOOL := 0;
begin
-- Let's start enumeration of the windows
res := Win32.WinUser.EnumWindows
(lpEnumFunc => Callbacks.EnumProc'Access,
lParam => Win32.LPARAM (0));
end Test_EnumWindows;
|