4.3.2 OLESERVERDOCVTBL

The following table summarizes the callback functions needed to manipulate documents in OLE server applications. The pointers to these callbacks must be defined in an OLESERVERDOCVTBL structure, and the functions must be exported in your application's module definition file (.DEF).

Document Callback Description

Close Requests the server application to unconditionally close the document.
Execute Specifies DDE execute strings.
GetObject Requests the server application to create an OLEOBJECT structure.
Release Notifies the server application when a revoked document has terminated conversations and must be destroyed.
Save Instructs the server application to save the document.
SetColorScheme Specifies the color palette preferred by the client application.
SetDocDimensions Gives the server application the rectangle on the target device for which the object should be formatted.
SetHostNames Sets the names that should be used for window titles.

For more information about the OLESERVERDOCVTBL structure and its associated callback functions, see Chapter 7, "Callback Functions and Data Structures."

The following code example defines the OLESERVERDOC SetHostNames callback function, as used in the sample SRVRDEMO.EXE program:

/*

* DocSetHostNames DOCUMENT "SetHostNames" METHOD

*

* The library uses this method to set the name in the

* document window. This function is only called for

* embedded objects; linked objects use their filenames for

* the title bar text.

*

* LPOLESERVERDOC lpoledoc - The server document

* LPSTR lpszClient - The name of the client

* LPSTR lpszDoc - The client's name for the

* document

*

* RETURNS: OLE_OK

*/

OLESTATUS FAR PASCAL DocSetHostNames

(LPOLESERVERDOC lpoledoc, LPSTR lpszClient, LPSTR lpszDoc)

{

SetTitle (lpszDoc, TRUE);

lstrcpy ((LPSTR) szClient, lpszClient);

lstrcpy ((LPSTR) szClientDoc, Abbrev(lpszDoc));

UpdateFileMenu (IDM_UPDATE); // Update file menu so

// that it reflects the

// embedded object

return OLE_OK;

}