Communication from the OLE server DLL to server applications is done through callback functions. Callback functions, a standard Windows programming mechanism, are called directly from the server DLLs. You will need to add callbacks to your code so that the OLE DLLs can provide data to your application as well as let your application perform specific operations with that data.
When a server application is invoked, it provides the OLESVR.DLL with a data structure called a virtual table (VTBL). This VTBL contains a table of pointers to the application's callback functions. The server DLL uses these pointers to locate the application's callback functions.
For example, a server application fills a specific data structure (OLESERVERDOCVTBL) with pointers to a set of callback functions that provide object level support. These callbacks include Save, Close, SetHostNames, SetDocDimensions, GetObject, Release, SetColorScheme, and Execute, all of which are described later in this chapter.
Once the application passes the initialized VTBL to the server DLL, the DLL can call any of the functions pointed to in the table. The VTBLs allow the DLLs to call a defined set of callback functions that all OLE applications support, but which differ in operation depending on the specific needs of the application and the class of object being linked or embedded.
For a discussion of actions that affect the calling of these functions, see the section "Actions that Invoke Server Callback Functions," later in this chapter.
The server application must set up the following data structures, the prototypes of which are defined in OLE.H:
Structure Name | Contents, as defined in OLE.H |
OLESERVER | A single pointer (LPOLESERVERVTBL) to the OLESERVERVTBL structure. |
OLESERVERVTBL | Far pointers to the server callback functions. |
OLESERVERDOC | A single pointer (LPOLESERVERDOCVTBL) to the document functions VTBL. |
OLESERVERDOCVTBL | Far pointers to the document callback functions. |
OLEOBJECT | A single pointer (LPOLEOBJECTVTBL) to the object functions VTBL. |
OLEOBJECTVTBL | Far pointers to the object callback functions. |