How to pass a method as callback to a Windows API call?

Posted by Heinrich Ulbricht on Stack Overflow See other posts from Stack Overflow or by Heinrich Ulbricht
Published on 2010-05-07T10:38:37Z Indexed on 2010/05/07 11:18 UTC
Read the original article Hit count: 151

Filed under:
|

Hi,

I'd like to pass a method of a class as callback to a WinAPI function. Is this possible and if yes, how?

Example case for setting a timer:

TMyClass = class
public
  procedure TimerProc(Wnd:HWND; uMsg:DWORD; idEvent:PDWORD; dwTime:DWORD);
  procedure DoIt;
end;
[...]
procedure TMyClass.DoIt;
begin
  SetTimer(0, 0, 8, @TimerProc);  // <-???- that's what I want to do (last param)
end;

Thanks for your help!

Edit: The goal is to specify a method of this class as callback. No procedure outside the class.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about winapi