Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2008 May : How to pass a procedure (implemented within a class) to a Win32 function?
| Subject: | How to pass a procedure (implemented within a class) to a Win32 function? |
| Posted by: | "Sakis Metallidis" (sakis.metallid..@gmail.com) |
| Date: | Fri, 30 May 2008 11:27:03 |
Hi delphians,
I would like to pass a procedure which is implemented within a class to a
Win32 function.
I did it a few years ago but now I don't remember how.
Maybe some of you can help me.
If I put the procedure outside the class then I have no problem.
But I need to pass a procedure implemented within a class.
I have attached the code below.
Thanx and have a nice day
unit Form_Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function EnumWindowsFunc (Handle: THandle; lParam: LPARAM): boolean;
stdcall;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.EnumWindowsFunc(Handle: THandle; lParam: LPARAM): boolean;
begin
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Clear;
EnumWindows(@EnumWindowsFunc, 0) ;
end;
end.