📄 vcg10.htm
字号:
<BR>
<LI>Sample code: Visual C++ 4 includes a number of sample controls that you can work with to learn some of the OLE control programming techniques. (See the list of OLE sample controls a little later in this chapter.)
<BR>
<BR>
<LI>Books Online: Books Online lets you easily look up information on OLE controls.
<BR>
<BR>
<LI>Test Container: You can use OLE Control Test Container to test your newly developed OLE controls. This program lets you test all of a new control's functionality.
<BR>
<BR>
</UL>
<P>Many of the new tools used to create OLE controls appear on the Visual Workbench Tools menu:
<BR>
<UL>
<LI>Register Control lets you register your OLE control in the system registry.
<BR>
<BR>
<LI>OLE Control Test Container lets you test your newly developed OLE control. It also offers the capability to test all of an OLE control's features.
<BR>
<BR>
<LI>OLE Object View, shown in Figure 10.3, is a utility that lets you gather information about installed OLE objects (including controls).
<BR>
<BR>
</UL>
<P><B><A HREF="10vcg03.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/10vcg03.gif">Figure 10.3. OLE Object View, showing the OLE Grid Control.</A></B>
<BR>
<P>Chapter 16, "Creating OLE Controls with Visual C++ 4," describes each of these tools in detail.
<BR>
<P>For earlier versions of Visual C++ that use the CDK, the CDK is installed in a directory called either CDK32 (for Visual C++ 2.0) or CDK16 (for 16-bit versions of Visual C++) under Visual C++'s main directory (MSVC20 in most installations). Visual C++ 4 is installed in the directory MSDEV, and the OLE control components are integrated directly into the standard Visual C++ directory structure.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE><B>NOTE</B>
<BR>
<BR>Even though this book deals with the 32-bit compiler for Visual C++ 4.0, 16-bit products are mentioned because some programmers might have to maintain compatibility with existing versions of Windows for their applications.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>There is a directory that contains sample source code for a number of OLE controls included with Visual C++ 4. The sample controls that are supplied with Visual C++ 4 (in the \MSDEV\SAMPLES\MFC\CONTROLS folder on the Visual C++ 4 CD) include the following:
<BR>
<UL>
<LI>BUTTON: A simple pushbutton control.
<BR>
<BR>
<LI>CIRC1: A control that implements a custom pushbutton.
<BR>
<BR>
<LI>CIRC2: An advanced version of CIRC1.
<BR>
<BR>
<LI>CIRC3: A more advanced version of CIRC1.
<BR>
<BR>
<LI>DB: A database access control that uses simple ODBC and SQL...() functions to access a database.
<BR>
<BR>
<LI>LICENSED: An example of a licensed control.
<BR>
<BR>
<LI>LOCALIZE: A control showing localization techniques.
<BR>
<BR>
<LI>PAL: A color palette control.
<BR>
<BR>
<LI>PUSH: A custom pushbutton control.
<BR>
<BR>
<LI>REGSVR: A utility that can be used to register an OLE control.
<BR>
<BR>
<LI>SMILEY: A control that shows drawing icons in the control's client area.
<BR>
<BR>
<LI>SPINDIAL: An implementation of a spindial control.
<BR>
<BR>
<LI>TIME: A control that triggers an event at a timer interval.
<BR>
<BR>
<LI>XLIST: A custom list box control.
<BR>
<BR>
</UL>
<P>OLE controls are supported by a number of runtime DLL files when they're developed with either Visual C++ 1.5x or Visual C++ 2.x. OLE controls that are developed with Visual C++ 4 are supported directly by the system OLE DLL files. The Visual C++ 2.x and Visual C++ 1.5x DLL files include the following:
<BR>
<UL>
<LI>Visual C++ 1.5x: OC25.DLL contains the release (nondebug) version of the 16-bit OLE controls.
<BR>
<BR>
<LI>Visual C++ 1.5x: OC25D.DLL contains the debug version of the 16-bit OLE controls.
<BR>
<BR>
<LI>Visual C++ 2.x: OC30.DLL contains the release (nondebug) version of the 32-bit OLE controls. This 32-bit version of OLE controls supports ANSI/DBCS.
<BR>
<BR>
<LI>Visual C++ 2.x: OC30D.DLL contains the debug version of the 32-bit OLE controls. This 32-bit version of OLE controls supports ANSI/DBCS.
<BR>
<BR>
<LI>Visual C++ 2.x: OC30U.DLL contains the release (nondebug) version of the 32-bit OLE controls. This 32-bit version of OLE controls supports Unicode.
<BR>
<BR>
<LI>Visual C++ 2.x: OC30UD.DLL contains the debug version of the 32-bit OLE controls. This 32-bit version of OLE controls supports Unicode.
<BR>
<BR>
</UL>
<P>The appropriate DLL files are also installed in the WINDOWS\SYSTEM directory (or WINNT\SYSTEM32 for Windows NT) and are registered by the CDK setup program. If the registration database becomes corrupted and has to be replaced, you'll need to reinstall the CDK to use OLE controls when using Visual C++ 1.5x or Visual C++ 2.x. Of course, Visual C++ 4 eliminates this problem, because it doesn't have separate DLL files for OLE controls.
<BR>
<BR>
<A NAME="E68E60"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>A Few OLE Definitions</B></FONT></CENTER></H3>
<BR>
<P>This section defines a few of the more common terms used with OLE. We've included these definitions here because many of these terms aren't defined in a single location. Understanding each of them will greatly help you comprehend OLE and OLE controls.
<BR>
<BR>
<A NAME="E69E167"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>OLE</B></FONT></CENTER></H4>
<BR>
<P><I>OLE</I> stands for Object Linking and Embedding. It was created as a wrapper for the original concept of Dynamic Data Exchange (DDE). OLE defines a set of standard interfaces to objects, such as IUnknown.
<BR>
<BR>
<A NAME="E69E168"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Objects</B></FONT></CENTER></H4>
<BR>
<P>An <I>object</I> is an item that is placed in a document. Objects may be either linked, meaning that the object's data is external to the containing document, or embedded, meaning that the object's data is internal to the containing document. Objects may also be referred to as <I>servers</I>.
<BR>
<BR>
<A NAME="E69E169"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Containers</B></FONT></CENTER></H4>
<BR>
<P>A <I>container</I> is a document into which objects may be embedded or linked. Generally, the term <I>container</I> refers to either a container application such as Word, Excel, or Access, or a container document such as a Word document, an Excel worksheet, or an Access report or form. Containers may also be referred to as <I>clients</I>.
<BR>
<BR>
<A NAME="E69E170"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Linked Objects</B></FONT></CENTER></H4>
<BR>
<P>A <I>linked object</I> is an object whose basic data isn't part of the containing document. The information that is part of a linked object tells where the actual information is located and includes a view of the object.
<BR>
<P>When the user decides to change the object, the object's server uses the link information to retrieve the object's data. When a linked object is modified outside the container application, the container's representation of the object's data is also updated.
<BR>
<BR>
<A NAME="E69E171"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Embedded Objects</B></FONT></CENTER></H4>
<BR>
<P>An <I>embedded object</I>'s data resides in the container document. Changes to the embedded object's original source data don't affect the embedded object or its data. An embedded object can be modified if necessary.
<BR>
<P>A document with embedded objects is larger than a document that has linked objects, because the embedded objects' data must be included in the containing document.
<BR>
<BR>
<A NAME="E69E172"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Windows Objects</B></FONT></CENTER></H4>
<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -