The following table summarizes the set of callback functions needed to manipulate objects in server applications. The pointers to these callbacks must be defined in an OLEOBJECTVTBL structure, and the functions must be exported in your application's module definition file (.DEF).
Object Callback | Description |
DoVerb | Specifies what kind of action the server application should take when a user opens an object. |
EnumFormats | Enumerates the data formats that the server is capable of providing to describe an object. |
GetData | Retrieves data from the server to the client describing an object in a specified format. |
QueryProtocol | Provided for compatibility only. |
Release | Causes the server application to free the resources associated with the specified OLEOBJECT structure. |
SetBounds | Provided for compatibility only. |
SetColorScheme | Specifies the color palette to be used when the server application edits the specified object. |
SetData | Stores data in an object in a specified format. |
SetTargetDevice | Communicates information about the client application's target device for the object. |
Show | Causes the server application to show an object. |
Other optional callback functions are available; see Chapter 7, "Callback Functions and Data Structures."
The following code example defines the OLEOBJECT DoVerb callback function, as used in the sample SRVRDEMO.EXE program:
/*
* ObjDoVerb OBJECT "DoVerb" METHOD
* This method is called by the client, through the library,
* to either PLAY, or EDIT the object. PLAY is implemented
* as a beep, and EDIT will bring up the server and show the
* object for editing.
* LPOLEOBJECT lpoleobject - The OLE object
* WORD wVerb - The verb acting on the object:
* PLAY or EDIT
* BOOL fShow - Should the object be shown?
* BOOL fTakeFocus - Should the object window get
* the focus?
* RETURNS: OLE_OK
*/
OLESTATUS FAR PASCAL ObjDoVerb (LPOLEOBJECT lpoleobject,
WORD wVerb, BOOL fShow,
BOOL fTakeFocus)
{
switch (wVerb)
{
case verbPlay:
{ // The application can do whatever is
// appropriate for the object.
int i;
for (i=0; i<25;i++) MessageBeep (0);
return OLE_OK;
}
case verbEdit:
if (fShow)
return objvtbl.Show (lpoleobject, fTakeFocus);
else
return OLE_OK;
default:
// Unknown verb.
return OLE_ERROR_DOVERB;
}
}