OWLNext 7.0
Borland's Object Windows Library for the modern age
|
An ObjectWindows SDI application can use a frame window that does not contain a client window.
Similarly, an ObjectWindows MDI application can use MDI child windows that do not contain a client window. Omitting the client window makes it harder to convert the application from one kind of frame to another-SDI, MDI, or decorated frame. It is also awkward when building OLE 2 applications.
For example, it is easier for a container's main window to make room for a server's tool bar if the container owns a client window. To take full advantage of the ObjectWindows OLE classes, your application must use a client window. For more information about using client windows, see the ObjectWindows Tutorial.
The following topics discuss setting up the Client Window.
ObjectWindows provide several classes that include default implementations for many OLE operations. To adapt an existing ObjectWindows program to OLE, change its derived classes to inherit from the OLE classes.
The TOleFrame and TOleMDIFrame classes both derive from decorated window classes. The OLE 2 user interface requires that containers be prepared to handle tool bars and status bars. Even if a container has no such decorations, servers might need to display their own in the container's window. The OLE window classes handle those negotiations for you. The following code shows how to change the declaration for a client window. Boldface type highlights the changes.
Before:
After changing the declaration to derive from an OLE-enabled class:
ObjectWindows applications create their main window in the InitMainWindow method of the TApplication-derived class. Typically, SDI applications also create their initial client window in the InitMainWindow function. The following code shows the typical sequence.
When used in the OLE frame and client classes, however, that sequence presents a timing problem for OLE. The OLE client window must be created after the OLE frame has initialized its variables pointing to ObjectComponents classes. To meet this requirement, an SDI OLE application should create only the frame window in the InitMainWindow function. Create the client window in the InitInstance method of your application class. Boldface type highlights the changes.
For every client window capable of having linked or embedded objects, you must create a TOcDocument object to manage the embedded OLE objects, and a OCF.HLPTOcView" object to manage the presentation of the OLE objects. The CreateOcView method from the TOleWindow class creates both the container document and the container view. Add a call to CreateOcView in the constructor of your TOleWindow-derived class.
Notice that unlike the TWindow constructor, the TOleWindow constructor does not require a title parameter. It is unnecessary because TOleWindow is always the client of a frame. TWindow, on the other hand, can be used as a non-client window-a pop-up, for example.