Google Answers Logo
View Question
 
Q: Building Automation DLL's which have properties that return objects. ( No Answer,   3 Comments )
Question  
Subject: Building Automation DLL's which have properties that return objects.
Category: Computers > Programming
Asked by: boluc-ga
List Price: $10.00
Posted: 21 Jun 2002 07:23 PDT
Expires: 24 Jun 2002 01:56 PDT
Question ID: 31158
I am trying to write an MFC DLL using MS Visual C++ 6.0. I want it to
be automation enabled so that I can reference it from VB or VBA and
use its methods and properties. One of the properties I want a class I
create (FTPSession) to have will be File, which will return a FTPFile
object (also defined in that project). I know it is possible because I
have seen automation libraries which do that, e.g. the fields property
of the recordset object returns a field object. I create a project
using ATL wizard and create my interfaces without any problem, I add a
property that returns ([out, retval]) a CFTPFile pointer. When I start
to build the DLL the MIDL stops with an error saying that
'error MIDL2025 : syntax error : expecting a type specification near
"CFTPFile"'
Obviously meaning it cannot recognize my class name. What should I do?

Request for Question Clarification by jeanluis-ga on 21 Jun 2002 10:28 PDT
Hello,
Hmm not sure, at first I thought "Well the CFTPFile class needs to be
defined in scope of the file that you are using it". But I figured
that is such an easy problem you would have already thought of it.
Then I did some snooping and I found this website, which appears to
have the same problem you have:
"The Wrong Way"
http://www.msu.edu/~huntharo/portfolio/vb-for-idl/passing-interface-pointers-wr
ong.html

Down toward the bottom of that page they explain what is going wrong,
then they show how to fix it:
"The Right Way"
http://www.msu.edu/~huntharo/portfolio/vb-for-idl/passing-interface-pointer-right-way.html

One thing to note is that they are passing from VB to C++, and from
your post it sounds like you are trying to go from C++ to VB, I am not
sure if this will change things much. Because of that small difference
I am posting this as a clarification, if this is correct and helps
you; please let me know and I will consider it answered.
Thanks,
--jld

Request for Question Clarification by jeanluis-ga on 21 Jun 2002 10:29 PDT
(I always forget to do this!)
To find those pages I just searched for: MIDL2025

Clarification of Question by boluc-ga on 23 Jun 2002 22:52 PDT
Well it doesnt answer my question because it shows the way when using
an already built and ready to go DLL library to import from. The
classes I want to expose are in the project I am trying to build.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Building Automation DLL's which have properties that return objects.
From: danielearwicker-ga on 22 Jun 2002 13:18 PDT
 
The problem is in the IDL file. It can't refer to C++ class names,
only IDL interface names.

The interface of the FTPFile object is probably called IFTPFile.
That's what you need to put as the output parameter type in the IDL
file.
Subject: Re: Building Automation DLL's which have properties that return objects.
From: boluc-ga on 23 Jun 2002 22:57 PDT
 
Regarding danielearwicker's comment: Tried that, doesn't work. Even if
it did, how can I return a IFTPFile or *IFTPFile from the property
function? There is no function linking CFTPFile to IFTPFile, or is
there?
Subject: Re: Building Automation DLL's which have properties that return objects.
From: boluc-ga on 24 Jun 2002 01:55 PDT
 
After posting the previous comment I cut and pasted the positions of
the classes in the IDL file. Once the interfaces were declared in
their hierarchical order, it built the file. Thanks to
danielearwicker. However, I still don't know how to return a pointer
to IFTPFile pointer (IFTPFile **) from the CFTPFile class. Can anyone
help?

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy