[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

COM interfaces appearence in VB Client

Posted on 2003-10-26
1
Medium Priority
?
214 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 210 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

Industry Leaders: 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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

650 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