0
votes

I'm writing an ActiveX control to embed inside an Internet Explorer page, and I'm having trouble passing a string to an ActiveX method from inside JavaScript.

I am using MFC activex control and my function looks like this

DISP_FUNCTION_ID(CCSDS_CommunicationCtrl, "CloseCon", eventidCloseCon, CloseCon, VT_EMPTY,VTS_PI1 VTS_I4)

void CloseCon(CHAR* a,LONG b);

On the JavaScript side, I call the method like this:

CSDS_Communication1.CloseCon("1",3)

while calling the method it gives me a "Type Mismatch" error.

Thank you for any help.

1

1 Answers

0
votes

Although I'm not using MFC much (strongly prefer ATL), I pretty convinced you can't communicate char* from JavaScript, and have to use BSTR. That is: use BSTR instead of char*, and VTS_WBSTR instead of VTS_Pl1. In your code, please try

DISP_FUNCTION_ID(CCSDS_CommunicationCtrl, "CloseCon", eventidCloseCon, CloseCon, VT_EMPTY, VTS_WBSTR VTS_I4)

void CloseCon(BSTR a, LONG b);