6.3.8 Opening and Closing Objects

When the user requests the client application to activate an object, the client should check whether the object is busy by calling the OleQueryReleaseStatus function. If the object is busy, the client should either refuse the request to open the object or enter a message-dispatch loop, waiting for the OLE_RELEASE notification.

If the object to be activated is not busy, the client should call the OleActivate function. The library notifies the client when the server is open or when an error occurs.

The OleActivate function allows the client application to specify whether to display the activated object in a window of the server application. A client might hide the server window if an object is updated automatically.

A client application can use the OleQueryOpen function to determine whether a specified object is open. The OleClose function allows the client to close an open object. Closing an object terminates the connection with the server. To reestablish a terminated connection between a linked object and an open server, the client can use the OleReconnect function. To close an open object and release it from memory, a client application can call the OleRelease function.

The first time a client application activates a particular embedded object, the client should call the OleSetHostNames function, specifying the string the server window should display in its title bar. This string should be the name of the client document containing the object. The client does not need to call OleSetHostNames every time an embedded object is activated, because the library maintains a record of the specified names.