Разработка компонентов в DELPHI. Вощинская Г.Э. - 22 стр.

UptoLike

Составители: 

TEdit=class(TCustomEdit)
private
published
property OnClick;
end;
Ɍɚɤ ɤɚɤ ɫɨɛɵɬɢɹ Delphi ɨɯɜɚɬɵɜɚɸɬ ɛɨɥɶɲɭɸ ɱɚɫɬɶ ɫɨɨɛɳɟɧɢɣ Win-
dows, ɬɨ ɪɚɡɪɚɛɨɬɱɢɤɭ ɧɨɜɨɝɨ ɤɨɦɩɨɧɟɧɬɚ, ɤɚɤ ɩɪɚɜɢɥɨ, ɛɵɜɚɟɬ ɞɨɫɬɚɬɨɱɧɨ
ɨɩɭɛɥɢɤɨɜɚɬɶ ɜ ɫɜɨɟɦ ɤɨɦɩɨɧɟɧɬɟ ɫɨɛɵɬɢɹ ɩɪɟɞɤɚ.
ȼ ɛɨɥɟɟ ɫɥɨɠɧɨɣ ɫɢɬɭɚɰɢɢ, ɤɨɝɞɚ ɢɦɟɸɳɢɯɫɹ ɫɬɚɧɞɚɪɬɧɵɯ ɫɨɛɵɬɢɣ
ɧɟɞɨɫɬɚɬɨɱɧɨ, ɦɨɠɧɨ ɨɩɪɟɞɟɥɢɬɶ ɧɨɜɵɟ ɫɨɛɵɬɢɹ. Ɇɟɬɨɞɢɤɚ ɦɨɠɟɬ ɨɬɥɢ-
ɱɚɬɶɫɹ ɜ ɡɚɜɢɫɢɦɨɫɬɢ ɨɬ ɡɚɞɚɱɢ. Ɉɛɵɱɧɨ ɜ ɞɨɩɨɥɧɟɧɢɟ ɤ ɨɛɴɹɜɥɟɧɢɸ ɩɨɥɹ
ɢ ɫɜɨɣɫɬɜɚ ɞɥɹ ɫɨɛɵɬɢɹ ɜɜɨɞɹɬ ɦɟɬɨɞɵ ɞɢɫɩɟɬɱɟɪɢɡɚɰɢɢ ɫɨɛɵɬɢɣ (event-
dispatching methods). ɗɬɢ ɦɟɬɨɞɵ ɧɭɠɧɵ ɞɥɹ ɬɨɝɨ, ɱɬɨɛɵ ɨɩɪɟɞɟɥɢɬɶ, ɫɨɡ-
ɞɚɧ ɥɢ ɤɨɞ ɨɛɪɚɛɨɬɤɢ ɩɪɨɢɡɨɲɟɞɲɟɝɨ ɫɨɛɵɬɢɹ ɞɥɹ ɞɚɧɧɨɝɨ ɤɨɦɩɨɧɟɧɬɚ, ɢ
ɬɨɝɞɚ ɨɛɴɹɜɥɹɸɬɫɹ ɤɚɤ ɡɚɳɢɳɟɧɧɵɟ (protected). ȼ ɤɥɚɫɫɟ TControl
ɛɢɛɥɢɨɬɟɤɢ VCL ɞɥɹ ɫɜɨɣɫɬɜɚ OnClick ɨɩɪɟɞɟɥɟɧ ɦɟɬɨɞ ɞɢɫɩɟɬɱɟɪɢɡɚ-
ɰɢɢ ɫ ɧɚɡɜɚɧɢɟɦ Click:
type
TControl = class (TComponent)
private
FOnClick: TNotifyEvent;
protected
procedure Click; dynamic;
property OnClick: TNotifyEvent
read FOnClick write FOnClick;
end;
implementation
procedure TControl.Click;
begin
22