Flylib.com

Books Software

 
 
 

The Edit Menu

Chapter 25 - Getting Started with OLE

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Testing the Container Application
The container application can now be tested . Remember that the container application was produced as a template, without additional functionality added. However, what you will see in the next few pages is a very complete and functioning application.
The container application can be started by typing Cnt at the command line or run directly from the integrated environment of the Visual C++ compiler. Figure 25-10 shows the initial container window.
Figure 25-10: The initial window for the Cnt container application
This container can use objects from any server. For this example well insert an Excel spreadsheet into the container. To select Excel as the server, open the containers Edit menu and use the Insert New Object… menu option. This will open the Insert Object dialog box, as shown in Figure 25-11.
Figure 25-11: The Insert Object dialog box allows the selection of an Excel worksheet
From the Insert Object dialog box, choose Microsoft Excel Worksheet as the object to embed in the container.
Figure 25-12 shows the initial insertion of the object into the container document with data entered in various cells .
Figure 25-12: The Excel worksheet is inserted into the Cnt container
Dont forget, you gained all of this functionality without writing one line of code. The AppWizard has made it very easy to develop OLE container and server applications. As a little project, why not create your own server application. Then, to test your skills further, insert a server object from this application into the Cnt container.

Books24x7.com, Inc 2000 –  

Chapter 25 - Getting Started with OLE

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Whats Coming?
OLE is truly a complicated subject, but one worthy of your attention. The smart money is on building OLE applications with the help of the AppWizard and the MFC library. Once you master OLE concepts, using the AppWizard makes actual project creation a snap.
We recommend studying articles on OLE and COM that can be found in the Microsoft Systems Journal .
In the next chapter, we will examine another exciting subject: ActiveX controls.

Books24x7.com, Inc 2000 –  

Chapter 26 - Getting Started with ActiveX Controls

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Chapter 26: Getting Started with ActiveX Controls
Overview
You are already familiar with a wide variety of Windows controls such as radio buttons , checkboxes, list boxes, and so on. Many developers also design their own controls. This special group of controls is known as ActiveX or custom controls. As Windows evolved from 3. x to Windows 95, 98, and NT, so have custom controls. Custom controls really had their beginning with Microsofts Visual Basic programming language. Visual Basic made it easy to implement new controls that were not part of the standard group of Windows controls. These custom controls, originally known as VBXs (after their original file extension .VBX), were specialty items. They were actually small dynamic link libraries (DLL) with .VBX file extensions. Custom controls have now evolved into 32-bit controls with new abilities . These new controls use an .OCX file extension. A good example of a custom control is a custom slide bar that might be used to control the volume in a CD-ROM player application.
There is a commercial market for well designed custom controls. However, custom controls developed commercially can also be much more complicated. Some include complete spreadsheet, image, and database capabilities within the control!
Many programmers have developed custom controls using Visual Basic and then incorporated them into their C/C++ applications. Obviously, the C/C++ language has needed its own mechanism for creating custom controls. At the same time Microsoft was developing a solution, they began the migration from 16-bit Windows 3.1 to 32-bit Windows 95 and NT. As it turns out, the hardware-specific 16-bit VBX controls will not serve the new 32-bit multiple platform environments as well as programmers desired. Thus, Microsoft decided that rather than expand the VBX specifications, it would redesign the custom control architecture to include the 32-bit platforms; thus, the new control specifications with .OCX file extensions. Under Windows 95, 98, and Windows NT, OCX controls are the natural replacement for the older VBX custom controls of Visual Basic. These new custom controls will also serve container applications such as Microsoft Access, Excel, Word, PowerPoint, and so on. The term custom control has largely been replaced with ActiveX control.
The good news concerning controls for the C++ developer is that ActiveX controls have a built-in Microsoft C++ wizard that helps build the control. This wizard is officially called the MFC ActiveX ControlWizard . The wizard builds the ActiveX control using object-oriented C++ code and takes full advantage of the MFC.
During development, your controls can be tested with the ActiveX Test Container tool. Once the ActiveX control is complete, it can be incorporated into any application that supports OLE objects. Microsoft Word, Excel, and Access are typical applications that support ActiveX controls.
  Note There is another aspect to Windows controls—controls that involve the COM object-model. This group of controls allows control usage independent of the container and thus is ideal for languages such as Visual Basic, Visual C++, and even dynamic HTML.

Books24x7.com, Inc 2000 –