OLEOBJECTVTBL

3.1

#include <ole.h>


typedef struct _OLEOBJECTVTBL {   /* oov */
    void FAR* (CALLBACK* QueryProtocol)(LPOLEOBJECT, OLE_LPCSTR);
    OLESTATUS (CALLBACK* Release)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* Show)(LPOLEOBJECT, BOOL);
    OLESTATUS (CALLBACK* DoVerb)(LPOLEOBJECT, UINT, BOOL, BOOL);
    OLESTATUS (CALLBACK* GetData)(LPOLEOBJECT, OLECLIPFORMAT,
        HANDLE FAR*);
    OLESTATUS (CALLBACK* SetData)(LPOLEOBJECT, OLECLIPFORMAT, HANDLE);
    OLESTATUS (CALLBACK* SetTargetDevice)(LPOLEOBJECT, HGLOBAL);
    OLESTATUS (CALLBACK* SetBounds)(LPOLEOBJECT, OLE_CONST RECT FAR*);
    OLECLIPFORMAT (CALLBACK* EnumFormats)(LPOLEOBJECT, OLECLIPFORMAT);
    OLESTATUS (CALLBACK* SetColorScheme)(LPOLEOBJECT,
        OLE_CONST LOGPALETTE FAR*);

    /*
     * Server applications implement only the functions listed above.
     * Object handlers can use any of the functions in this structure
     * to modify default server behavior.
     */


    OLESTATUS (CALLBACK* Delete)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* SetHostNames)(LPOLEOBJECT, OLE_LPCSTR,
        OLE_LPCSTR);
    OLESTATUS (CALLBACK* SaveToStream)(LPOLEOBJECT, LPOLESTREAM);
    OLESTATUS (CALLBACK* Clone)(LPOLEOBJECT, LPOLECLIENT, LHCLIENTDOC,
        OLE_LPCSTR, LPOLEOBJECT FAR*);
    OLESTATUS (CALLBACK* CopyFromLink)(LPOLEOBJECT, LPOLECLIENT,
        LHCLIENTDOC, OLE_LPCSTR, LPOLEOBJECT FAR*);
    OLESTATUS (CALLBACK* Equal)(LPOLEOBJECT, LPOLEOBJECT);
    OLESTATUS (CALLBACK* CopyToClipboard)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* Draw)(LPOLEOBJECT, HDC, OLE_CONST RECT FAR*,
        OLE_CONST RECT FAR*, HDC);
    OLESTATUS (CALLBACK* Activate)(LPOLEOBJECT, UINT, BOOL, BOOL, HWND,
        OLE_CONST RECT FAR*);
    OLESTATUS (CALLBACK* Execute)(LPOLEOBJECT, HGLOBAL, UINT);
    OLESTATUS (CALLBACK* Close)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* Update)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* Reconnect)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* ObjectConvert)(LPOLEOBJECT, OLE_LPCSTR,
        LPOLECLIENT, LHCLIENTDOC, OLE_LPCSTR, LPOLEOBJECT FAR*);
    OLESTATUS (CALLBACK* GetLinkUpdateOptions)(LPOLEOBJECT,
        OLEOPT_UPDATE FAR*);
    OLESTATUS (CALLBACK* SetLinkUpdateOptions)(LPOLEOBJECT,
        OLEOPT_UPDATE);
    OLESTATUS (CALLBACK* Rename)(LPOLEOBJECT, OLE_LPCSTR);
    OLESTATUS (CALLBACK* QueryName)(LPOLEOBJECT, LPSTR, UINT FAR*);
    OLESTATUS (CALLBACK* QueryType)(LPOLEOBJECT, LONG FAR*);
    OLESTATUS (CALLBACK* QueryBounds)(LPOLEOBJECT, RECT FAR*);
    OLESTATUS (CALLBACK* QuerySize)(LPOLEOBJECT, DWORD FAR*);
    OLESTATUS (CALLBACK* QueryOpen)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* QueryOutOfDate)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* QueryReleaseStatus)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* QueryReleaseError)(LPOLEOBJECT);
    OLE_RELEASE_METHOD (CALLBACK* QueryReleaseMethod)(LPOLEOBJECT);
    OLESTATUS (CALLBACK* RequestData)(LPOLEOBJECT, OLECLIPFORMAT);
    OLESTATUS (CALLBACK* ObjectLong)(LPOLEOBJECT, UINT, LONG FAR*);
} OLEOBJECTVTBL;

The OLEOBJECTVTBL structure points to functions that manipulate an object. A server application creates this structure and an OLEOBJECT structure to give the server library access to an object.

Server applications do not need to implement functions beyond the SetColorScheme function. Object handlers can provide specialized treatment for some or all of the functions in the OLEOBJECTVTBL structure.

The following list of structure members does not document all the functions pointed to by the OLEOBJECTVTBL structure. For information about the functions not documented here, see the documentation for the corresponding function for object linking and embedding (OLE). For example, for more information about the QueryProtocol member, see the OleQueryProtocol function.

Comments

The following functions in OLEOBJECTVTBL should return OLE_BUSY when appropriate:

Activate Close CopyFromLink Delete DoVerb Execute ObjectConvert Reconnect RequestData SetBounds SetColorScheme SetData SetHostNames SetLinkUpdateOptions SetTargetDevice Show Update

Function

Release

  OLESTATUS (FAR PASCAL *Release)(lpObject)    
  LPOLEOBJECT lpObject;    

The Release function causes the server to free the resources associated with the specified OLEOBJECT structure.

Parameters

lpObject

Points to the OLEOBJECT structure to be released.

Return Value

The return value is OLE_OK if the function is successful. Otherwise, it is an error value.

Comments

The server application should not destroy data when the library calls the Release function. The library calls the Release function when no clients are connected to the object.

Function

Show

  OLESTATUS (FAR PASCAL *Show)(lpObject, fTakeFocus)    
  LPOLEOBJECT lpObject;    
  BOOL fTakeFocus;    

The Show function causes the server to show an object, displaying its window and scrolling (if necessary) to make the object visible.

Parameters

lpObject

Points to the OLEOBJECT structure to show.

fTakeFocus

Specifies whether the server window gets the focus. If the server window is to get the focus, this value is TRUE. Otherwise, this value is FALSE.

Return Value

The return value is OLE_OK if the function is successful. Otherwise, it is an error value.

Comments

The library calls the Show function when the server application should show the document to the user for editing or to request the server to scroll the document to bring the object into view.

Function

DoVerb

  OLESTATUS (FAR PASCAL *DoVerb)(lpObject, iVerb, fShow, fTakeFocus);    
  LPOLEOBJECT lpObject;    
  UINT iVerb;    
  BOOL fShow;    
  BOOL fTakeFocus;    

The DoVerb function specifies what kind of action the server should take when a user activates an object.

Parameters

lpObject

Points to the object to activate.

iVerb

Specifies the action to take. The meaning of this parameter is determined by the server application.

fShow

Specifies whether to show the server window. This value is TRUE to show the window; otherwise, it is FALSE.

fTakeFocus

Specifies whether the server window gets the focus. If the server window is to get the focus, this value is TRUE. Otherwise, it is FALSE. This parameter is relevant only if the fShow parameter is TRUE.

Return Value

The return value is OLE_OK if the function is successful. Otherwise, it is an error value.

Comments

All servers must support the editing of objects. If a server does not support any verbs except Edit, it should edit the object no matter what value is specified by the iVerb parameter.

Function

GetData

  OLESTATUS (FAR PASCAL *GetData)(lpObject, cfFormat, lphdata)    
  LPOLEOBJECT lpObject;    
  OLECLIPFORMAT cfFormat;    
  HANDLE FAR* lphdata;    

The GetData function retrieves data from an object in a specified format. The server application should allocate memory, fill it with the data, and return the data through the lphdata parameter.

Parameters

lpObject

Points to the OLEOBJECT structure from which data is requested.

cfFormat

Specifies the format in which the data is requested.

lphdata

Points to the handle of the allocated memory that the server application returns. The library frees the memory when it is no longer needed.

Return Value

The return value is OLE_OK if the function is successful. Otherwise, it is an error value, which may be one of the following:

OLE_ERROR_BLANK
OLE_ERROR_FORMAT
OLE_ERROR_OBJECT

Function

SetData

  OLESTATUS (FAR PASCAL *SetData)(lpObject, cfFormat, hdata)    
  LPOLEOBJECT lpObject;    
  OLECLIPFORMAT cfFormat;    
  HANDLE hdata;    

The SetData function stores data in an object in a specified format. This function is called (with the Native data format) when a client opens an embedded object for editing. This function is also used if the client calls the OleSetData function with some other format.

Parameters

lpObject

Points to the OLEOBJECT structure in which data is stored.

cfFormat

Specifies the format of the data.

hdata

Identifies a place in memory from which the server application should extract the data. The server should delete this handle after it uses the data.

Return Value

The return value is OLE_OK if the function is successful. Otherwise, it is an error value.

Comments

The server application is responsible for the memory identified by the hdata parameter. The server must delete this data even if it returns OLE_BUSY or if an error occurs.

Function

SetTargetDevice

  OLESTATUS (FAR PASCAL *SetTargetDevice)(lpObject, hotd)    
  LPOLEOBJECT lpObject;    
  HGLOBAL hotd;    

The SetTargetDevice function communicates information about the client's target device for the object. The server can use this information to customize output for the target device.

Parameters

lpObject

Points to the OLEOBJECT structure for which the target device is specified.

hotd

Identifies an OLETARGETDEVICE structure.

Return Value

The return value is OLE_OK if the function is successful. Otherwise, it is an error value.

Comments

The server application is responsible for the memory identified by the hotd parameter. The server must delete this data even if it returns OLE_BUSY or if an error occurs.

The library passes NULL for the hotd parameter to indicate that the rendering is necessary for the screen.

See Also

OleSetTargetDevice

Function

ObjectLong

  OLESTATUS (FAR PASCAL *ObjectLong)(lpObject, wFlags, lpData)    
  LPOLEOBJECT lpObject;    
  UINT wFlags;    
  LONG FAR* lpData;    

The ObjectLong function allows the calling application to store data with an object. This function is typically used by object handlers.

Parameters

lpObject

Points to the OLEOBJECT structure for which the data is stored.

wFlags

Specifies the method used for setting and retrieving data. It can be one or more of the following values:

Value Meaning

OF_SET Data is written to the location specified by the lpData parameter, replacing any data already there.
OF_GET Data is read from the location specified by the lpData parameter.
OF_HANDLER Data is written or read by an object handler. This value prevents data from an object handler from being replaced by other applications.

If the calling application specifies OF_SET and OF_GET, the function returns a pointer to the previous data and replaces the data pointed to by the lpData parameter with the data specified by the calling application.

lpData

Points to data to be written or read.

Return Value

The return value is OLE_OK if the function is successful. Otherwise, it is an error value.

Function

SetColorScheme

  OLESTATUS SetColorScheme(lpObject, lpPal)    
  LPOLEOBJECT lpObject;    
  OLE_CONST LOGPALETTE FAR* lpPal;    

The SetColorScheme function sends the server application the color palette recommended by the client application.

Parameters

lpObject

Points to an OLEOBJECT structure for which the client application recommends a palette.

lpPal

Points to a LOGPALETTE structure specifying the recommended palette.

Return Value

The return value is OLE_OK if the function is successful. Otherwise, it is an error value.

Comments

Server applications are not required to use the palette recommended by the client application.

Before returning from the SetColorScheme function, the server application should use the palette pointed to by the lpPal parameter in a call to the CreatePalette function to create the handle of the palette:

hpal = CreatePalette(lpPal);

The server can then use the palette handle to refer to the palette.

The first palette entry in the LOGPALETTE structure specifies the foreground color recommended by the client application. The second palette entry specifies the background color. The first half of the remaining palette entries are fill colors, and the second half are colors for lines and text.

Client applications typically specify an even number of palette entries. When there is an uneven number of entries, the server should interpret the odd entry as a fill color; that is, if there are five entries, three should be interpreted as fill colors and two as line and text colors.