Solved

COM interfaces appearence in VB Client

Posted on 2003-10-26
1
211 Views
Last Modified: 2010-04-01
Hi,
I have a VC++ COM server application and a VB client that uses the server.
Some of the interfaces are not shown as I expected in the VB application (it seems like the appearence of them
depends on the order that they are written in the idl file).
for example, if I have the following declaration (in the idl):
      [
            uuid(1960D896-6ED7-483B-8C73-35C913DA9657),
            helpstring("Book Class")
      ]
      coclass Book
      {
            interface IBook;
            interface IBall;
            interface IPool;
      };
then if I try to create in the VB an object of type Book, the list that contains all the interfaces/objects does not contain "IBook",
it contains: "Book", "IBall" , "IPool".
I noticed also that every interface that is define first in the coclass declaration will not be shown in the VB.

Does someone know about a macro/flag that I can add inorder that the VB will show all the interfaces ???

thanks,
Yoav.

0
Comment
Question by:yoavo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
_ys_ earned 70 total points
ID: 9625947
Your coclass declaration is equivalent to this:
[
    uuid(1960D896-6ED7-483B-8C73-35C913DA9657),
    helpstring("Book Class")
]
coclass Book
{
    [default] interface IBook;
    interface IBall;
    interface IPool;
};

Notice the default attribute. In VB code when you code as such:

Dim bkBook As Book
Set bkBook = New Book

What is actually happening is VB is declaring the type as whatever [default] was.

Dim bkBook As IBook
Set bkBook = New Book

As you already know, it also hides whatever the [default] is.

You *can* however still declare a variable as IBook, and I would encourage you to do so. If [default] ever changes, at least your code won't break.

>> Does someone know about a macro/flag that I can add inorder that the VB will show all the interfaces ???
Unfortunately there isn't one. *But* what you can do, and it's quite a kludge, is inherit all your interfaces from an empty base interface, and declare this as [default].

[
    uuid(1960D896-6ED7-483B-8C73-35C913DA9657),
    helpstring("Book Class")
]
coclass Book
{
    [default] interface IVbNamed;
    interface IBook;
    interface IBall;
    interface IPool;
};

[IVbNamed will reveal itself to most other COM clients - which is not good]

If you remeber that 'Dim bkBook As Book' is equivalent to 'Dim bkBook As IBook', and always declare it as such, as recommended, you can do away with the above kludge
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
is twain_32.dll cmpatible with windows 10 ? 10 269
Why isn't object file created? 6 105
One named event, multiple event handlers 2 54
using interface in TLB 3 25
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question