The information in this article applies to:
SUMMARY
When building a container/server application with the Microsoft
Foundation OLE Classes, you should prohibit the application user from
inserting an object of the type serviced by the application itself. In
fact, with an MDI application, if you try to embed your server's object in
your server's document, you'll get the following message and trace messages
indicating that a QueryInterface call failed:
Trace messages: This article gives an example showing how to customize the OLE Insert Object dialog wrapped by the COleInsertDialog class. This customization omits your server object's class id from the selection list so the user won't be able to embed it. MORE INFORMATIONThe COleInsertDialog class contains a member m_io -- as described in online help for the OLE Classes:
The OLEUIINSERTOBJECT dialog contains two members which allow the user to
exclude specific object types from the dialog's selection list by CLSID.
The member lpClsidExclude is a pointer of type LPCLSID and therefore must
point directly to a variable of type CLSID. The member cClsidExclude is a
UINT and contains the number of CLSID types that are pointed to by
lpClsidExclude. If you want to exclude more than one CLSID, use an array.The sample code below demonstrates how to exclude the AppWizard generated CLSID for the application's own object. This CLSID can be found in the CWinApp-derived class implementation file as the static global variable "clsid" and will look something like this:
For the purpose of accessing clsid from a view class member function,
take the "static" storage class off the above declaration.You can then assign the lpClsidExclude pointer to &clsid from any module in the program. For the purpose of this sample, cClsidExclude is a count of one, so no array will be used. The code to assign these members must be run before displaying the dialog. Therefore it's best to assign these members in the container view class' OnInsertObject() member. The OnInsertObject() shown in the sample code below is based on the one that AppWizard provides. Sample Code
Additional query words: kbinf 1.50 2.00 2.50 3.00
Keywords : |
Last Reviewed: July 26, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |