sample-ole-container library


This project contains an example program that demonstrates use of the low-level OLE interface to support embedding of graphical objects produced by other programs. It uses the low-level OLE API for the compound documents and the low-level Win32 API for user interface.

See the Functional Developer "OLE, COM, ActiveX and DBMS" reference manual for documentation of the OLE library which the program uses.

The example was translated to Dylan from a C++ program in directory "\MSTOOLS\samples\ole\simpcntr\" from the Microsoft Win32 SDK of July 1995. The "README.TXT" file there describes it as:

This sample is the simplest OLE 2.0 container that can be written and still support the visual editing feature. The sample has no native file format, and can only support one OLE object at a time. The Insert Object command is used to create an object.

This example intentionally maintains the style of the original C++ version, and uses the same low-level OLE and user interface APIs as the C++ program. See the example project win32-ole-container for an implementation of the same functionality using the higher-level OLE container framework provided by Functional Developer. The example project sample-duim-container additionally uses the Functional Developer DUIM framework for its user interface.

.

Program internals

Program execution begins in file last.dylan, which calls WinMain in simpcntr.dylan, which contains the Windows event loop. That same file contains function main-wnd-proc which handles Windows events. When the "Insert Object" command is invoked from the "Edit" menu, the function InsertObject, in file doc.dylan, calls OleUIInsertObject from the OLE-Dialogs library to handle choosing and connecting to an object.

The original program included code for managing color palettes, but all of that is currently commented out (note comments flagged with "???") because the functions used were not yet supported by the Win32-GDI library at the time of this writing. However, the program seems to work fine without it so far. Note also that the entire source file stdpal.dylan is currently omitted from the project.

After building the program, run it and use the "Insert Object" command from the "Edit" menu to choose an object from among those registered on your system. Some may directly draw in the container window, while others pop up a separate application window in which you create the object, which is inserted in the container when you exit the application. Some objects add their own commands to the menu bar. You can invoke "New" from the "File" menu to erase the current object and enable selecting another.