     9.    ActiveX	221 

     9.      ActiveX 

      ActiveX  ,      
     .  
  ActiveX  ,       
  .       
 ..    ActiveX,   Visual Basic,  
  - ActiveX,     
Visual Basic,  Microsoft Office  Internet Explorer. 

    9.1.     ActiveX 

    9.1.1.    

         ,  
     .    
          
    . 
     ,    Visual Basic,    
 ,        
.          
     (   
     ),     : 

      	 
      
     -  UserControl (Ctrl) 
    Ctrl.ctl 
    CtrM 

    . 9.1.     . 


    9.1.2.     

            
,     ..     
       . 
       ActiveX  Visual Basic     
 .,        . 
       .   
  . 
      .     ,  
  . 9.2. 

    9.1.3.   ActiveX    

         . 
       ,    
 ,      
  


    222     ActiveX 


     . 
       

    . 9.2.  .    . 

      
       ,    , 
   
    - 
     ,     
     .   	 
		   
     
    
        

    . 9.3.     . 

    .       , 
    ,     (. 9.3). 

    9.1.4.  User-Control 

     UserControl      .  
  ActiveX,     Visual Basic,  
 UserControl 
     UserControl       
.   UserControl       
  .      
     User-Control   
,       Visual Basic (. 9.4). 

    ,    UserControl 

           UserControl   
    .ctl.  .ctl   Visual Basic 
.frm,        . 
     ,       ,  
 :  .ctx.   .ctx    .frx, 
  ,       . 


     9,    ActiveX 223 


    . 9.4.  UserControl    . 


    9.1.5.    ActiveX 

          ,   
  .      
  ,      
   . 
      ActiveX       
, ,   Microsoft Office, Internet Explorer   
Visual Basic.   ActiveX     
     Web-. 

          

           
    ( .),    
 ActiveX  public .    
   Setup . 

           

     .ctl      Visual Basic.   
        
  . 
           : 
             .; 
         ,      
    . 
            
    ,    
       . 


    224      


    9.1.6.     ActiveX 

        ActiveX   : 
    1.      . 
    2.        . 
    3.       . 
    4.      . 
    5.     . 

    9.2.      

          
ActiveX     Visual Basic.   
        , 
     . 
              
 .     ,   
   . ,   
    ,   ,  
 ,     TextBox. 

    9.2.1.     

      ActiveX   UserControl   
 . 
          ,  
   UserControl.     ActiveX  
,    UserControl,     
  ,    UserControl. 
         UserControl,    
   : 

    . 9.5.   ActiveX   . 

         UserControl  
     Visual Basic,   
  OLE Container. 
        ( )  
,         Components (. . 1.3). 


     9.    ActiveX	225 


    9.2.2.     

      ,      
    ,        
       . 
    ,       ,  
   ,     
 . 
            : 
               
    ; 
        ,    ,  
          . 
         ,    
UserControl, , ,   ,   
   .    Resize    
 ,         
     . 

    :        , 
    Resize,      , 
  ,   . , 
        Resize. 


    9.2.3.    

     Resize       
     .    
       
  UserControl. ' 
            UserControl 
   : 

    Private   Sub  UserControl_Resize() Const  MinWide   =   2000 If  
UserControl.ScaleWidth  < MinWide  Then 
    Textl.Width  =   1000 Else 
    '                  UserControl 
Textl.Width  =  UserControl.ScaleWidth   -   Textl.Left End   If End  Sub 


    9.2.4.      

             
 . ,      
(Frame) Visual Basic       
.            
      . 
           ActiveX  
      ,  
  True  ControlContainer  UserControl. 

    8 .   136 


    226	     


         

            
   ActiveX,     
  .    
       ,  
   UserControl    ActiveX 
  ,   Windows      
    ActiveX   .   
   . 
         ,   
   ActiveX      . 

     ContainedControls 

              
  ContainedControls    
ActiveX,       . 
     ContainedControls    , 
         
 ActiveX   .      
 ,        . 
        ,    
ContainedControls     ,   
  ActiveX: 

    Dim  CtrContained  As   Object For  Each   CtrContained   In  _ 
    UserControll.ContainedControls MsgBox  CtrContained.Name Next 

      ,     ActiveX   
    ControlContainer     
True,       . 

    9.2.5.   About 

      ActiveX    About.    
   About: 
    1.     About. 
    2.       . 
    3.   Procedure Attributes  Procedure ID    AboutBox. 
         About   ,   
   (...)    About (. 9.6). 

    9.2.6.      

           
,         
Visual Basic,    . 9.7. 
           16 X 15 . 
    ,     
 ,      . 


     9.    ActiveX 227 


    . 9.6.  About     . 

    . 9.7.       . 

         UserControl,  
   ToolboxBitmap. 


    228	   


    9.3.    

         ActiveX   
   . ,   
    ActiveX,    
     . ;        
  ,       . 
        ActiveX    -,  
    .     
     . 

    9.3.1.    

        (    
),         
       . 
             ,  
 ,         
 (    ). 
        ActiveX    ,   
        
.exe. Visual Basic         
,     .vbg.     
      . 
          : 
    1.   File  Add Project      Add 
Project   . 
     Open Project  New Project  ,     
  . 
    2.    Add Project    Standard EXE, 
   .   . 
      Project Explorer     .   
Project Explorer     (. . 9.6). 
            , 
     .   Visual 
Basic        ,   
      -. 

    9.3.2.       

         ActiveX   
        ,   
   in-process.      
 ActiveX   in-process  ,    
     ,      . 
              
     (IDE).    
       . 

     9.    ActiveX 229 
         ActiveX .   
"   ActiveX"  8 "  
 ActiveX". 
    9.3.3.      
            
   UserControl. 
      ActiveX  ,      
  . ,      
-,         .. 
         
              
UserControl         
.        . 
   ,    ,    
   ,      
   . 
       ,      
  : 
    9.4.  ,    
               
Visual Basic,   ActiveX    
,  ,   .   
,           
 . 
       ,    , 
  ,     ActiveX Control Interface Wizard. 
          Property 
  ,      
,       . 

         

  -    .
Initialize, InitProperties, Resize,   .                 
                              Paint    
-     - 

WriteProperties, Terminate,   ,  
    ,    

Initialize, ReadProperties,  .                   - 

Resize, Paint  
.           - 

Terminate, Initialize,  ,       

ReadProperties, Resize, Paint  .                 . 
   ,   -   - 

WriteProperties, Terminate   .           .   
    - 

Initialize, ReadProperties, 
.                                .              

Resize, Paint 


    230	 ,    


    9.4.1.   


    :     ActiveX   
   ,     , 
   . 

      

            
Property.         
   .   .   
"  Property   "  8 " 
  ActiveX". 
          public  
  .       ,  
  ,   PropertyChanged  
UserControl   PropertyLet  PropertySet. 
      PropertyChanged: o6bem.PropertyChanged _ 
 : 

    	 

    	       EserControl. 
    _	 ,   ,  
   . 
          Property,   
  Name: 

    Public   Property  Get  Name()   As   String 
    Name  =  txtName.Text End  Property 
    Public   Property  Let  Name(ByVal  NewName  As   String) 
    txtName.Text  =  NewName 
    PropertyChanged   "Name" End  Property 


         

         ,   
UserControl     ,  ,   
  .       
   User-Control    . 
    ,    ,    
 Label    TextBox, ,   
Property,     UserControl   
 . 
        ,    Caption 
  Label,      
 UserControl: 

    Public   Property  Get   Caption()   As   String 
    Caption  =   IblName.Caption End  Property 


     9.    ActiveX	231 


    Public   Property  Let  Caption(ByVal   NewCaption  As   String) 
    IblName.Caption   =  NewCaption 
    PropertyChanged   "Caption" End  Property 

       UserControl   ,  Caption 
       . ,  
   ,    , 
   . 

         

           
        . 
    ,    UserControl   
 ,        
,      : 

    Public Property Get ForeColorO As OLE_COLOR 
    ForeColor = Controll.ForeColor End Property 
    Public Property Let ForeColor(ByVal NewfColor As OLE_COLOR) Dim ctlElement 
As Object Controll.ForeColor = NewfColor For Each ctlElement In Controls 
    If(TypeOf ctlElement Is Label) _ 
    Or (TypeOf ctlElement Is CheckBox) _ 
    Then ctlElement.ForeColor = NewfColor Next 
    PropertyChanged "ForeColor" End Property 


    9.4.2.   

           
    ,     . 

      

             
          
 UserControl   Public Sub  Function,  
   ,       UserControl. 
         .   
" "  8 "   ActiveX". 
           UserControl 1  
,        : 

    Public Sub ShowDateO 
    MsgBox "Date is: " & Now () End Sub 
    Private Sub Form_Load() UserControll.ShowDate End Sub 


    232	 ,    


         

            
  ,      
; -     . 
         IDFocus,    
   -: 

    Public   Sub   IDFocus() txtEmpID.SetFocus End  Sub 
    Private   Sub   cmdSet!dFocus_Click() 
    Controll.IDFocus End  Sub 

         txtEmpID     
UserCon       ,   
    txtEmpID   UserControl. 

    9.4.3.     

          ,  
  . ,    
  ,         
.        
,  i    . 
       ,     
    .   ,  
        
   . , BackColor     
   Visual Basic.      
 ,    . 

     AmbientChanged 

     AmbientChanged     .  
        
    ,      
  AmbientChanged.     , 
PropertyName,    . 

     Ambient 

     Ambient      . 
    ,    ,    Ambient  
  AmbientChanged: 

    Private   Sub  UserControl_AmbientChanged(PropertyName  As   String) 
    If   PropertyName   =   "BackColor"   Then 
    UserControl.BackColor  =  Ambient.BackColor 
    End   If End   Sub 

      ,  ,    , 
  BackColor ,     
      . 


     9.    ActiveX	233 


      Enabled 

     Enabled    .     
  UserControl,      
 Property  Enabled        Enabled. 
             
,    Enabled   
 Enabled,  ,       
 .    Enabled   
 Enabled,   Procedure Attributes   Tools   
 Enabled   Procedure ID. 

    9.4.4.      

          , 
     .   
     ,   
      . 
              
   PropertyBag,     
ReadProperties  WriteProperties. 
           PropertyBag  
      WriteProperty: 

    Private   Sub  UserControl_ WriteProperties(PropBag As   PropertyBag) 
PropBag.WriteProperty  "Caption",   _ 
    Caption,   Username End  Sub 

           
ReadProperties   ReadProperty  PropertyBag. 
     ReadProperty   : ,   
,    .     , 
 ReadProperty   .      
,     . 
       ,    ReadProperty  
    Caption: 

    Private   Sub  UserControl  _ ReadProperties(PropBag  As   PropertyBag) '  
         On  Error  Resume  Next 
Caption  =   PropBag.ReadProperty   "Caption",   _ 
    Username 
    ' ...    End Sub 


       

              
 . Visual Basic        
 (.frm, .dob, .pag  .ctl),     
    ,   .  
       ,  
  . 


    234  ,    


    9.4.5.    

     Visual Basic  5.0   ,  
    .   
        
    .    
         
     Auto List Members ( 
Editor   Options). 
          ,  
   Public.      
public ,   ,  ,   , 
UserControl  UserDocument. 
         ,   
 ,       
 : 

    Public  Enum  TempBoilCelsius 
    msubWater   =   100   '    
    msublron  =   2750   '    
    msubNitrogen   =   -195.8   '    
    msubGold  =   2807   '    End  Enum 
       , ,     
Temp,     : 

    . 9.8.     Auto List Members. 


    9.4.6.     


    :     .   
 " "  8 "   ActiveX". 
         ,    
,  ,   RaiseEvent,  . 


     9.    ActiveX 235 


         UserControl   Click: 
    '      public     Click      Public   Event   ClickO 
         Click: 

    RaiseEvent Click 

         
           ,  
     
 . 
          UserControl: 
    1.    UserControl  . 
    2.        . 
          KeyPress   
 TextBox: 

    '     TextBox Public Event KeyPressl(KeyAscii As Integer) 
    Private Sub Textl_KeyPress(KeyAscii As Integer) 
    RaiseEvent KeyPressl (KeyAscii) End Sub 
     ,       . 
    '     : 
    Private Sub ClientControl_KeyPressl(KeyAscii As Integer) 
    '     . 
    '    KeyAscii  ByRef,    
    '   . 
    KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub 
    1 


    9.4.7.   


    ActiveX Control Interface Wizard 

     Visual Basic   ActiveX Control Interface Wizard,  
    .    
 ,   ,     
 . 
    ActiveX Control Interface Wizard    
      UserControl  
  .    
 . 
     ,       , : 
    	     Property; 
    	     Sub  Function; 
    	    . 
             
     . 


    236  ,    


    . 9.9.  ActiveX Control Interface Wizard    
 . 

       ,   ,    
   .   ( ) , 
    . 

    My Custom Members: 

    . 9.10.  ActiveX Control Interface Wizard    
  ,    . 


     9.    ActiveX	237 


    . 9.11.  ActiveX Control Interface Wizard   . 
   ,      
 ( Public Name)     
  ( Control  Member). 

    ActiveX Control Interface Wizard - Set Attributes 

    . 9.12.  ActiveX Control Interface Wizard    
 ,        
  . 


    238    


    9.5.    

      (  Property Pages)   
    ActiveX.     
         
.    ,    . 
    ,    Font,     
,        ,   
      . 

    9.5.1.     

             
  (      Property Pages  
Visual Basic). 

    . 9.13.    Property Pages:  ""  
""  , "Font"  "Color"  . 

           : 
    1.   Project  Add Property Page. 
    2.   New   Add Property Page   
 Property Page. 
          ,   
    ,      
  (. 9.14). 

    9.5.2.     

            ,    
 .          
,      -. 


     9.    ActiveX 239 


    . 9.14.       . 

     SelectionChanged 

     SelectionChanged     ,  
   .      
    ,     . 
          Interval   
Timer         : 

    Private   Sub   PropertyPage_SelectionChanged() txtTimerlnterval.Text   =  _ 
    SelectedControls(0).Interval End  Sub 


     SelectedControls 

     SelectedControls      , 
     .   
    . 
           
 Count  SelectedControls.    1 
,        . 

     Changed 

      Visual Basic  ,     
 ,    True  Changed  
PropertyPage.      Apply    
Property Pages. 
    ,     Visual Basic,   
         Interval: 

    Private   Sub   txtTimerlnterval^ 
    Changed  =  True End  Sub 
    Change() 


    240    


     ApplyChanges 

             
  ApplyChanges. 
     ApplyChanges    : 
    	       Property Pages; 
    	  Apply; 
    	      Property Pages. 
          objControl, 
       ,  
   Interval    : 

    Private Sub PropertyPage_ApplyChanges() 
    Dim objControl As Variant 
    For Each objControl In SelectedControls 
    objControl.Interval = txtTimerlnterval.Text 
    Next End Sub 


    9.5.3.     

        ActiveX      
 .         
  . 

          

              
   Connect Property Pages.     
  ,         
 PropertyPages      (...)   . 

    . 9.15.      . 


     9.    ActiveX	241 


         

           . 
    .    ,  
      ,        
    . 
        ,    
,     . , , 
    ,     
 (...).        . 
         : 
    1.   Project Explorer   UserControl    View 
Code       UserControl    
   View Code,     . 
    2.   Tools   Procedure Attributes    Procedure 
Attributes   Advanced.       
 (. . 8.4). 
    3.   Name  ,     
 . 
    4.   Use this Page in Property Browser     
   Apply  . 

    9.5.4.     

          
     .  
       , 
,       . 
    Visual Basic     : 
    	StandardFont; 
    	StandardColor; 
    	StandardPicture. 
        Font, OLE_COLOR  Picture   
        
.       (...)      
 , ,    ,   
  . 
     ,     Visual Basic  
    Property Pages,   , 
   Connect Property Pages (. . 9.13  9.15). 

    9.6.    

           
 ,   ,    Application 
Setup Wizard        . 

    9.6.1.    

         ActiveX Visual Basic 
  .    
        
        . 


    242	   

    Visual Basic      
      ..  Setup  
      . 
             
,  Setup       
.    ,      
   . ,    
   ,    
       .   
        
 ,      
        
    Setup  . 

      

             
General   Project Properties   Require License Key 
(. . 8.8). 
       . Visual Basic   .vbl,   
     . Application Setup 
Wizard      . 

    9.6.2.      

       ActiveX,   Visual Basic,  
,       . 

     Application Setup Wizard 

             
Application Setup Wizard,    ,   ,  
  ,         . 
    Application Setup Wizard  ,   ,  
    ActiveX      
Visual Basic.     , , 
        
,    .vbl. 
         ,     
  . Application Setup Wizard     
      Setup. 
       Setup     ActiveX: 
    1.     ,    
    . 
    2.   .. 
    3.  Application Setup Wizard. 

      Setup   

          , 
Application Setup Wizard   Setup,   
   .vbl   .   , 
  .vbl     . 


     9.    ActiveX	243 


        .vbl, Application Setup Wizard  
 -.    Do not install this file 
(He   ),       ,  
     ,    
    .   ,  
        
,           
    . 
    Application Setup Wizard ( Setupwiz.exe)    
 \VB\Setup-kit\Kitfi!32\   Visual Basic.    
   ,     
  : 
          :   Setup,  Setup  
  Internet  .; 
          ,  ,   
(Diskl, Disk2  . .); 
          ; 
           ActiveX,   ; 
         ; 
       . 
