OLESTATUS OleSetTargetDevice(lpObject, hTargetDevice)
LPOLEOBJECT lpObject;
HGLOBAL hTargetDevice;
The OleSetTargetDevice function specifies the target output device for an object.
Parameter | Description |
lpObject | Points to the object for which a target device is specified. |
hTargetDevice | Identifies a StdTargetDevice memory structure that describes the target device for the object. See the following comments for information about this structure. |
The OleSetTargetDevice function allows a linked or embedded object to be formatted correctly for a target device, even when the object is rendered on a different device.
A client application should call this function whenever the target device changes, so that servers can be notified to change the rendering of the object, if necessary. The client application should call the OleUpdate function to ensure that the information is sent to the server so that the server can make the necessary changes to the object's presentation. The client application should call the DLL to redraw the object if it receives a notification from the server that the object has changed.
A client application uses the OleSetTargetDevice function to change the target device. The client does not need to call OleSetTargetDevice every time a server is opened.
The StdTargetDevice structure accepts information about the target device that the client is using. The information is in binary format, interpreted as the following structure. (Offsets are relative to the start of the data array.)
struct {
WORD deviceNameOffset;
WORD driverNameOffset;
WORD portNameOffset;
WORD extDevModeOffset;
WORD extDevModeSize;
WORD environmentOffset;
WORD environmentSize;
BYTE data[];
} StdTargetDevice;
The deviceNameOffset, driverNameOffset, and portNameOffset members should be null-terminated.
In Windows 3.1, the ability to connect multiple printers to one port has made the environment obsolete. The environment information retrieved by the GetEnvironment function can occasionally be incorrect. To ensure that the StdTargetDevice structure is initialized correctly, the application should copy information from the DEVMODE structure retrieved by a call to the ExtDeviceMode function to the environment position of the StdTargetDevice structure.
The return value is OLE_OK if successful; otherwise, it could be one of the following:
OLE_BUSY
OLE_ERROR_MEMORY
OLE_ERROR_OBJECT
OLE_WAIT_FOR_RELEASE