基于COM接口编程基础I.ppt

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Introduction to Programming ArcObjects with VBA
6-2
Introducing COM
COM is a standard for creating classes Classes can be reused between applications
Independent of programming language
接口Interfaces 多态Polymorphism 接口查询QueryInterface
测试一个对象的引用Testing an object reference
Is it nothing? What type of object is it?
Copyright © 2001, 2002 ESRI. All rights reserved.
基于COM接口 编程基础(I)
Copyright © 2001, 2002 ESRI. All rights reserved.
Introduction to Programming ArcObjects with VBA
Lesson overview
COM: 组件对象模型Component Object Model 使用COM类Working with COM classes
Copyright © 2001, 2002 ESRI. All rights reserved.
Introduction to Programming ArcObjects with VBA
6-8
Using methods and properties
Dim the variable pointing to an interface
Instantiate the object (Set)
Call methods, set properties
'Create a new RaceCar with IDrive
Dim pCar As IDrive Set pCar = New RaceCar
IDrive
pCar.Accelerate
Copyright © 2001, 2002 ESRI. All rights reserved.
Introduction to Programming ArcObjects with VBA
6-3
COM classes have interfaces
对象拥有一个或多个接口 接口是定义了一组方法和属性的逻辑关系 与对象的通信是通过接口来进行的
6-7
ArcObjects 多态
许多ArcGIS的类都表现出多态的特性 General interfaces for all subtypes
ILayer: All layer types (raster, tin, feature, etc.) IGxFile: All ArcCatalog file types (shapefile, map, table, etc.) IActiveView: Map (data view) and PageLayout (layout view) Several others …
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-6
多态
许多不同的类可以支持相同的接口
拥有相同的所有的方法和属性 可以有不同的执行方式和拥有不同的属性值
IDrive
燃料 加速 刹车
Copyright © 2001, 2002 ESRI. All rights reserved.
Introduction to Programming ArcObjects with VBA
Dim pGarbage As IDrive Set pGarbage = New GarbageTruck IDrive
pGarbage.Fuel = "Full" pGarbage.Accelerate
IGal Accelerate Brake
Dump PickUp
6-4
Working with ArcObjects COM classes
Instantiate COM classes with an interface
Dim <variable> As <some interface>
Interfaces group properties and methods
Copyright © 2001, 2002 ESRI. All rights reserved.
Introduction to Programming ArcObjects with VBA
6-5
More on interfaces …
一个组合音响的例子
一个对象可以播放收音机、磁带、CD 必须使用适当的接口 如果选择了播放磁带的接口,则不能收听收音机
pCar.Fuel = "Full"
IDrive IGarbage
垃圾车 燃料 加速 刹车
倾倒 拾起
IDrive IRace
RaceCar Fuel Accelerate Brake
圈速度 停靠站
Copyright © 2001, 2002 ESRI. All rights reserved.
Introduction to Programming ArcObjects with VBA
Dim pBBox As ITape Set pBBox = New BoomBox pBBox.FM = True
IRadio ITape ICD
Copyright © 2001, 2002 ESRI. All rights reserved.
Introduction to Programming ArcObjects with VBA
相关文档
最新文档