VC++ ActiveX
-
I hate to be a newbie but I need this. I made an ActiveX that its only function is return a string with some information of client PC but this doesn't matter ... the problem is... When I invoke my method in my HTML file my method doesn't return any string... I don't know how to make this but I tried by this way: /****** IDL FILE *********/ dispinterface _DMyActiveX { properties: methods: [id(60666)] char* GetString(); }; /******Control CPP File*******/ BEGIN_DISPATCH_MAP(CMyActiveXCtrl, COleControl) DISP_FUNCTION_ID(CMyActiveXCtrl, "GetString", 60666, GetString, VT_EMPTY, VTS_NONE) END_DISPATCH_MAP() char* CMyActiveXCtrl::GetString() { return "TestString\0"; } /******** CONTROL H FILE *****/ // Dispatch maps DECLARE_DISPATCH_MAP() afx_msg char* GetString(); /************************************************************/ This is what I changed on original VC++ files... this method works as well to show an MessageBox or an Dialog but it doesn't to just return a string... I don't know the reason... maybe the afx_msg... Can anyone help me??? Thanks!!!! :confused::confused::confused: Wender Oliveira .NET Programmer
-
I hate to be a newbie but I need this. I made an ActiveX that its only function is return a string with some information of client PC but this doesn't matter ... the problem is... When I invoke my method in my HTML file my method doesn't return any string... I don't know how to make this but I tried by this way: /****** IDL FILE *********/ dispinterface _DMyActiveX { properties: methods: [id(60666)] char* GetString(); }; /******Control CPP File*******/ BEGIN_DISPATCH_MAP(CMyActiveXCtrl, COleControl) DISP_FUNCTION_ID(CMyActiveXCtrl, "GetString", 60666, GetString, VT_EMPTY, VTS_NONE) END_DISPATCH_MAP() char* CMyActiveXCtrl::GetString() { return "TestString\0"; } /******** CONTROL H FILE *****/ // Dispatch maps DECLARE_DISPATCH_MAP() afx_msg char* GetString(); /************************************************************/ This is what I changed on original VC++ files... this method works as well to show an MessageBox or an Dialog but it doesn't to just return a string... I don't know the reason... maybe the afx_msg... Can anyone help me??? Thanks!!!! :confused::confused::confused: Wender Oliveira .NET Programmer
Maybe since you are not "really" allocating any memory to set the return value, the string value gets cleaned up when the method exits. Try allocating some memory and setting it to the value you want. Do not forget to free the memory when the callee is done using the value.
-
Maybe since you are not "really" allocating any memory to set the return value, the string value gets cleaned up when the method exits. Try allocating some memory and setting it to the value you want. Do not forget to free the memory when the callee is done using the value.
I didn't understood... I really haven't experience with C++ and this is the reason that I don't know how to make what you said... Can you show me an example? I changed the method to: void CMacAddressCtrl::GetMacAddress() { MessageBox("TestString"); } and it works as well... But when I try to return the char* it returns ... Wender Oliveira .NET Programmer
-
I didn't understood... I really haven't experience with C++ and this is the reason that I don't know how to make what you said... Can you show me an example? I changed the method to: void CMacAddressCtrl::GetMacAddress() { MessageBox("TestString"); } and it works as well... But when I try to return the char* it returns ... Wender Oliveira .NET Programmer
Wender Oliveira wrote: I really haven't experience with C++ Starting out in C++ with an ActiveX control probably isn't the best path, IMHO. - Nick Parker
My Blog | My Articles