COM Plugin - losing COM reference - Is anyone using ActiveX?

Questions and answers on developing, deploying and using plugins and JavaBeans

COM Plugin - losing COM reference - Is anyone using ActiveX?

Postby joe26 » Fri Jul 10, 2015 6:54 pm

I am calling an application through the COM PlugIn, and getting returned

com.servoyguy.plugins.servoycom.RemoteCOM@9b9965

but calling a function to return an object from a function within the app gives me an ActiveX reference of

com.jacob.com.Dispatch@19a09ab

after which, I cannot use any references to the jacob COM reference that I would normally be passed from a servoyguy COM reference.

Is this a dead-end or is there a way to get the information through this plugin?

I've also attempted to access the jacob.jar package directly but it is dynamic so likely fails in this context, attempting to connect with BarTender from Seagull Scientific.

Also, a defect ticket was posted to ServoyForge.

thanks,
--Joe.
joe26
 
Posts: 172
Joined: Wed Jun 19, 2013 10:30 pm

Re: COM Plugin - losing COM reference - Resolved

Postby joe26 » Thu Jul 16, 2015 8:28 pm

For those who may need this in the future:

Description

I am calling an application through the COM PlugIn, and getting returned

com.servoyguy.plugins.servoycom.RemoteCOM@9b9965

but calling a function to return an object from a function within the app gives me an ActiveX reference of

com.jacob.com.Dispatch@19a09ab

after which, I cannot use any references to the jacob COM reference that I would normally be passed from a servoyguy COM reference.

I'm calling the ActiveX controls within BarTender for opening a simple barcode and attempting to print the barcode to a default printer.

var com = plugins.servoyguy_servoycom.getNewClientJSCOM("BarTender.Application");
if (!com || !com.isJACOBLoaded()) {
plugins.dialogs.showErrorDialog( "Error", "Error loading COM: \\n" + plugins.servoyguy_servoycom.getLastError());
return;
}
com.put("Visible","true");
var test = com.getActiveXComponent();
var formats = com.getChildJSCOM("Formats"); // formats: com.servoyguy.plugins.servoycom.RemoteCOM@9b9965
var formatsFile = formats.call("Open","c:\\\\sample.BTW", "false", ""); //formatsFile: com.jacob.com.Dispatch@19a09ab, no ActiveX behavior from this object

// Program will exit properly if the following three lines are commented out
formatsFile.call("ExportToClipboard",0,0);
application.output("error "+plugins.servoyguy_servoycom.getLastError());
var comItems = formatsFile.get("NamedSubStrings");

com.call("Quit",1); // BarTender.BtSaveOptions.btDoNotSaveChanges = 1
com.release();



History
#1
Updated by Joe Collins 1 day ago
Comment Edit

Also, BarTender from Seagull Scientific is demoware for 30 days.
#2
Updated by Scott Butler about 1 hour ago
Comment

The getChildJSCOM is a work in progress. There is a sample of another use on this ticket: https://www.servoyforge.net/issues/655

Could you try an adjustment to the getChildJSCOM. Instead of:
var formats = com.getChildJSCOM("Formats");

Try:
var formats = com.getChildJSCOM("Formats", "BarTender.Application", []);
#3
Updated by Scott Butler about 1 hour ago

Status changed from New to Feedback

#4
Updated by Joe Collins 22 minutes ago
Comment Edit

The getChildJSCOM("Formats") does return a useful ActiveX reference.

Calls to that object's methods fail in that the methods do not exist, get, put, etc. as well as any properties.

In the plugin code, getChildJSCOM gets transformed, somehow. (New to plugins, exactly one written...)
return new JSVariant(Dispatch.call(axo, methodName, arg1, arg2, arg3, arg4, arg5));
Versus the getChildJSCOM,
return new RemoteCOM(Dispatch.get(axo, key).toDispatch())

It looks like it's returning the jacob response, but...

Executing within the Console:

=>com.getActiveXComponent()
com.jacob.activeX.ActiveXComponent@182a702 {m_pDispatch:1455185420}

=>com
com.servoyguy.plugins.servoycom.RemoteCOM@e88e50

=>formats = com.getChildJSCOM("Formats", "BarTender.Application", []);
com.servoyguy.plugins.servoycom.RemoteCOM@4c57d4

=>formats.getActiveXComponent()
com.jacob.activeX.ActiveXComponent@30128c {m_pDispatch:1458962620}

=>formatInfo = formats.call("Open","c:\\\\sample.BTW", "false", "")
com.jacob.com.Dispatch@1a9e26b

=>formatInfo
com.jacob.com.Dispatch@1a9e26b

=>formatInfo.getActiveXComponent()
"Error during evaluation:TypeError: Cannot find function getActiveXComponent in object com.jacob.com.Dispatch@1a9e26b."

=>for (item in formats){application.output(item)}
getClass
call
put
get
equals
hashCode
wait
getDispatch
getLastError
getChildJSCOM
getActiveXComponent
notify
toString
isJACOBLoaded
release
notifyAll

=>for (item in formatInfo){application.output(item)}
getClass
isNull
getDouble
equals
getInt
getBoolean
hashCode
wait
getFormattedDate
getDate
notify
toString
getString
notifyAll
#5
Updated by Joe Collins 1 minute ago
Comment Edit

My apologies... misdirected on the call to "Formats".

This line got me a correct RemoteCOM reference, as opposed to the Dispatch reference.

=>format = formats.getChildJSCOM("Open","BarTender.Application",["c://sample.BTW","false",""])
com.servoyguy.plugins.servoycom.RemoteCOM@1220c66
=>for (item in format){application.output(item)}
getClass
call
put
get
equals
hashCode
wait
getDispatch
getLastError
getChildJSCOM
getActiveXComponent
notify
toString
isJACOBLoaded
release
notifyAll
joe26
 
Posts: 172
Joined: Wed Jun 19, 2013 10:30 pm


Return to Plugins and Beans

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

cron