Copyright © 2001, 2002 ESRI. All rights reserved.
Introduction to Programming ArcObjects with VBA
基于 COM 接口
编程基础( I )
6-2
Introduction to Programming ArcObjects with VBA
Copyright © 2001, 2002 ESRI. All rights reserved.
Lesson overview
COM: 组件对象模型 Component Object Model
使用 COM 类 Working with COM classes
接口 Interfaces
多态 Polymorphism
接口查询 QueryInterface
测试一个对象的引用 Testing an object reference
Is it nothing?
What type of object is it?
6-3
Introduction to Programming ArcObjects with VBA
Copyright © 2001, 2002 ESRI. All rights reserved.
Introducing COM
COM is a standard for creating classes
Classes can be reused between applications
Independent of programming language
All ArcObjects are COM classes
Technologies based on COM
Object Linking and Embedding (OLE)
OLE DB
ActiveX is any technology built on COM
DCOM and COM+
6-4
Introduction to Programming ArcObjects with VBA
Copyright © 2001, 2002 ESRI. All rights reserved.
COM classes have interfaces
对象拥有一个或多个接口
接口是定义了一组方法和属性的逻辑关系
与对象的通信是通过接口来进行的
RaceCar
Accelerate
Brake
Fuel
停靠站
圈速度
IRace
IDrive
垃圾车
加速
刹车
燃料
拾起
倾倒
IGarbage
IDrive
6-5
Introduction to Programming ArcObjects with VBA
Copyright © 2001, 2002 ESRI. All rights reserved.
Instantiate COM classes with an interface
Dim <variable> As <some interface>
Interfaces group properties and methods
Dim pGarbage As IDrive
Set pGarbage = New GarbageTruck
pGarbage.Fuel = "Full"
pGarbage.Accelerate
Working with ArcObjects COM classes
GarbageTruck
Accelerate
Brake
Fuel
PickUp
Dump
IGarbage
IDrive