Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get my javascript to talk to my C++ app?

Status
Not open for further replies.

baxybaxy

Programmer
May 16, 2007
3
GB
Hi all,

first post here, so please be gentle!

i have an app developed in c++ which uses a 3rd party activeX control to display SVG (graphics in XML format)

unfortunately, the activeX control is not very sophisticated and does not have all the methods i need - specifically it does not have the ability to generate an event based on clicking part of the SVG graphics. for example, in my app, i need to be able to click on a picture of a truck which then pops up a (C++) form window showing the contents of the truck, where it's going etc

SO....

I have embedded some javascript in the SVG xml in order to try and generate some events that i might be able to capture in c++

my cunning plan was
1. when user clicks a truck, javascript inserts a new XML element in the SVG (using insertafter.. to insert the truck ID at the end of the SVG.)
2. at same time, C++ generates a 'activeX window clicked' event
3. then read the new SVG from C++

However, step 3 does not work. It is only possible to read the original SVG in C++, not the modified SVG (not sure why - when i test in mozilla it works just fine)

This leaves me with the question :
- how can i use javascript to 'pass' the truck ID number to C++
The obvious solution is to write the truck ID to a file-> (If I could write the file on clicking the SVG element, i could process with steps 2,3 above with step 3 opening the new file)
however, I recall for obvious security reasons that javascript is not allowed to write to the harddrive.

Is there any other solution to this?

Note: this is all local processing - no internet, intranet etc.
 
This is probably not what you want, but it's the only thing I could think of. If the ActiveX control is not exposing the events and methods you need, maybe you could bypass the ActiveX control by displaying the SVG in an embedded browser object using the Adobe's SVG viewer to get direct access to the page events. Or maybe embed Adobe's SVG viewer directly, if it's possible and licensing allows for it.

Adam
 
thanks for the advice adam
unfortunately, the main reason for using this control is to avoid having to embed a browser, because that really slows the app down (in fact, i am migrating from that situation - the original graphics were in vml in a browser!). i did already try and embed the adobe viewer, but the control is undocumented and very complex - i can't even get the most basic things running. also i had to use an old version to avoid a security fix in the last svg viewer (difficult sell that - get users to go back a version just to get my app to work!)

i am moving on with a work-around; i can detect when the focus moves on / off the control (by the user clicking it somewhere) and at that point i am picking up the mouse location and backwards working that to find which svg graphic has been clicked, by crossreferencing the original svg generation. not very elegant, but does have a slight speed advantage it would seem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top