      

     17 

      

         .   
      ,    
,  ,     . 

       

     ,    ,    
Delphi     ,    
   .      
,         . 

       

       TComponent   ComponentState. 
      . 
    ,      - 
.      ,   
 ,      ,   
     .  . 17.1   
,      (     
   Delphi). 

       

         ,    
 . 

         

     ""       . 

     

        Windows      . 

      

        . 

      

      . 

381


     17.1.   ComponentState 

    _________ ______ ___ _______ __ 

    csAncestpr	,         
   csDesigning
    csDesigning____   , ..     
    csDestroing_    
   
    csFixups	,       
,    . ,   
   
    csLoading    ___        
csReading	      
    csUpdating	,      
        csAncestor 
    csWriting	      
       ,        
,  ,       
ComponentState. ,    ,   
   . 

    if   (csDesigningi.ji....ComponentState}   then 
    ShowM^ssage (Tplease  register  this  Component'}; 

        

       TControl    ,  
    |    
.  ControlState   . 
    TControlState  =  set  of   (csLButtonDown,   csClicked,   csPalette,   
csReadingState, csATrg"nm?TTtTJe"eded,   csFocusing,   csCreating,   
csPaintCopy) ; 
           (  
TControl)         ComponentState. 
 . 17.2     . 

     17.2.   ControlState 

    	                     __     _______________________________ 

    csLButtonDown	       .  
  ,     ____________________________ 
    csClicked	   csLButtonDown,   
  ,  
     ControlStyle    csClickEvents, ,  
. v         , 
^^^^.   __ 
    csPalette	         
  
    WM_PALETTCHANGED
    csReadingState	       
    csAlignmentNeeded __    __________ ___ 
    csFocusing	    .   
,      , ' 
  
    csCreating	  /      
    .      
    
    csPaintCopy	    .    
   
    csReplicatable  ControlStyle 


    382	 IV.   


        

    ,_Coatrol?tyle       
,       
 .  ^_?     
ControlStyle    Create.  ,   
        .   
         
 (     )    
 . 
     ControlStyle     TControlStyle. 
  TControlStyle   . 
    TControlStyle  =  set  of   (csAcceptControls,   csCaptureMouse,   csDesignlnteractive, 
    csClickEvents,   csFramed,   csSetCaption,   csOpaque,   csDoubleClicks, 
csFixedWidth,   csFixedHeight,   csNoDesignVisible,   csReplicatable, 
csNoStdEvents,   csDisplayDraglmage); 
     ControlStyle     TControl   
     . 
    FControlStyle   :=   [csCaptureMouse,   csClickEvents,   csSetCaption,   
csDoubleClicks];  . 17.3         
     . 

     17.3.   ControlStyle 

    	 

    csAcceptControls	      
,       
    csCaptureMouse	     
    csDesignlnteractive	      
                                   
    csClickEvents	          
    csFramed	       
    csSetCaption	     ,   
   Name,        
-   
    csOpaque	      
    csDoubleClicks	       
     .  npOTHBH?Mjcjj?jaejHj?jjHbie  
   
    csFixedWidth	     
    csFixedHeight	     
    csNoDesignVisible	       
    csReplicatable	  ^ _   DBCtrlGrid 
    csNoStdEvents	   ,     
 .   ,        
  ,  ? ^ 
    csDisplayDraglmage	       
   -    /^ .   ,  
              4  1__?_ 
           ,  
  OnClick   1   OnDblClick,     
- ^   , ,  ,  
 ControlStyle,  ,     csClickEvents  csDoubleClicks. 

     17.   383 


    ,    

     VCL Delphi    ,   
   .    ,   
 ,    Delphi    
 ,        . 

     Loaded 

     Loaded     16, " ".   
         
,      DFM-,    .   
   (private)   (public)  
,        . 

     Notification 

     Notification   ,   
 TComponent    IDE Delphi  ,  
       .  Notification 
  : 

    procedure Notification(AComponent:   TComponent;   Operation:   
TOperation);   virtual; 

     Notification   .   ,  
      ,     
 :  oplnsert,  opRemove.     
,            
. ,  ,  Notification   TBatchMove. 

    procedure TBatchMove.Notification(AComponent:   TComponent;   Operation:   
TOperation); begin 
    inherited Notification(AComponent;   Operation); 
    if Operation =  opRemove  then 
    begin 
    if  Destination  =  AComponent   then  Destination   :=  nil; if  Source = 
AComponent  then  Source   := nil; end; end; 

         Notification,   
      opRemove.    
    ,       
,      Source  Destination. 
        nil. 

     FreeNotification 

     FreeNotification   ,   
TComponent.      TComponent  ,  
,   ,    Notification  
  . 
         ,    
  FreeNotification        
.        
  Notification. 
     FreeNotification   . 

    procedure  FreeNotification(AComponent:   TComponent); 

      Notification      
    ,     .  
    ,     ,  
        , 
, ,~           
.           
    ,   TDataSource    
DataModule.    ,   "   
",     FreeNotification   
 . 

    384	 IV.   


     DestroyWnd 

     DestroyWnd     TWinControl    
  .       
,    ,     
(Window Handle).       Destroy.  
      Destroy    
     TOMJ.HTO "Window has_nq parent" (..    ), 
,   ,       
     DestroyWnd.      
        DestroyWnd.   
   ,      TCustomEdit. 

    procedure  TCustomEdit.DestroyWnd; begin 
    FModified   := Modified;   w    9 
    inherited  DestroyWnd; .^x    {j^	' '''" end; 
    function TCustomEdit.GetModified:   Boolean; begin 
    Result   :=  FModified; 
    if HandleAllocated  then 
    Result   :=  SendMessage(Handle,   EM_GETMODIFY,   0,    0)   <>   0; end; 

      DestroyWnd     
FModified   Modified.    GetModif ied  
 Modified   SendMessage,    
   .       
,          
      . 

     GetChildren 

     GetChildren    ,   
    -nent       
 .  GetChildren   . 
    procedure  GetChildren(Proc:   TGetChildProc;   Root:   TComponent);   
dynamic; TGetChildProc  = procedure(Child:   TComponent}   of  object; 
       ,        
,      ,  
 GetChildren  ,  ,     
   ,   DFM-.  GetChildren 
  ,   , ,   ,  
  Root    TComponent.  GetChildren    
    ,   ,   
     .  Root  
       .      
  TMenuItem. 

    procedure  TMenuItem.GetChildren(Proc:   TGetChildProc;   Root:   
TComponent); var 
    I:   Integer/begin 
    for  I   :=  0  to  Count  -  1  do 
    Proc(Items[I] ) ; end; 

      GetChildren  TMenuItem     
  Items       Items.  
    Items    DFM-.   
  TMenuItem       
 Items,       Root   
  ,  ,      
 .      ,       
 Root    Owner  .   
     ,     
,      . 

     17.  	385 
    13  Delphi 3.   


      

          Windows   
.__  ,  -  . 
  ,      ^ 
   Windows.    
Windows    . WINDOWS. PAS,      
    .       
 ,   ,      
   ( ) . 

      Windows 

        Windows,    
,    . 

    PMsg = ; 
    TMsg = packed record 
    hwnd: HWND; 
    message: UINT; 
    wParam: WPARAM; 
    IParam: LPARAM; 
    time: DWORD; 
    pt: TPoint; end; 

     hwnd     ,   
 .  message    
    (     
 MESSAGES. PAS).  wParam  IParam  ,   
 .  time  ,  Windows  
, , ,  pt       
 . 
    ^    Delphi (Message Loop)   
 (Message Queue)        
 TMessage,    . 

    PMessage =  "TMessage; TMessage  =  record; Msg:   Cardinal; case   
Integer  of 0:    ( 
    WParam:   Longint; LParam:   Longint; Result:   Longint); 1:    ( 
    WParamLo: Word; WParamHi: Word; LParamLo: Word; LParamHi: Word; ResultLo: 
Word; ResultHi: Word); end; 

      MESSAGES. PAS       
,       TMessage. 
       Windows   ,  
    TMessage (      
  TMessage).  ,       
   message   .   
 ,     ,    . 
    ,       . 

    TEverything  =  class(TCustomControl) 
    public 
    procedure WMChar(var Message: TWMChar); message WM_CHAR; end;        ^-^	** 


    386	 IV.   

          ,  . 

    procedure TEverything.WMChar(var Message:   TWMChar); begin 
    MessageBeep(0); 
    inherited; end; 

       ,       
  ,     message WM_CHAR 
_, ,      
 . .^ BjjPjy^bjbixjMieTOflOBj     
,     ,    
  - . _    
ij}]^??itecl_ra^^'^^^,].99,  ".	" " ""~~~ 
      Windows    ""  
.       Result    
TMessage.  Result   . 

     ,   

          .  
Delphi    ^ ,_.1\; 
^ __ wm_User + 151  $7FFF.    
~~   ,    
  , , ,     
  ,      Windows   
   .     
,  -   ,    
 ""       
.        
,          
    . 
           , 
   API Register-WindowMessage,   
     .  API  
 .   API    ,  
    .   ( ) 
 ,     ( ) 
   .  RegisterWindowMessage 
  . 

    UINT RegisterWindowMessage( LPCTSTR  Ipsz     //        
. ); 

     RegisterWindowMessage   ,  
     .     
 ,    .      
  Windows,    ,  Windows 
  ,     $  $7FFF  
  .    , Windows  
  .     
     Windows. 

       

           
   ,       
 (data-link object).      
   TDataSource.     
 .     '  
       ,    ,    
   (,  DBCtrlGrid).   
       TDataLink.  . 17.4 
   TDataLink. 

     17.4.   TDataLink 

    	 

    TGr idDataLink	       DBGrid 
    TMasterDataLink	       / 
    TFieldDataLink	       
 ,     ________________________________ 

     17.  	387 


     . 17.4 

    	 

    TNavDataLink	       TDBNavigator 
    TDataSourceLink	       
DBLookupComboBox  
    DBLookupListBox 
    TListSourceLink	       
 DBLookupComboBox  DBLookupListBox 
    TDBCtrlGridLink	       
DBCtrlGrid TQueryDataLink                         
  DataSource   TQuery 
    THTTPDataLink	        
  Internet TdataSetTableProducer 


         TDataLink 

      TDataLink     (public) 
  ,       .  
    . 

     UpdateRecord 

     UpdateRecord         
,          
 .       ,   
     .   , 
     . 

     Active 

     Active        
,    ,       . 

     ActiveRecord 

     ActiveRecord       
     .     
         .  
  ?_^[   (,   
TDBGrid        ,   
ActiveRecord  ,     ). 

     BufferCount 

     BufferCount       
 . ,   TDBGrid  BufferCount 
        
 .        
RecordCount         
    . 

     DataSet 

     DataSet     TDataSet,   
       DataSource. 

     DataSource 

     DataSource     TDataSource,   
    . 

     DataSourceFixed 

     DataSourceFixed ,     DataSource. 

     Editing 

     Editing ,    DataSource   
 (Edit). 

    388  IV.   


     Readonly 

     Readonly ,         
 . 

     RecordCount 

     RecordCount   ,    
     . 

         TFieldDataLink 

     TFieldDataLink        
.      TDataLink     
DBCTRLS.PAS.         
     TFieldDataLink. 

     Edit 

     Edit        . 
        true, 
,     (  )   Edit. 
            
,  Edit   false. 

     Modified 

     Modified    ,     
   .    Modified  
TDataSource    ,      . 

     Reset 

     Reset      __  
 TDataSource.         
 . 

     CanModify 

     CanModify ,       
   .     false, 
             
 . 

     Control 

     Control         
  .    Delphi     
 ,     ,   , 
     . 

     Editing 

     Editing ,    DataSource   . 

     Field 

     Field         
 TField,       . 

     FieldName 

     FieldName       ,  
     . 

     OnActiveChange 

     OnActiveChange   ,    
Active  ,       . 

     17.  	389 


     OnDataChange 

     OnDataChange     ,   
   .        
    .      
      . 

     OnEditingChange 

     OnEditingChange   ,   DataSource 
   .     
      . 

     OnUpdateData 

     OnUpdateData ,   DataSource   
   .     ,   
     ,   , 
    . 

        

           
  . 
    1.     . 
    2.      TDataLink    . 
    3.     (published)  DataField  DataSource. 
    4.          OnDataChange  OnUpdateData. 
    5.      cm_GetDataLink. 
      ,      
   .      (     
),   ,     .  
   ,    Create  Destroy 
 TButton,         
.  ,  ,        
  DataField  DataSource. , ,   
  DataChange     OnDataChange. 
 17.1      ,    
 . 

    !    17.1. \UDELPHI3\CHP17\DBBTN.PAS.     
 TButton 

    unit DBBtn; 
    interface 
    uses 
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
StdCtrls, DB, DBCtrls; 
    type 
    TDBButton = class(TButton) private 
    {  . } 
    FDataLink : TFieldDataLink; 
    function GetDataField: string; 
    function GetDataSource: TDataSource; 
    procedure SetDataField(const Value: string); 
    procedure SetDataSource(Value: TDataSource); 
    procedure DataChange(Sender: TObject); protected 
    {  . } public 
    {  . } 
    // He    Create  Destroy! 
    constructor Create(AOwner: TComponent); override; 
    destructor Destroy; override; published 


    390	 IV.   


    {  . } 
    property DataField: string read GetDataField write SetDataField; property 
DataSource: TDataSource read GetDataSource write SetDataSource; end; 
    procedure Register/implementation 
    constructor TDBButton.Create(AOwner: TComponent); begin 
    //     Create. 
    inherited Create(AOwner); 
    FDataLink := TFieldDataLink.Create(Self); 
    FDataLink.OnDataChange := DataChange; end; 
    destructor TDBButton.Destroy; begin 
    //     Destroy. 
    FDataLink.OnDataChange := nil; 
    FDataLink.Free; 
    inherited Destroy; end; 
    function TDBButton.GetDataField: string; begin 
    Result := FDataLink.FieldName; end; 
    function TDBButton.GetDataSource: TDataSource; begin 
    Result := FDataLink.DataSource; end; 
    procedure TDBButton.SetDataField(const Value: string); begin 
    FDataLink. FieldName := Valuer-end; 
    procedure TDBButton.SetDataSource(Value: TDataSource); begin 
    FDataLink.DataSource := Value; end; 
    procedure TDBButton.DataChange(Sender: TObject); begin 
    if FDataLink.DataSource.State = dsBrowse then if FDataLink.Field.AsString 
<> '' then begin Caption := FDataLink.Field.AsString; Enabled := true; end 
else begin 
    Caption := '(Empty)'; Enabled := false; end; end; 
    procedure Register; begin 
    RegisterComponents('UD3', [TDBButton]); end; 
    end. 


     17.  	391 


      1 
         ,    
  ,     OnUpdateData. 
     cm_GetDataLink    , 
      .      
     ,      
   DBCtrlGrid (     
csReplicatable   ControlStyle). 

       

             
    .      
 Delphi       
  .      
-      , Delphi  
    .     
 Delphi        
       .     
     Delphi   , 
    .       
,      ,     
   . 
       ,    . 
    1.	  . 
    2.	  . 
    3.	  . 

       

         ,    
    Delphi   , 
      DSGNINTF. PAS,   
 \SOURCE\TOOLSAPI. 
     . 17.5     , 
  Delphi.      
         
. ,  Boolean   ,   
  TEnumProperty Delphi   
TBoolProperty,      TEnumProperty  
     Boolean. 

    j  17.5.    Delphi	; 

    	  

    TPropertyEditor                
    TIntegerProperty             (Byte, 
Word, Integer, Longlnt, 1..., 20  ..) 
    TCharProperty	     Char (Char, 'A'..., 'Z'  ..) 
    TEnumProperty_____  ________________________________________ 
    TFloatProperty	    (Float, Single, Double   ..) 
    TStringProperty              (String, ShortString, 
String [20], AnsiString  ..) 
    TSetProperty	   "" 
    TClassProperty____   ""_____________________________ 
    TMethodProperty            "" 
    TcomponentProperty       TComponent 


    392  IV.   


       

    _|>     TPropertyEditpr   
?  ,      
,      .  
GetName  GetValue         
 .  SetValue   ,  
   .  Edit ,  
          ,  
 GetValues (    GetValue) ,  
   .  GetProp-erties  
,        . 
        ,     
,       . 

     Activate 

     Activate   ,      
 .       , 
    ,    , 
     ,    
 .   ,      
 paMultiSelect  paSubProperties  GetAttributes, Delphi  
,        Activate (  
    Create). 

    procedure  Activate;   virtual; 


     AIIEqual 

     AIIEqual ,      
 ,     ,   GetAttributes  
 paMultiSelect.   AIIEqual   True,  
 GetValue,       .  
  ,       
    . 

    function AIIEqual:   Boolean;   virtual; ,   
AIIEqual   String. 
    function  TStringProperty.AIIEqual:   Boolean; var	"~~   ** I:   
Integer; V:   string; begin 
    //        False. 
    Result   :=   False; 
    //            . 
    if  PropCount  >  1  then 
    begin 
    //     . V := GetStrValue; 
    -> for I := 1 to PropCount - 1 do 
    t,   //         . t   11 
  ~" ,    . 
    If GetStrValueAt(I) <> V then Expend; 
    //     , ,   . Result := 
True;	"'  --end; 


     Edit 

      Edit ,      
       (...)    . 
  Edit       
   (,   Font, Color  
Picture).    Edit  TPropertyEditor _ 
    GetValues.   GetValues   
,  Edit   . "" 
    procedure  Edit;   virtual; 


     17.  	393 

    , ,  Edit   Font.  
  ,    Font    try. . 
.finally     finally.  _  
,         
/

    procedure TFontProperty.Edit; var 
    FontDialog: TFontDialog; begin 
    //   Font. 
    FontDialog := TFontDialog.Create(Application); 
    try 
    //           
    FontDialog.Font := TFont(GetOrdValue); 
    FontDialog.HelpContext := hcDFontEditor; 
    FontDialog.Options := FontDialog.Options + [fdShowHelp, fdForceFontExist]; 
    if FontDialog.Execute then 
    //    ,   Font. 
    SetOrdValue(Longint(FontDialog.Font)); ' finalTy""~" " 
    //   Font. 
    FontDialog.Free; end; 
    end; 


     GetAttributes 

     GetAttributes   TPropertyAttributes,  
   .     
^        
.    ,      
 ,      ,   
      ,    
 ,         
  .. 

    function  GetAttributes:   TPropertyAttributes;   virtual; 

     TPropertyAttributes    ,   
. 17.6. ,   *~"  GetAttributes  
  ,        
   .     
    (     ).  
   paMultiSelect  paSubProperties. 

      17.6.    TPropertyAttributes 

    ______________________________________________________ 

    paValueList	,       
    .      
           
    paSubProperties         ,      
,          
    
    paDialog	,       
,    Edit.     
    
    paMultiSelect	,      ,  
     __ 
    paAutoUpdate	,     SetValue   
  .  ___    
  (   <>    
     ) 
    paSortList	      , 
  
    GetValues 
    paReadOnly	,       
    paRevertable   ____,       
 ____   ___ 

    394	 IV.   

    I  1 
     paValueList        
 ,   paDialog   .    
        , , 
    paValueList  paDialog    , 
DeTpfii   paValueList    paDialog. 

     GetEditLimit 

     GetEditLimit    ,  
        .  
  GetEditLimit  TPropertyEditor   255. 

    function  GetEditLimit:   Integer;   virtual; 


     GetName 

     GetName   ,     
.       RTTI  .  
,         
.        . 

    function GetName:   string;   virtual; 

     ,      . 
      ,    , 
        ,   
 .     GetName   TSetElementProperty. 

    function  TSetElementProperty.GetName:   string; begin 
    Result   :=  GetEnumName(GetTypeData(GetPropType).CompType",   FElement); end; 


     GetProperties 

     GetProperties ,      
 ,   .     
GetAttributes    paSubProperties.  GetProperties 
        
      . 

    procedure GetProperties(Proc:   TGetPropEditProc);   virtual; 

    , ,  GetProperties   TClassProperty.  
       ,   
  . 

    procedure  TClassProperty.GetProperties(Proc:   TGetPropEditProc); var 
    I:   Integer; 
    Components: TComponentList; begin 
    //   . Components := TComponentList.Create; try 
    for I := 0 to PropCount - 1 do 
    //       . Components.Add(TComponent(GetOrdValueAt(I))); 
    //   GetComponentProperties     // 
  ,       // 
,     GetProperties. 
GetComponentProperties(Components, tkProperties, Designer, Proc); Finally 
    Components.Free; end; end; 


     GetValue 

     GetValue     .  
         
 ,   . 

    function GetValue:   string;   virtual; 


     17.  	395 

    , ,    GetValue   
 TStringProperty.    GetValue  " (unknown) ". 

    function TStringProperty.GetValue:   string; begin 
    Result   :=  GetStrValue; end; 


     GetValues 

     GetValues     ,   
    ,     
   .      
,      string.   
       .  GetValues 
    ,    GetAttributes  ([wiarpaValueList. 

    TGetStrProc = procedure(const S: string) of object; procedure 
GetValues(Proc: TGetStrProc); virtual; 
        GetValues   TBoolProperty. 
    procedure TBoolProperty.GetValues(Proc: TGetStrProc); begin 
    //   Proc    . 
    Proc('False'); 
    Proc('True'); end; 


     Initialize 

     Initialize     ,    
 .     ,  
     Create.     Activate, 
     .  -   
,  Initialize    Activate.    
Initialize  TPropertyEditor   . 

    procedure Initialize; virtual; 


     SetValue 

     SetValue     .   
            
,   .     
  ,        
  . 

    procedure  SetValue(const  Value:   string);   virtual; 

           , 
   .     
       SetXxxValue,   
  .     SetValue   TBoolProperty. 

    procedure TBoolProperty.SetValue  SetValue(const Value:   string); var 
    I:   Integer/begin 
    if CompareText(Value,    'False')   =  0  then 
    I   :=  0 else  if  CompareText(Value,    'True')   =  0  then 
    I   :=  -1 else 
    I := StrToInt(Value) ; SetOrdValue (I); end; 


         TPropertyEditor 

      TPropertyEditor       
 ,     .   
            
    TPropertyEditor,      .


    396	 IV.   


     Designer 

     Designer    ,  
    .     
  GetComponentProperties. 

     PrivateDirectory 

     PrivateDirectory  ,      
 .      Delphi 1.0,  . 
   INI-    , 
   .'Ѹ  i ^_ 
 .	"" * ' 

     PropCount 

     PropCount ,      
 .     ,    
    paMultiSelect. 

     Value 

     Value     ,  
   .      
  GetValue  SetValue . 

     GetComponent 

     GetComponent   ,   
Index,        . 
        ,  
 GetAttributes      paMultiSelect. 
       PropCount. 

    function  GetComponent(Index:   Integer):   TPersistent; 


     GetPropType 

     GetPropType     RTTI  
    .  ,    
,  ,    4, "Object Pascal:  "'. 

    function  GetPropType:   PTypelnfo; 


     Modified 

     Modified    Designer ( ,   
    ),   .   
SetXxxValue  TPropertyEditor     ,   
   .      
   ,     ,    
  SetXxxValue. 

     Get  Set 

     TPropertyEditor        
,     . 17.7.     
  ,       
  Modified.      ,    
  Get  Set,      
  Modified. 

     17.7.  Get  Set   TPropertyEditor 

     _______________ Get_______________ Set_____________ 

    Float	GetFloatValue               SetFloatValue Method                     
GetMethodValue              SetMethodValue Ordinal                     
GetOrdValue                 SetOrdValue String                     
GetStrValue                 SetStrValue Variant                     
GetVarValue                 SetVarValue 


     17.  	397 


       

             
   .      
 IDE Delphi   RegisterPropertyEditor.    
     . 

    procedure RegisterPropertyEditor(PropertyType: PTypelnfo; ComponentClass: 
TClass; const PropertyName: string; EditorClass: TPropertyEditorClass); 
    PropertyType 

        RTTI  ,    
 .       
    Type Info. ,       
,      : 

    Typelnfo() 


    ComponentClass 

      ,      
.        
   .     njj.,  
      .

    PropertyName 

      ,      .  
PropertyName       
  .      ,  
    ,    .	 

    EditorClass 

        . Delphi   
  ,     
      . 

       

           ,   
   ,       
      . ,    
 , .<_     
 .  . 17.1    -"TifTDatabase. 
   ,   ,     
   ,     .  
   ,    
  TDatabase " " (   
 ). 

    . 17.1.   TDatabase 

              
      '"'""   
      .    
    Delphi   TComponentEditor.   
  TDe-faultEditor,      
 .     ,    
  . 


    398  IV.   


     TComponentEditor 

     TComponentEditor       
  Delphi.      ,  
  Create (,   ).    
   DSGNINTF. PAS,      . 

    TComponentEditor = class public 
    constructor Create(AComponent: TComponent; ADesigner: ^	TFormDesigner); virtual; 
    procedure Edit; virtual; 
    procedure ExecuteVerb(Index: integer); virtual; 
    function GetVerb(Index: integer): string; virtual; 
    function GetVerbCount: integer; virtual; 
    procedure Copy; virtual; 
    property Component: TComponent read FComponent; 
    property Designer: TFormDesigner read FDesigner; end; 

           . 

     Create 

      ,      
.      , Delphi   
   .  Create   :  
  ,   ,    
  .     Create, 
    Create. 

     Edit 

     Edit   ,      
.     TComponentEditor    
GetVerbCount  .    ,   
ExecuteVerb(0),        
 .  TDef aultEditor   Edit,  
      -Create, OnChange  
OnClick ( ,    )     
   . 

     GetVerbCount 

     GetVerbCount  aJJJ^JiOJJJ[^poae  
    .    ,  
    "  .     
   ,   .    
  . 

     ExecuteVerb 

     ExecuteVerb ,      
     .  
 Index,     .    
     Edit~KJiacca TComponentEditor.   
       ,   
       . 

     GetVerb 

     GetVerb ,       
 .    ,     
      Index.  Index  
   , ..     
.          
 ,   . 

      

      ^^^.     
,     ,    
   .        
   ,    Delphi (   
    ,        ). 

     17.  	399 


     TDefaultEditor 

     TDefaultEditor    TComponentEditor.  
  Edit,       
EditProperty.  TDefaultEditor   . 

    TDefaultEditor  =  class(TComponentEditor) protected 
    procedure EditProperty(PropertyEditor:   TPropertyEditor;   var Continue,  
 FreeEditor: Boolean);   virtual; public 
    procedure Edit;   override; end; 


     Edit 

     TDefaultEditor   Edit      
  ,   EditProperty    
.    ,   Edit. 

     EditProperty 

     EditProperty   Edit    
 .    EditProperty   OnCreate, 
OnChange  OnClick (  ).   , 
       , 
      Edit. 

       

            
.       IDE Delphi 
  RegisterComponentEditor.       
  . 

    procedure  RegistuiComponentEditor(ComponentClass:   TComponentClass; 
ComponentEditor:   TComponentEditorClass); 

         ,      
  . 

       

         ,   TEdit. 
    ,      
  .  ,     
  TEdit       
(OnCreate, OnChange  OnClick),    ,   " 
 "  Delphi.    Delphi   OnChange. 
    ,    ,    
 , ,  ,       
 OnExit.           
:   ,       TEdit 
  OnExit   OnChange.       
    TEdit  ,   Events 
    "   OnExit.   17.2 
,    ,    OnExit 
          TEdit 
(     )  OnExit  OnChange. 

    {  17.2. \UDELPHI3\CHP17\TESTCD. PAS.   TEdit 

unit  TestCE;	" 
    interface 
    uses 
    Dsgnlntf, StdCtrls, SysUtils, Classes; 
    type 
    TMyEditEditor = class(TDefaultEditor) 


    400	 IV.   


    private 
    FIndex : integer; public 
    constructor Create(AComponent: TComponent; 
    ADesigner: TFormDesigner); override; 
    function GetVerbCount: integer; override;      ^ 
    function GetVerb(Index: integer): string; override; 
    procedure ExecuteVerb(Index: integer); override; 
    procedure EditProperty(PropertyEditor: TPropertyEditor; var Continue, 
FreeEditor: Boolean); override; end; 
    procedure Register; implementation 
    constructor TMyEditEditor.Create(AComponent: TComponent; 
    ADesigner: TFormDesigner); begin 
    inherited Create(AComponent,ADesigner); 
    //  Findex. 
    FIndex := -1; end; 
    function TMyEditEditor.GetVerbCount: integer; begin 
    //    GetVerbCount  2    , 
    //    . 
    result := 2; end; 
    function TMyEditEditor.GetVerb(Index: integer): string; begin 
    //    , case Index of 
    0: result := 'O&nChange'; I: result := 'OnE&xit'; end; end; 
    procedure TMyEditEditor.ExecuteVerb(Index: integer); begin 
    // ,       Edit 
    //     . 
    // ?,    -.  . 
    //  FIndex' iri'dex,     Edit. 
    FIndex := Index; 
    Edit; 
    //    FIndex  -1. 
    FIndex := -1; 
    // __ Mp_dified  Designer   , 
    //   . 
    if Designer <> nil then 
    Designer.Modified; end; 
    procedure TMyEditEditor.EditProperty(PropertyEditor: TPropertyEditor; 
    var Continue, FreeEditor: Boolean); begin 
    case FIndex of 
    //   FIndex    , //   
   .  : begin 
    if CompareText(PropertyEditor.GetName, 'OnChange') = 0 then begin 


     17.  	401 

    PropertyEditor.Edit; Continue := false; end; end; 1 : begin 
    if CompareText(PropertyEditor.GetName, 'OnExit') = 0 then begin 
    PropertyEditor.Edit; Continue := false/end; end; else 
    //   . 
    inherited EditProperty{PropertyEditor,Continue,FreeEditor); end; end; 
    procedure Register; begin 
    //   TMyEditEditor   Tedit. 
    RegisterComponentEditor(TEdit, TMyEditEditor); end; 
    end. 


     

        ,   ""  .  
      ,  
       
.   ,      ,  
        . 

    402	 IV.   

