Solved

How to define a struct data interface in a ActiveX control?

Posted on 2003-11-22
6
438 Views
Last Modified: 2013-11-20
I hope define a struct interface as GetPostInfo(PostInfo* postinfo); in a ActiveX control,

for example this struct as following:
typedef Struct PostInfo
{
   long nIndex;
   BSTR strPostName;
} PostInfo
 
and how to define that parameter of a FUNCTION definition in a xxxctrl.h
DISP_FUNCTION(CxxxCtrl, "GetPostInfo", GetPostInfo, VT_BOOL, ?)

so I must define this PostInfo struct in ODL file, and I hope this interface as a common data type, for example DRAWITEMSTRUCT, the data can be transfer from COM inside to user.
0
Comment
Question by:Gempin
  • 2
6 Comments
 

Author Comment

by:Gempin
Comment Utility
Experts, help me, please~~
0
 

Author Comment

by:Gempin
Comment Utility
Experts, help me, please~~
0
 

Accepted Solution

by:
boonsha earned 300 total points
Comment Utility
We are allowed to declare C and C++ style structures in an IDL file. Once declared they can be used like usual data types. This is show in the following IDL code.

         // declare structure

        typedef struct
        {
            double x ;
            double y ;
        } Point2d ;
       // interface IZ
       [object,uuid (32bb8325-b41b. 11cf-a6bb- 0080c7b2d682);
      helpstring ("IZInterface")
      pointer_default(unique)]
      interface IZ ; IUnknown
      {
                HRESULT StructIn ( [in] Point2d pt ) ;
                HRESULT StructOut ( [out] Point2d *pt ) ;
      } ;

As shown here the StructIn( ) method receives a structure of type Point2d and the method StructOut( ) returns a Point2d structure. Once the structure has been defined in the IDL file there is no need to declare it again in the client program. The client program can easily pass and receive this structure without the declaration. This is possible because when we #import the server’s type library file the structure declaration also gets imported.

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now