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. How do I do this ? [modified]

How do I do this ? [modified]

Scheduled Pinned Locked Moved ATL / WTL / STL
questionc++data-structures
3 Posts 3 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.
  • S Offline
    S Offline
    Smith
    wrote on last edited by
    #1

    Imagine.. in the ATL implementation, we have a collection or an array, ie : int num[5]; num[0]=100;..... [5]=500; Now in my client, (i.e VB) , I need to access them like, (Imagine collection is the property which points to the array I've mentioned above} msgbox (MyComp.Collection[0]) (and like this too..) MyComp.Collection(0).length --> this should pop "3" It should popup 100. :confused: -- modified at 11:24 Monday 10th July, 2006

    K P 2 Replies Last reply
    0
    • S Smith

      Imagine.. in the ATL implementation, we have a collection or an array, ie : int num[5]; num[0]=100;..... [5]=500; Now in my client, (i.e VB) , I need to access them like, (Imagine collection is the property which points to the array I've mentioned above} msgbox (MyComp.Collection[0]) (and like this too..) MyComp.Collection(0).length --> this should pop "3" It should popup 100. :confused: -- modified at 11:24 Monday 10th July, 2006

      K Offline
      K Offline
      Kurt _B
      wrote on last edited by
      #2

      Try using a SafeArray on the ATL side.

      1 Reply Last reply
      0
      • S Smith

        Imagine.. in the ATL implementation, we have a collection or an array, ie : int num[5]; num[0]=100;..... [5]=500; Now in my client, (i.e VB) , I need to access them like, (Imagine collection is the property which points to the array I've mentioned above} msgbox (MyComp.Collection[0]) (and like this too..) MyComp.Collection(0).length --> this should pop "3" It should popup 100. :confused: -- modified at 11:24 Monday 10th July, 2006

        P Offline
        P Offline
        Pharago
        wrote on last edited by
        #3

        Hi, you have variuos options in this case, you can try and use some kind of collection enumeration based on the variant safearrays to try to please com clients like VB, or you can use the raw and simply way of having a property that inputs an index and returns the value in the array. Something like: idl: HRESULT get_CollectionItemName([in]long Index,[out,retval]BSTR* pVal); ClassName.cpp STDMETHODIMP ClassName::get_CollectionItemName(long Index,BSTR* pVal) { lookup vector or container using index copy item or item member on return value *pVal return S_OK; } This method is fairly simple of implement, you don't need to get very involved in com specific code, and you can use simple datatypes and the kind of array of your choice.

        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