Delphi是支持回调函数的,举个例子(EnumWindows)如下
{回调函数}
function EnumerateWindows(hWnd: HWND; lParam: LPARAM): BOOL; stdcall;
var
Form1: TForm1;
implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Clear;
EnumWindows(@EnumerateWindows,0);
end;
function EnumerateWindows(hWnd: HWND; lParam: LPARAM): BOOL;
var
TheText: Array[0..255] of char;
begin
if (GetWindowText(hWnd, TheText, 255)=0) then
Form1.ListBox1.Items.Add(Format('%d = {这个窗体没有标题}',[hWnd]))
else
Form1.ListBox1.Items.Add(Format('%d = %s',[hWnd,TheText]));
Result:=TRUE;
end;
我想看了上面的例子,EnumFontFamilies的用法你应该会用了。