     29

       Open Tools API 

      

       ,     (IDE) 
Delphi      ? ,    
          
         VCL  
       .   Open Tools 
API     .      Open Tools 
API   . 
      ,     Delphi  . 
(Wizards   , .    Windows 
    . .)      
 ,  ,   Open Tools API   
  (  ,     ). 
    Open Tools API    ,    
    Del-"f>hi7   Open Tools API  
    . 
          .         
.       (, , , 
  ..). 
           (, ,   ..). 
    	  Delphi. 
    	   . 
    	   . 
     Open Tools API    ,    
  Delphi (   ).   

    29 

    Open Tools API 

       Open Tools API   Delphi. 

     Delphi 

             
 Delphi. 

    ToolServices     Delphi 

        Open Tools API (ToolServices),  
   Delphi. 

681

      -, ,  
,    Delphi IDE,    . 
                
 ToolServices    Delphi  . 
        Open Tools API  Delphi 3.   
       Delphi 1 -   Open 
Tools API.    ,   -^     
  Delphi, ,       
  Delphi,      Delphi. 

      Delphi 

              
TIExpert,    ( ,    
). TIExpert     ,  , 
   ,   .    TIExpert 
       Delphi,   
     ,        . 

      

           TIExpert,   
,   Delphi: , ,    
(standard, add-in, form  project),   . 29.1. 

     29.1.   Delphi 

    	  

    	   Help   
    	       
    	   Forms   New Items   
    	   Projects   New Items 
  

            jjbisosa 
    Delphi.  ,     
    Operi TooJs_.Aj,I.   ,  
    . "" 
        ,     
        Help  ,   
 ,   .       
      ,  ,  
    Open Tools API. 
    3	  Open Tools API     Delphi 
Developer  Client Server,        
   Delphi.   (     
Delphi)     .. \DELPHI   3\SOURCE\TOOLSAPI. 

      TIExpert 

             
TIExpert,     .   
  TIExpert    29.1. 

     29.1. EXPINTF. PAS.    TIExpert	| 

    TIExpert  =  class (TInterface) public 
    function GetName:   string;   virtual;   stdcall;   abstract; 
    function GetAuthor:   string;   virtual;   stdcall;   abstract; 


    682	 VI.   


    function GetComment: string; virtual; stdcall; abstract; function GetPage: 
string; virtual; stdcall; abstract; function GetGlyph: HICON; virtual; 
stdcall; abstract; function GetStyle: TExpertStyle; virtual; stdcall; 
abstract; function GetState: TExpertState; virtual; stdcall; abstract; 
function GetlDString: string; virtual; stdcall; abstract/function GetMenuText: 
string; virtual; stdcall; abstract; procedure Execute; virtual; stdcall; 
abstract; end; 

        .   ,   
   Delphi    . 

    GetStyle 

        .     
     : esStandard, esAddin, esForm, 
esProject.       
Result:=esStandard;       
   . 

    GetlDString 

          .  , 
 .     ,  
Borland    : -.,  

    Result   :=   'UDelphiS.Proj^ctlnfoExpert';     
    ,     ! 


    GetName 

         .   
  ,  

    Result   :=   'Project   Information  Expert'; 

              
^      New 
Items.	f!t)ffif'ffjQ"  S 

    GetMenuText 

       o|c?_jl_?^J?oo_cepa   
,      Help  Delphi,  

    Result   :=   'UD3   Project   Information  Expert...' 

     GetMenuText     ,    
 . 

     
    

    GetState 

     ,      , 
,      , ..    
   . 
     GetState     ,    
 -^   . 
        : 

    Result   :=   [esEnabled]; 


     29.    Open Tools API	683 


    Execute 

              
.           
   .      ,  
       ,    
  Delphi. 
            ,  

    procedure TProjectlnfo.Execute; begin 
    if not Assigned(ProjectlnfoForm)   then 
    ProjectlnfoForm   := TProjectlnfoForm.Create(Application); 
    ProjectlnfoForm.Show; 
    ProjectlnfoForm.SetFocus end; 

    He ,        , 
 ,    .     
  f inalization. 

    GetPage 

           .    
,     New Items,  

    Result   :=   'Projects'; 
    GetGlyph 

           .   
 ,        ( 
).    0    ,  

    Result   :=  Loadlcon(Hinstance,'MYICON'); 
    GetAuthor 

           .    
    ,     
    New Items,  

    Result   :=   'KIV  without   Co   (AKA  2:463/59)'; 
    GetComment 

           .   
  - ,     
  ,  

    Result   :=   'DLL  project   expert.   Write   Delphi   1   Style   DLLs'; 

       ,         
,    . 29.2. 

     29.2.    TI Expert 

    	             		 

    GetStyle	S                                        /	/	/ 
    GetlDString	/                             /	s	s 
    GetName	/                             /	/	s 
    Execute	/	s	V 
    GetPage		s	s 
    GetGlyph		s	/ 
    GetAuthor		s	V 
    GetComment		/	V 
    GetMenuText	s 
    GetState	s 


    684  VI.   


        .    Delphi 
(   )      
     (  interface).   
     implementation ( 29.2). 

     29.2.  . PAS.      

    unit CompExpt; interface 
    uses 
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
Exptlntf, Toollntf; 
    type 
    TGenericComponentDialog = class(TForm) procedure FormCreate(Sender: 
TObject); procedure FormClose(Sender: TObject; 
    var Action: TCloseAction); end; 
    Type 
    // .     TIExpert. //     
 . TGenericExpert = class(TIExpert) public 
    function GetlDString: string; Override; function GetStyle: TExpertStyle; 
Override; function GetState: TExpertState; Override; function GetMenuText: 
string; Override; function GetPage: string; Override; function GetName: 
string; Override; function GetAuthor: string; Override; function GetComment: 
string; Override; function GetGlyph: HICON; Override 
    procedure Execute; Override; end; 
    var GenericComponentDialog: TGenericComponentDialog; 
    procedure Register; implementation {$R *.DFM} 
    procedure Register; 
    begin 
    RegisterLibraryExpert(TGenericExpert.Create); end; 
    // TGenericExpert Implementation 
    / /              '          	          ' 
    function TGenericExpert.GetlDString: String; begin 
    Result := 'UDelphi3.GenericComponentExpert'; end; 
    function TGenericExpert.GetStyle: TExpertStyle; begin 
    Result := esStandard; //  , end; 


     29.    Open Tools API	685 


    function TGenericExpert.GetState: TExpertState; begin 
    Result := [esEnabled] //  , end; 
    function TGenericExpert.GetMenuText: String; begin 
    Result := 'UD3 Generic Component Expert...1 end; 
    function TGenericExpert.GetName: String; begin 
    Result := 'Generic Component Expert' end; 
    function TGenericExpert .GetPage: string/begin 
    Result := ''; //       , end; 
    function TGenericExpert.GetAuthor: string; begin 
    Result := ''; //       , end; 
    function TGenericExpert.GetComment: String; begin 
    Result := ''; //       , end; 
    function TGenericExpert.GetGlyph: HICON; begin 
    Result := 0; //       , end; 
    procedure TGenericExpert.Execute; begin 
    if not Assigned(GenericComponentDialog) then 
    GenericComponentDialog := TGenericComponentDialog.Create(Application); 
    GenericComponentDialog.Show; 
    GenericComponentDialog.SetFocus; end; 
    / /______________________________________________________________________i__________ 
    // TTestDialog Implementation 
    / /_________________________________________ 
    / /      
    procedure TGenericComponentDialog.FormCreate(Sender: TObject); begin if 
not Assigned(ToolServices) then Exit; 
    //    , end; 
    procedure TGenericComponentDialog.FormClose(Sender: TObject; 
    var Action: TCloseAction); begin 
    Action := caFree; 
    GenericComponentDialog := Nil; end; 
    Initialization GenericComponentDialog := Nil; 
    Finalization end. 


    686	 VI.   


         TIExpert,     , 
    . 
    ,   TGenericExpert      
 .   - 1  հ̰>  . 
             Delphi. 

      

        , ^^__??1?1 
   .        
 RegisterLibraryExpert   Register,  
Delphi   .      . 
        DLL- ,   Delphi IDE 
     DLL     
 .    Delphi    
Experts   Windows.	. -  - - -. 
          ,     
 Delphi       . 
        
            .  
    Register   . 

    procedure  Register; 
    implementation {$R  *.DFM} procedure Register; begin 
    RegisterLibraryExpert(TGenericExpert.Create); end; 

         Delphi   .  
 , Delphi   RegisterLibraryExpert,   
   Delphi IDE. 
     ,  ,       
 .       15, 
"  ",   dpk-     
    \UDELPHI3\CHP29\. 
             
 Help (. 29.1). 

      DLL 

        DLL     . 
      DLL,    29.3. 

     29.3. \UDELPHI3\CHP29\GENERIC\AS_DLL\DLLEXPRT . DPR.  
  DLL- 

    library DllExprt; 
    uses 
    Exptintf, 


     29.    Open Tools API	687 


    dllexpt in 'dllexpt.pas' {GenericDLLDialog}; {$R *.RES} 
    exports	'      """" '""^s InitExpert name ExpertEntryPoint;}      , 
    begin end. 

     ,   InitExpert    
  ExpertEntryPoint,  Delphi    
   DLL. InitExpert   ,      
  Register.   29.4    InitExpert. 

    . 29.1.       

     29.4. \UDELPHI3\CHP29\GENERIC\AS_DLL\DLLEXPT.PAS.  
 InitExpert ' 

    function InitExpert(ToolServices: TIToolServices; >  RegisterProc: TExpertRegisterProc; 
    var Terminate: TExpertTerminateProc): Boolean; export; stdcall; 
    implementation {$R *.DFM} 
    procedure TerminateExpert; begin 
    //   , end; 
    function InitExpert(ToolServices: TIToolServices; 


    688  VI.   


    RegisterProc: TExpertRegisterProc; var Terminate: TExpertTerminateProc): 
Boolean; export; stdcall; begin Result := False; 
    //    . 
    if (ToolServices = Nil) or Assigned(Exptlntf.ToolServices) then Exit; 
    //    ToolService. Exptlntf.ToolServices := ToolServices; 
    // To     . Application.Handle := ToolServices.GetParentHandle; 
    //   . Terminate := TerminateExpert; 
    //  . RegisterProc(TGenericExpert.Create); 
    {  . } Result := True; end; 
     initExpert       
ToolService       RegisterProc  
 .      
,    . 
          DLL   
     ,   Delphi    
 . 
      RegEdit   . 

    HKEY_CURRENT_USER Software Borland Delphi 3.0 
    Experts 
    TestExpert=C:\UDELPHI3\CHP29\GENERIC\DLL\DLLEXP.DLL 


     

      Delphi  ,    
DLL.       ,      
    DLL  . 

       

          .   
     RaiseException  
TIToolServices.         
 ReleaseException   Virtlntf,    
 ,         
  .   . 

    procedure HandleException; begin 
    if Assigned(ToolServices) then 
    ToolServices.RaiseException(ReleaseException) end; 


     29.    Open Tools API	689 

