Solved

VC++ statements equivalent to VB.

Posted on 2003-10-29
9
249 Views
Last Modified: 2010-04-01
Hello,
I have the following statements in VB.I have a ActiveXcontrol in my form PopXCtl1.
Folder is another COM component which I am using.
Dim InboxFolder As Folder
Set InboxFolder = PopXCtl1.Inbox

Can anyone suggest me how to convert these statements to VC++.
I have used COM component for PopXCtl like given below:
 hresult=CoCreateInstance(__uuidof(PopX),NULL,CLSCTX_ALL,__uuidof(IPopX),(LPVOID *) &popx);
and I am using popx->GetInBox method.
I want to get a statement like in VB
Set InboxFolder = PopXCtl1.Inbox.
I want to use a simlar statement in VC++ for popx->GetInBox ,I want to set the result of this statement to an object of another COM component Folder.
Can anyone help me.
0
Comment
Question by:geethaes
[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
  • 3
  • 3
  • 2
9 Comments
 
LVL 9

Expert Comment

by:_ys_
ID: 9648860
This will probably do what you want. It all depends on how you add a reference the the control.

_Folder *fld = 0; //** verify the type used for Folder **//
hresult = popx->GetInBox(&fld);
//... use it
fld->Release( ); //** mandatory **//
fld = 0;

Automation clients, such as VB, never show you the HRESULTs. The pseudo return value is actually a [retval] attributed parameter.
0
 

Author Comment

by:geethaes
ID: 9655371
I have given like you specified but I got hte error GetInbox function  doesnot take one parameter.
So I gave like this using get_Inbox() method,another method.
IFolder *folder = 0;
hresult= popx->get_Inbox((IDispatch **)folder);
Now I want to use the  GetCount method  of  this Folder.This GetCount method doesnot take any parameter,it returns long integer.
I have in VB
Dim InboxFolder As Folder
Dim n as long
Set InboxFolder = PopXCtl1.Inbox
n = InboxFolder.Count  ,
There are methods Count,GetCount() and get_count(long *pVal) which all has te same functionality of getting count .But I am not able to use these methods of Folder.
I tried to use get_count which takes a paremeter as long *pVal.
I have used as
long count =0;
hresult1 = folder->get_Count(&count);
But I am getting Unhandled exeception error.
Can you plese help me.
0
 
LVL 9

Accepted Solution

by:
_ys_ earned 50 total points
ID: 9656373
>> But I am getting Unhandled exeception error.
As I would expect from the code you provided, because ...

>> IFolder *folder = 0;
>> hresult= popx->get_Inbox((IDispatch **)folder);
inconsistent types specified - IFolder and IDispatch.


You've hinted that get_Inbox expectes an IDispatch interface. So:

IDispatch *pDisp = 0;
hresult = popx->get_Inbox (pDisp);

IFolder *folder = 0;
hresult = pDisp->QueryInterface (IID_IFolder, reinterpret_cast<void**>(&folder));

pDisp->Release ( );

// folder can be used here
// ...

folder->Release ( );


Alternatively, you may be able to get away with not using IDispatch at all. Try this:

IFolder *folder = 0;
hresult = popx->get_Inbox (&folder);

// folder can be used here
// ...

folder->Release ( );
0
Technology Partners: 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!

 

Author Comment

by:geethaes
ID: 9656523
Thanks  a lot it worked out fine.
0
 
LVL 9

Expert Comment

by:_ys_
ID: 9656565
Out of interest, which one worked ... as both are viable.
0
 

Author Comment

by:geethaes
ID: 9656588
I used the first one .
For the second one I got some compiler error of type mismatch of the IFolder and IDispatch.
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10546310
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in approximately one week.  I would appreciate any comments by the experts that would help me in making a recommendation.

It is assumed that any participant not responding to this request is no longer interested in its final deposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help.jsp#hs5

Tinchos
EE Cleanup Volunteer
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10586367
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: _ys_ {http:#9656373}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Technology Partners: 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
I could not build boost code, 10 117
White board coding practice 3 99
C++ help/ Toy problem 19 71
keep track of class structure 1 55
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 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.

751 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