2
如何將timeSetEvent
的回調函數定義爲實例方法?常規程序/方法指針
TUDPBC = class(TObject)
private
hTimer: word;
...
public
procedure sendUDPBC;
...
end;
procedure DoTimer(uTimerID, uMessage: UINT; dwUser,dw1,dw2: DWORD); stdcall;
procedure TUDPBC.sendUDPBC; //send UDP Broadcast
begin
...
hTimer := TimeSetEvent(FTimeOut, uRes, DoTimer, 0, TIME_ONESHOT); //need DoTimer as a TUDPBC class method
...
end;
因此,'dwUser'可用於傳遞任何值,該值在計時器事件中傳回給您。這樣你就可以區分定時器。您可以使用該字段來存儲對象中的引用。 – GolezTrol