Procedure DefineProperties (Filer: TFiler); Override.
Procedure TMyTimer. DefineProperties (Filer: TFiler);
The begin
Inherited;
Filer. DefineProperty (' MyProperty 'LoadProperty StoreProperty, true);
//LoadProperty and StoreProperty based on function parameters
end;
//in DefineProperties method needs a variable function as a parameter,
Procedure StoreProperty (Writer: TWriter);
Procedure TMyTimer. StoreProperty (Writer: TWriter);
The begin
Writer. WriteInteger (FInterval);
Writer. WriteInteger (FResolution);
Writer. WriteBoolean (FEnabled);
Three protection fields//persistent variables
end;
//in DefineProperties approach requires a read variable function as a parameter,
Procedure LoadProperty (Reader: TReader);
Procedure TMyTimer. LoadProperty (Reader: TReader);
The begin
FInterval:=reader. ReadInteger;
FResolution:=reader. ReadInteger;
Fenabled:=reader. ReadBoolean;
Hirestimer1. Interval:=FInterval;
Hirestimer1. Resolution:=FResolution;
Hirestimer1. Enabled:=FEnabled;
//read the attribute value
end;
//when the attribute value change, modify HiResTimer1 controls the corresponding attribute values,
The function TMyTimer. Get_Enabled: WordBool;
The begin
Result:=FEnabled;
end;
Procedure TMyTimer. Set_Enabled (Value: WordBool);
The begin
FEnabled:=Value;
Hirestimer1. Enabled:=FEnabled;
.//set hirestimer1 Enabled to determine whether the timer,
end;
The function TMyTimer. Get_Interval: Integer;
The begin
Result:=Finterval;
end;
The function TMyTimer. Get_Resolution: Integer;
The begin
Result:=Fresolution;
end;
Procedure TMyTimer. Set_Interval (Value: Integer);
The begin
Finterval:=value;
Hirestimer1. Interval:=Finterval;
//hirestimer1. The effect of the Interval and VB comes, the features of the Timer Timer Interval attribute
end;
Procedure TMyTimer. Set_Resolution (Value: Integer);
The begin
Fresolution:=value;
Hirestimer1. Resolution:=Fresolution;
//hirestimer1. Ensure the accuracy of timer Resolution attributes, the smaller the numerical accuracy is higher,
end;
After adding the attribute, but also to join in the IMyTimerEvents Ontimer event, first defined in the private section a TimerEvent function, and then Initialize the program segment let HiResTimer1. Ontimer=TimerEvent; . And in the event of an TimerEvent call FEvents OnTimer, so you can in the OnTimer event capture to HiResTimer1. The OnTimer event, program implementation is as follows:
Procedure TMyTimer. The Initialize;
The begin
Inherited the Initialize.
HiResTimer1. OnTimer:=TimerEvent;
end;
Procedure TMyTimer. TimerEvent (Sender: TObject);
The begin
If FEvents & lt;> Nil then FEvents. OnTimer;
end;
4. Because we want to write is a non-visual Activex controls, so controls in VB development environment should also have the following characteristics such as: control in designtime size should be fixed and can be seen, but not visible during runtime, the following code can be realized fixed dimensions:
The constructor Create (AOwner: TComponent); Override.
The constructor TMyTimer. Create (AOwner: TComponent);
The begin
Self. AutoSize:=true;
Inherited the create (aowner);
Self. Width:=32;
Self. Height:=32;
Self. Constraints. MaxHeight:=32;
Self. Constraints. MaxWidth:=32;
Self. Constraints. MinHeight:=32;
Self. Constraints. MinWidth:=32;
end;
The following lines of code ActiveX control can be realized when designtime visible and invisible when the runtime functions,
TActiveFormFactory. Create (
ComServer,
TActiveFormControl,
TMyTimer,
Class_MyTimer,
1,
DCC ` b151a 97-9 d6f - 4 - BAA8 - E4B51D2DD68B} `
OLEMISC_INVISIBLEATRUNTIME,//modified
//OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL, default parameter
TmApartment);
CodePudding user response:
Under the urgent hope to be able to help, in c + + builder written in c + +CodePudding user response:
Hurry come some places not intelligent white inside