ActiveX ATL
-
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
-
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
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! -
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!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
-
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
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! -
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!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