DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Jeff Yoder Guest

    Passing a structure from VB to an ActiveX control


    I'm trying to pass a structure from VB to an ActiveX control written in Visual
    C. I've defined the data type of the structure in an idl library, and VB
    recognizes it as a valid data type. I can declare variables of that type
    in VB and use them. On the C side, I can use the structure as well. Where
    I'm running into problems is in figuring out how to pass the structure from
    VB to C. Specifically, I can't figure out what needs to be entered into
    the DISP_PROPERTY_EX() macro for the final parameter, vtPropType which specifies
    the properties type. Anybody tried doing this before?

    Thanks,

    Jeff

  2. #2
    Boris Karadjov Guest

    Re: Passing a structure from VB to an ActiveX control

    You should use VT_VARIANT in DISP_PROPERTY_EX() . The variant set should be
    of type VT_RECORD. The following fields of the VARIANT are used:
    V_RECORDINFO(&var) contains a pointer to IRecordInfo
    (http://msdn.microsoft.com/library/de...dk/automat/cha
    p12_69wl.htm) interface. V_RECORD(&var) contains a pointer to the record
    data. To make a local copy of the record (structure) use
    V_RECORDINFO(&var)->CopyRecord(V_RECORD(&var), &mystruct). Note that
    mystruct must be zeroed before a pointer to it being supplied to CopyRecord
    method.
    --
    Boris Karadjov
    Brainbench MVP for Visual C++
    http://www.brainbench.com

    "Jeff Yoder" <jeff.yoder@americanhofmann.com> wrote in message
    news:3b05337c$1@news.devx.com...
    >
    > I'm trying to pass a structure from VB to an ActiveX control written in

    Visual
    > C. I've defined the data type of the structure in an idl library, and VB
    > recognizes it as a valid data type. I can declare variables of that type
    > in VB and use them. On the C side, I can use the structure as well.

    Where
    > I'm running into problems is in figuring out how to pass the structure

    from
    > VB to C. Specifically, I can't figure out what needs to be entered into
    > the DISP_PROPERTY_EX() macro for the final parameter, vtPropType which

    specifies
    > the properties type. Anybody tried doing this before?
    >
    > Thanks,
    >
    > Jeff




  3. #3
    Jeff Yoder Guest

    Re: Passing a structure from VB to an ActiveX control


    Thanks, Boris,

    Do I need to use the CopyRecord function to make the copy? I've been successfully
    getting a copy of the record just by dereferencing the pointer to the record
    data.

    Jeff

    "Boris Karadjov" <bbmvp@cpppp.virtualave.net> wrote:
    >You should use VT_VARIANT in DISP_PROPERTY_EX() . The variant set should

    be
    >of type VT_RECORD. The following fields of the VARIANT are used:
    >V_RECORDINFO(&var) contains a pointer to IRecordInfo
    >(http://msdn.microsoft.com/library/de...dk/automat/cha
    >p12_69wl.htm) interface. V_RECORD(&var) contains a pointer to the record
    >data. To make a local copy of the record (structure) use
    >V_RECORDINFO(&var)->CopyRecord(V_RECORD(&var), &mystruct). Note that
    >mystruct must be zeroed before a pointer to it being supplied to CopyRecord
    >method.
    >--
    >Boris Karadjov
    >Brainbench MVP for Visual C++
    >http://www.brainbench.com
    >
    >"Jeff Yoder" <jeff.yoder@americanhofmann.com> wrote in message
    >news:3b05337c$1@news.devx.com...
    >>
    >> I'm trying to pass a structure from VB to an ActiveX control written in

    >Visual
    >> C. I've defined the data type of the structure in an idl library, and

    VB
    >> recognizes it as a valid data type. I can declare variables of that type
    >> in VB and use them. On the C side, I can use the structure as well.

    >Where
    >> I'm running into problems is in figuring out how to pass the structure

    >from
    >> VB to C. Specifically, I can't figure out what needs to be entered into
    >> the DISP_PROPERTY_EX() macro for the final parameter, vtPropType which

    >specifies
    >> the properties type. Anybody tried doing this before?
    >>
    >> Thanks,
    >>
    >> Jeff

    >
    >



  4. #4
    Boris Karadjov Guest

    Re: Passing a structure from VB to an ActiveX control

    Well, if the record does not contain BSTRs, interface pointers, VARIANTs,
    SAFEARRAYs, etc. or if you do not need to make a copy of the record you can
    skip the call to CopyRecord.
    --
    Boris Karadjov
    Brainbench MVP for Visual C++
    http://www.brainbench.com


    "Jeff Yoder" <jeff.yoder@americanhofmann.com> wrote in message
    news:3b09055a@news.devx.com...
    >
    > Thanks, Boris,
    >
    > Do I need to use the CopyRecord function to make the copy? I've been

    successfully
    > getting a copy of the record just by dereferencing the pointer to the

    record
    > data.
    >
    > Jeff
    >
    > "Boris Karadjov" <bbmvp@cpppp.virtualave.net> wrote:
    > >You should use VT_VARIANT in DISP_PROPERTY_EX() . The variant set should

    > be
    > >of type VT_RECORD. The following fields of the VARIANT are used:
    > >V_RECORDINFO(&var) contains a pointer to IRecordInfo

    >
    >(http://msdn.microsoft.com/library/de...sdk/automat/ch

    a
    > >p12_69wl.htm) interface. V_RECORD(&var) contains a pointer to the record
    > >data. To make a local copy of the record (structure) use
    > >V_RECORDINFO(&var)->CopyRecord(V_RECORD(&var), &mystruct). Note that
    > >mystruct must be zeroed before a pointer to it being supplied to

    CopyRecord
    > >method.
    > >--
    > >Boris Karadjov
    > >Brainbench MVP for Visual C++
    > >http://www.brainbench.com
    > >
    > >"Jeff Yoder" <jeff.yoder@americanhofmann.com> wrote in message
    > >news:3b05337c$1@news.devx.com...
    > >>
    > >> I'm trying to pass a structure from VB to an ActiveX control written in

    > >Visual
    > >> C. I've defined the data type of the structure in an idl library, and

    > VB
    > >> recognizes it as a valid data type. I can declare variables of that

    type
    > >> in VB and use them. On the C side, I can use the structure as well.

    > >Where
    > >> I'm running into problems is in figuring out how to pass the structure

    > >from
    > >> VB to C. Specifically, I can't figure out what needs to be entered

    into
    > >> the DISP_PROPERTY_EX() macro for the final parameter, vtPropType which

    > >specifies
    > >> the properties type. Anybody tried doing this before?
    > >>
    > >> Thanks,
    > >>
    > >> Jeff

    > >
    > >

    >




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links