I want to extend TTimer’s functionality by inserting an option how manny times the timer can execute.
My problem is that i need to do this inside the OnTimer() event. Is there a way i can override this event thus keeping it original functionality ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Most good components have a protected virtual or dynamic method that does nothing but call the corresponding event. That way, descendants can insert their own event-related code while still leaving the actual event available for the end user of the component when it’s placed on a form.
In the case of
TTimer, the method that invokes theOnTimerevent isTimer. Create a descendant ofTTimerand override that method. Check how many times you’ve already called the function, and if you’re still below the limit, then callinherited.