The next step is to do a component, I think of a counter component, functional aspects are relatively simple, but this is not the focus of this chapter, this chapter focuses on the production of a component of the entire process. In which I can learn a lot of component production skills, of course, these are also I learned from the book.
This is a component that can be counted, in order to be simple, I'm in seconds, and when it starts, he starts to increase from 0, and it shows up, by 3600, it goes back to 0, so it loops. Of course it can also stop, pause, continue. In addition, he has a time event, that is, you can set the number of times to trigger this event, which is a good feature, we can set a half-hour trigger event, in the event handler function to a sound, and then sleep, half an hour later, the voice to remind you to get up.
Instead of creating a new component unit in the first place, we used it as a class in a project to make it easier to debug, so we created a new project and created a new blank cell for the class.
First, determine the parent class:
Next to this class called Ttimecount, then its parent should be what it is, it should be able to display, have a capacity to let him show that Tpanel is a good choice, I looked at the source code, found that Tpanel did not do anything, Just to manifest the attributes of its parent class Tcustompanel (This is a wait-and-see), Tcustompanel a lot of attributes as protected, providing a choice for his subclasses, whose subclasses if they are to be seen in the object Viewer, You can make a published again, if you don't want to, you don't have to ignore him. And our counter component just doesn't need so many attributes, just right. So I decided to use Tcusompanel as the parent class.
Class is established as follows:
TTimeCount=class(TCustomPanel)
private
protected
public
published
end;
Ii. determining members, methods and properties and events
Fcount; Read-only private members, save count values
Factive:boolean; /Determine if the class's time interval event occurs