ImageVerifierCode 换一换
格式:DOCX , 页数:18 ,大小:174.77KB ,
资源ID:6621154      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6621154.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Creating ActiveX Controls for InTouch Using Microsoft Visual Basic.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Creating ActiveX Controls for InTouch Using Microsoft Visual Basic.docx

1、Creating ActiveX Controls for InTouch Using Microsoft Visual BasicCreating ActiveX Controls for InTouch Using Microsoft Visual BasicAll Tech Notes and KBCD documents and software are provided as is without warranty of any kind. See the Terms of Use for more information.Topic#: 001010Created: Decembe

2、r 6, 2001IntroductionThis document will help users understand how to leverage ActiveX technology to create add-on controls to be used inside InTouch applications. Many programming tools can be used to create ActiveX controls, one of the most popular being Visual Basic (VB). It is asumed that you hav

3、e a working knowledge of Visual Basic.The first part of this document presents some key concepts in ActiveX; the second section shows how to actually use VB to create a sample ActiveX control.Note: This document is not intended to explain, in just a few pages, how ActiveX controls work, but rather t

4、o give an overview of ActiveX and how to create a simple control in VB. Please refer to the Microsoft VB documentation and MSDN for complete details.Part A - Theory of ActiveX Controls and InTouch ActiveX ContainerActiveX Controls - A Short DefinitionInter-process/Inter-node communication and intera

5、ction between different software packages are the driving force behind Dynamic Data Exchange (DDE), Object Linking and Embedding (OLE), Component Object Model (COM, DCOM, COM+), and ActiveX, among other technologies.An ActiveX control is a COM object that supports a customizable, programmatic interf

6、ace using the methods, events, and properties exposed. Because ActiveX Controls are not executable programs, they must be instantiated and used inside other applications called ActiveX containers. Examples of ActiveX containers include Internet Explorer, Microsoft Office, and windows in InTouch appl

7、ications.ActiveX Controls TheoryInterfaces: Properties, Methods, and EventsActiveX containers and ActiveX controls communicate via interfaces that the controls expose to the outside world. An interface can include a number of Properties, Methods, and Events. Properties define the behavior of the con

8、trol. For example, Color, Font, Size, and Data Source Name can be properties exposed by a control. When ActiveX controls are used inside InTouch, Properties can be bound to tagnames in different ways, as will be shown later. Methods are functions exposed by the control that allow the container to tr

9、igger actions inside the control. To call a method, reference the name of the control, then the name of the function: MyControl3.Connect, YourControl1.CalAvg(1,2,3), #ThatControl7.Do Stuff(); (This last example shows the proper syntax inside InTouch scripts.) Events allow an ActiveX Control to signa

10、l to its container when an Event takes place inside the control. For example, Click, MouseMove, or DoneIt.Other concepts involving ActiveX controls include Identification, Encapsulation, Property Pages, Persistence, and Compatibility. These are briefly explained in the following paragraphs.GUIDsComp

11、onents in Microsoft Windows, which include ActiveX controls, have a 128-bit unique identification known as the Globally Unique IDentifier (GUID). GUIDs are based on the Date, Time, and the PC where they are generated (the algorithms used to create the GUIDs were designed by the Open Software Foundat

12、ion -OSF Distributed Computing Environment -DCE). GUIDs identify entries in the Windows registry, such as ActiveX controls, classes, Interfaces, and so on. For example, the GUID for the Calendar control included with MS Office XP is stored in the registry as:HKEY_CLASSES_ROOTCLSID8E27C92B-1264-101C-

13、8A2F-040224009C02Encapsulation: Containment and AggregationActiveX controls can have embedded ActiveX Controls. In that case, the outer control is called a Composite control and the inner controls are constituent controls. Containment takes place when a control exists within another control. Aggrega

14、tion (or delegation) is when the external control uses the constituent controls interface as its own. It is transparent to the client (container) who does the actual job. The concept of encapsulation is presented in the practical section of this Tech Note.Encapsulation is important because it allows

15、 the use of ActiveX controls inside InTouch when they expose properties other than the basic types that are supported in InTouch 7.x, i.e., Discrete, Integer, Real, and Message. The unsupported control can be used as a constituent control for another control that limits the properties to fore-mentio

16、ned types.Property PagesActiveX controls and containers typically include windows or dialog boxes to view and set the properties; these windows are called Property Pages. InTouch, an ActiveX container, has a tabbed dialog box that displays user-defined properties or container-defined properties; All

17、 controls inside InTouch have default properties that include ControlName, position (Left, Top, Width, Height), and Visible (in Runtime) as shown in Figure 1.Visual Basic, another ActiveX container, includes Font, Color, and Picture as default properties.Figure 1: Default Properties in the InTouch 7

18、.x ActiveX ContainerPersistencePersistence allows components to save and later retrieve data. Most containers support IPersistPropertyBag, an intrinsic interface that greatly simplifies the process of reading and writing data for controls. ActiveX controls in Visual Basic include a number of methods

19、, such as WriteProperties and ReadProperties to invoke the PropertyBag object.For example, the following line saves Wonderware to the m_strCompany string property:PropBag.WriteProperty (Wonderware, mbytMyData)CompatibiltyA compiled ActiveX control includes GUIDs for the control itself and for any ob

20、ject classes or interfaces that it implements. Containers use the class ID to request the control to create an object, and then query the object for the interface ID (IID); an error occurs if it is not found.By default, Visual Basic sets the compatibility for ActiveX controls to Project Compatibilit

21、y, which means new IDs are generated after each recompilation (see Figure 2). Once a control is released, it is recommended to switch from Project (or No Compatibility) to Binary Version Compatibility. Please refer to MSDN or the Visual Basic documentation for more details.One Golden rule in COM is

22、that you must never change an objects interface once it has been compiled and released because you could be breaking applications that use the object. Create new objects if necessary, and name them with a suffix that identifies subsequent releases: MyObject2, MyObject3, and so on.Figure 2: Default V

23、ersion Compatibility in VB ActiveX Control ProjectsInTouch as an ActiveX ContainerInTouch 7.x handles ActiveX controls as if they are wizards. Wiz.ini is a file in the InTouch directory that keeps track of what wizards have been installed in WindowMaker. Note the difference between registration of a

24、n ActiveX control in Microsoft Windows (via regsvr32) and installation. Registration makes any container capable of creating instances of a control; installation in WindowMaker allows the control to be configured. Here is an example of the Wiz.ini entries with 4 ActiveX controls installed:Group0001C

25、ount=4Name=ActiveX ControlsItem0001=OCXGOT, 1Item0002=OCXGOT, 2Item0003=OCXGOT, 3Item0004=OCXGOT, 4Unlike with regular InTouch wizards, the entries in the Wiz.ini do not indicate by name which ActiveX control is which; that job is done in the Ocx.ini file. Ocx.ini indicates the name and GUID for the

26、 installed controls. For example:ActiveX ControlsCount=4Item0001=8BD21D60-EC42-11CE-9E0D-00AA006002F3,Microsoft Forms 2.0 ToggleButtonItem0002=8BD21D10-EC42-11CE-9E0D-00AA006002F3,Microsoft Forms 2.0 TextBoxItem0003=EAE50EB0-4A62-11CE-BED6-00AA00611080,Microsoft Forms 2.0 TabStripItem0004=79176FB0-B

27、7F2-11CE-97EF-00AA006D2776,Microsoft Forms 2.0 SpinButtonWiz.ini and Ocx.ini are text files stored in the InTouch installation directory and apply to any InTouch application. In contrast, ITGUID.cfg and ITOcx.cfg are binary files that are application-specific. These files keep track of what ActiveX

28、controls have been used (and how many times) in the application, so that unique names are guaranteed and a new name generated when creating a new instance of a control.LimitationsDevelopers often compare InTouch ActiveX containers with other containers, such as Microsoft Internet Explorer or Visual

29、Basic. It is very important to understand that not all containers include the same functionality, and InTouch has a number of limitations that must be observed when creating ActiveX controls for InTouch applications: Supported Data TypesOnce again, remember that InTouch does not support data types o

30、ther than Discrete (boolean), Integer (32-bit numbers), Real (floating point IEEE notation with 32 bits), and Message (strings up to 131 characters). Unsupported data types include variant, pointers, arrays, structures, and parameterized properties.If you are planning to use an ActiveX control that

31、exposes properties, methods, and events that do not meet the requirements for InTouch data types, you need to create an ActiveX Control that encapsulates, or wraps the original ActiveX control and massages the unsupported property so that InTouch can use it. It is very easy to create properties and

32、methods for a wrapper (external) control that are mapped to properties and methods in the constituent (internal) control. The following is an example of a wrapper function to encapsulate an unsupported function that uses the Variant data type.Member variable defined as variantDim m_Prop1 As Variant.Public Function WrapperFunction() As String Dim MyVariant As Variant MyVariant = UnsupportedFunction(m_Prop1) WrapperFunction = MyVariantEnd FunctionPublic Function UnsupportedFunction(ByVal

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1