C++Builder And ACtiveX的標頭檔

來源:互聯網
上載者:User
來源:http://www.temporaldoorway.com/programming/cbuilder/activex/headerfiles.htm
註:先摘錄,研究後寫成中文
The Header Files From An Imported Control

Introduction

There are several header files generated by the act of importing an ActiveX control into C++ Builder. This article explains what they are, what they contain, and what they are used for.

This material is specific to BCB4 Patch 1 and above.

The Files

The following files are generated by importing a control

  • <control>OCX.h and .cpp - These are the VCL representation of the control itself. The class implemented by these files can be instantiated with the normal VCL "new".

  • <control>TLB.h and .cpp - These are the classes, templates, and function implementations / constant declaration / definitions for the classes specified in the control type library. These are not able to be instantiated using the VCL "new", as discussed later in this document.

The OCX File

This is a fairly simple file for those used to reading VCL header files. The control class definition is present. This definition contains VCL representations of the control properties, methods, and events. VCL style classes to support the various subobjects are not generated - unfortunately, this is as deep as VCL support for the control goes. If you need to use subobjects of this class, you will generally have to use the classes declared in the TLB files. In most cases, this will be similar to working with VCL objects - until you need to create one from scratch, as discussed later.

The TLB File

This is a much more complex file. For a reasonably sized control, it can be nearly 10,000 lines. The size of these files for large applications like Excel is truly legendary.

The following are the contents of this file

  • class GUID, DIID etc constants; here declared as extern and initialized in the TLB .cpp; NOTE: If you use the control in a package, you must change each extern const GUID declaration in the .h to extern __declspec (package) const GUID, or else the declarations will not be visible in using applications or packages.

For each class in the TLB...

  • The "class" declaration; this is an interface and is an abstract class. It cannot be instantiated.

  • The typedefed pointer to "class" ("class"Ptr).... a smart-interface wrapper. Initialized by a call to the creator class (see CoClass below), or a method on an existing interface that returns one.

  • "class"DispT<> a template class which is the non-abstract version of the IDispatch interface to the "class". It is used to call Invoke on the underlying interface and to hide that aspect of interacting with the interface.

  • "class"Disp a typedef to conceal the "templateness" of the DispT class.

  • TCoClassCreatorT<"class"Disp, "class", &CLSID_"classwithoutprefix", &DIID_"class"Co"classwithoutprefix"> used to set up new instances of the specified class. This is done with the Create method.

Conclusion

Though complex, the files generated for an imported control can be more easily used when they are understood. This article outlines thei contents and function of these files.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.