The information in this article applies to:
SUMMARY
Technical Note 38 "TN038: MFC/OLE IUnknown Implementation" contains two
errors. First, it describes how to implement standard and custom interface
functions for an OLE COM object using the MFC Interface Map macros, but the
code is incorrect. Additionally, the article explains how to aggregate an
object, but the code in the interface map is also incorrect. MORE INFORMATIONFirst Code ProblemFor the implementation of the interface functions, two sets of sample code are included, the first set is correct. The code immediately following the discussion of the Interface Map macros is the code in error. The code illustrates the implementation of the IUnknown functions and custom interface functions for the interface being created using the MFC Interface Maps. The sample code in error is as follows:
All of the function signatures are incorrect. CEditObj should actually be
XEditObj. The BEGIN_INTERFACE_PART and END_INTERFACE_PART macros create a
nested class inside the object class definition, and assign a name to the
nested class. The name of the nested class is created by prepending an X to
the first argument of the BEGIN_INTERFACE_PART macro, which should be the
name of your custom interface. Therefore, if you are going to implement the
functions in the nested classes that were created for you by the
BEGIN_INTERFACE_PART and END_INTERFACE_PART macros, the nested classes name
would always begin with an X. This is to distinguish the nested class from
global classes (which typically start with C) and interface classes (which
typically start with I).To implement a member of the above described nested class correctly, you need to implement the AddRef shown above as:
Second Code ProblemThe second problem is in the discussion of aggregation. In the second step, the instructions say, "Include an INTERFACE_AGGREGATE macro in your interface map, which refers to the member variable by name." However, the code doesn't do that. Here is the incorrect code:
The variable m_lpTypeInfo should be m_lpAggrInner. The code should look
like this:
Additional query words:
Keywords : kbole kbdocfix kbdocerr kbMFC kbVC |
Last Reviewed: August 2, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |