Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Exposing struct as method parameter

Exposing struct as method parameter

Scheduled Pinned Locked Moved ATL / WTL / STL
c++question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alex1205
    wrote on last edited by
    #1

    I want to expose a user defined data type (struct) to clients using ATL. I also wanted this struct to be a parameter to one of my methods. Is there a way in which I could do this? SDE

    I 1 Reply Last reply
    0
    • A alex1205

      I want to expose a user defined data type (struct) to clients using ATL. I also wanted this struct to be a parameter to one of my methods. Is there a way in which I could do this? SDE

      I Offline
      I Offline
      ian mariano
      wrote on last edited by
      #2

      If your class is foo and the structure is public or accessible to the calling object:

      class foo
      {
         public:
            struct  myStruct
            {
               int a;
               int b;
            }  myStruct;
      
            void   UseFooStruct(myStruct s);
      }
      
      class   bar
      {
         public:
            void   UseFooStruct(foo::myStruct s);
      }
      
      A 1 Reply Last reply
      0
      • I ian mariano

        If your class is foo and the structure is public or accessible to the calling object:

        class foo
        {
           public:
              struct  myStruct
              {
                 int a;
                 int b;
              }  myStruct;
        
              void   UseFooStruct(myStruct s);
        }
        
        class   bar
        {
           public:
              void   UseFooStruct(foo::myStruct s);
        }
        
        A Offline
        A Offline
        alex1205
        wrote on last edited by
        #3

        I think I must have phrased it wrong. I know what you mean. But what I wanted is to expose the struct to one of my interfaces, then be able to pass the struct from Visual basic to My VC++ COM object. Is this possible? SDE

        I 1 Reply Last reply
        0
        • A alex1205

          I think I must have phrased it wrong. I know what you mean. But what I wanted is to expose the struct to one of my interfaces, then be able to pass the struct from Visual basic to My VC++ COM object. Is this possible? SDE

          I Offline
          I Offline
          ian mariano
          wrote on last edited by
          #4

          Yes. You can define a user defined structure (a Type) in VB which corresponds to your C++ structure. That way, you can pass the structure back and forth. Look in the MSDN on how to do this: Passing User-Defined Types to a DLL Procedure. Of course, your Type declaration in VB must be equivalent to the C++ version.

          Ian Mariano - http://www.ian-space.com/
          "We are all wave equations in the information matrix of the universe" - me

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups