Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VC++ statements equivalent to VB.

Posted on 2003-10-29
9
Medium Priority
?
252 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 200 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
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!

 

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

715 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