![]() |
| ||
| [DELPHI] how to set event procedure runtime? hi everybody, i'm going to set the procedure for OnTimer event runtime but i don't know how... i've written the following (WRONG) program, can someone help me? var Timer1: TTimer; procedure PROC(Sender: TObject); begin .. end; begin Timer1.Create(Timer1) ; Timer1.Interval := 2000; Timer1.OnTimer := PROC; end; |
| ||
| Re: [DELPHI] how to set event procedure runtime? Quote:
see, from the help: type TNotifyEvent = procedure (Sender: TObject) of object;think it like a procedure of a object. So, your procedure must be declared into your form class definition, on this case: ...Now, You must adjust your code above: varobserve that parameter passed to Create methode from TTimer must be the Owner them. I suggest you to pass nil (no owner) or MainForm - it's more prudent. Bye |
| ||
| Re: [DELPHI] how to set event procedure runtime? thanks a lot Micheus, very interesting. however, for this project, i've not any form, i do use only program source code, like this: program myprg; begin ... end. in thi case how can i modify your suggestion? thanks |
| ||
| Re: [DELPHI] how to set event procedure runtime? Maybe i've found the solution to my problem using API function SetTimer with TimerProc CALLBACK but i do not know how i can use it...i need an example to follow... UINT SetTimer( HWND hWnd, // handle of window for timer messages UINT nIDEvent, // timer identifier UINT uElapse, // time-out value TIMERPROC lpTimerFunc // address of timer procedure ); VOID CALLBACK TimerProc( HWND hwnd, // handle of window for timer messages UINT uMsg, // WM_TIMER message UINT idEvent, // timer identifier DWORD dwTime // current system time ); to execute every 2000 msec my procedure TMyTimer.TimerEvent(Sender:TObject) i'm trying to use this statement: SetTimer(0, 0, 2000, addr(Timer1.TimerEvent(Timer1))); but i get this error: VARIABLE REQUIRED ???!?!?!? where? when? why? AAAAAHHHHHHHHHHHHHHHH help me please!!!! |
| ||
| Re: [DELPHI] how to set event procedure runtime? Quote:
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;I hope this help you. |
| ||
| Re: [DELPHI] how to set event procedure runtime? Micheus I L-O-V-E Y-O-U !!!!! you saved my life....is it enaugh? ;)) the last question: is it possible to launch console application like an icon on taskbar? or iconized? thanks a lot!!!! |
| ||
| Re: [DELPHI] how to set event procedure runtime? Quote:
Put a icon in systray will exige a window handle to interaction with your application (I think). Is possoble create a invisible window to do this but I haven't a sample to you. Search for AllocateHWnd and Shell_NotifyIcon. Bye |
| ||
| Re: [DELPHI] how to set event procedure runtime? thanks a lot again |
| ||
| Re: [DELPHI] how to set event procedure runtime? Meby this way... var Timer1: TTimer; procedure TForm1.PROC(Sender: TObject); begin .. end; begin Timer1 := TTimer.Create(NIL) ; Timer1.Interval := 2000; Timer1.OnTimer := PROC; Timer1.Enabled := True; end; |
| All times are GMT -4. The time now is 2:16 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC