User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 374,163 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,275 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:

[DELPHI] how to set event procedure runtime?

Join Date: Jun 2006
Location: Blumenau, Brazil
Posts: 67
Reputation: Micheus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
Micheus's Avatar
Micheus Micheus is offline Offline
Junior Poster in Training

Re: [DELPHI] how to set event procedure runtime?

  #5  
May 8th, 2008
Originally Posted by mfran2002 View Post
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:
  1. program AppTimer;
  2. {$APPTYPE CONSOLE}
  3. uses
  4. Dialogs,
  5. Windows, WinTypes;
  6.  
  7. var
  8. Counter :Integer;
  9.  
  10. // callback function for Timer
  11. procedure TimerProc(wnd :HWND; // handle of window for timer messages
  12. uMsg :UINT; // WM_TIMER message
  13. idEvent :UINT; // timer identifier
  14. dwTime :DWORD // current system time
  15. ); stdcall; // use stdcall when declare callback functions
  16. begin
  17. Inc(Counter);
  18. WriteLn('OnTimer passed...', Counter);
  19. end;
  20.  
  21. var
  22. Number :Integer;
  23. TimeHandle :UINT;
  24. Msg :TMSG;
  25. begin
  26. Counter := 0;
  27. TimeHandle := SetTimer(0, 0, 1000, @TimerProc);
  28. if TimeHandle > 0 then
  29. try
  30. while (Counter < 10) do
  31. begin
  32. GetMessage(Msg, 0, 0, 0);
  33. DispatchMessage(Msg);
  34. // uncomment this code portion and see the result
  35. // Write('Input some number: '); Readln(Number);
  36. end;
  37. finally
  38. KillTimer(0, TimeHandle);
  39. end;
  40. 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
Reply With Quote  
All times are GMT -4. The time now is 3:51 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC