Originally Posted by
mfran2002
however, for this project, i've not any form, i do use only program source code
mfran2002, You can use SetTimer API function to do this and pass 0 (null) to function in
hwnd param.
But is necessary that You use the GetMessage and DispatchMessage API's functions in order to keep message windows system unchanged.
You can test this sample:
program AppTimer;
{$APPTYPE CONSOLE}
uses
Dialogs,
Windows, WinTypes;
var
Counter :Integer;
// callback function for Timer
procedure TimerProc(wnd :HWND; // handle of window for timer messages
uMsg :UINT; // WM_TIMER message
idEvent :UINT; // timer identifier
dwTime :DWORD // current system time
); stdcall; // use stdcall when declare callback functions
begin
Inc(Counter);
WriteLn('OnTimer passed...', Counter);
end;
var
Number :Integer;
TimeHandle :UINT;
Msg :TMSG;
begin
Counter := 0;
TimeHandle := SetTimer(0, 0, 1000, @TimerProc);
if TimeHandle > 0 then
try
while (Counter < 10) do
begin
GetMessage(Msg, 0, 0, 0);
DispatchMessage(Msg);
// uncomment this code portion and see the result
// Write('Input some number: '); Readln(Number);
end;
finally
KillTimer(0, TimeHandle);
end;
end.
I hope this help you.
"It always has, at least, two ways to make one same thing. Exactly that they are certain and wrong"(Micheus)
Brazil - Blumenau