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. C / C++ / MFC
  4. ActiveX ATL

ActiveX ATL

Scheduled Pinned Locked Moved C / C++ / MFC
c++comquestion
5 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.
  • S Offline
    S Offline
    Sameer Maggon
    wrote on last edited by
    #1

    Hi, I have created a simple ActiveX ATL project in VC++, How do I add member variables in the Object. Its like I want to store some information that can be accessed from all my functions. Thanx in advance Sameer

    P 1 Reply Last reply
    0
    • S Sameer Maggon

      Hi, I have created a simple ActiveX ATL project in VC++, How do I add member variables in the Object. Its like I want to store some information that can be accessed from all my functions. Thanx in advance Sameer

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      You can add the variables directly to the class if you only want them to be used internally. However if you want to be able to access these variables externally through a COM interface, the easiest way to add a variable is to go to your class view tab of your ATL activex component workspace. Then right click to get the context menu, and select Add member variable. After you fill at that form, the IDE will modify your IDL file and CPP files to add that variable to your class and COM interfaces. Good Luck.


      Build a man a fire, and he will be warm for a day
      Light a man on fire, and he will be warm for the rest of his life!

      S 1 Reply Last reply
      0
      • P Paul M Watt

        You can add the variables directly to the class if you only want them to be used internally. However if you want to be able to access these variables externally through a COM interface, the easiest way to add a variable is to go to your class view tab of your ATL activex component workspace. Then right click to get the context menu, and select Add member variable. After you fill at that form, the IDE will modify your IDL file and CPP files to add that variable to your class and COM interfaces. Good Luck.


        Build a man a fire, and he will be warm for a day
        Light a man on fire, and he will be warm for the rest of his life!

        S Offline
        S Offline
        Sameer Maggon
        wrote on last edited by
        #3

        Thanx a lot.!! I have one more Problem. I have Declared a Method as method([in] LPSTR str, [out, retval] int *retvat) and when i call this function through ASP, it gives the error as Automation Variable not supported. Please help

        P 1 Reply Last reply
        0
        • S Sameer Maggon

          Thanx a lot.!! I have one more Problem. I have Declared a Method as method([in] LPSTR str, [out, retval] int *retvat) and when i call this function through ASP, it gives the error as Automation Variable not supported. Please help

          P Offline
          P Offline
          Paul M Watt
          wrote on last edited by
          #4

          You cannot use the LPSTR datatype if you want your COM objects to be portable outside of C++. You will need to use the BSTR datatype. Here is a little bit of information about BSTRs. They are UNICODE strings, so you will have to use the ATL conversion macros to convert between your ansi single character string and the wide char UNICODE string in ATL. Lookup A2W in MSDN and you will find some info about it. A BSTR is special in the fact that it contains the size of the BSTR encoded in its format. When you deal with a BSTR you are given a pointer to the string portion of the BSTR. However, the 4 bytes preceding that pointer contain the size of the BSTR. example: pointer | size | string data wide chars 4 bytes V 12 bytes, as the size fild indicates [12] [\0H\0e\0l\0l\0o\0\0] You can also use the CComBSTR class in ATL to manage your BSTR variables for you, it simplifies things a lot. You will also want to become familiar with the ::SysAllocString and ::SysFreeString functions. These are the functions that you will use to allocate a new BSTR. good luck


          Build a man a fire, and he will be warm for a day
          Light a man on fire, and he will be warm for the rest of his life!

          S 1 Reply Last reply
          0
          • P Paul M Watt

            You cannot use the LPSTR datatype if you want your COM objects to be portable outside of C++. You will need to use the BSTR datatype. Here is a little bit of information about BSTRs. They are UNICODE strings, so you will have to use the ATL conversion macros to convert between your ansi single character string and the wide char UNICODE string in ATL. Lookup A2W in MSDN and you will find some info about it. A BSTR is special in the fact that it contains the size of the BSTR encoded in its format. When you deal with a BSTR you are given a pointer to the string portion of the BSTR. However, the 4 bytes preceding that pointer contain the size of the BSTR. example: pointer | size | string data wide chars 4 bytes V 12 bytes, as the size fild indicates [12] [\0H\0e\0l\0l\0o\0\0] You can also use the CComBSTR class in ATL to manage your BSTR variables for you, it simplifies things a lot. You will also want to become familiar with the ::SysAllocString and ::SysFreeString functions. These are the functions that you will use to allocate a new BSTR. good luck


            Build a man a fire, and he will be warm for a day
            Light a man on fire, and he will be warm for the rest of his life!

            S Offline
            S Offline
            Sameer Maggon
            wrote on last edited by
            #5

            Hi, Thanx for the reply. Actually I want to pass a string as a paramter from my ASP code (in the ACTIVEX-ATL component) and in the component I am using the parameter as a string for some purpose where I want a char * type What should i do Sameer

            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