So this idea rekindled something I've been longing for for a long time in LabVIEW: better integration with web-based UI technologies. I've in the past played with using HTML/etc to create dynamic user interfaces which frankly aren't possible in LabVIEW since elements can't be created or destroyed dynamically, and this is something HTML/etc excels at if you know a little DOM and the idea of a little javascript doesn't scare you.
First a little proof of principle to show that you can get data in and out of a WebBrowser:
WebBrowser.zip
Caveats: This is a very simple proof of principle. To use it you must
Be on a Windows based PC (it uses .NET after all).
Keep the contained folder in a location which doesn't have spaces in the path, I didn't do any URL parsing...
How it works. Getting data in is pretty trivial. Once the document is loaded in the browser, grab a reference to whatever you need (in this case an input element), then whenever want to update the value, just push it to the browser using the element refnum.
Getting data out isn't so bad either, though it is rather annoying. If you know any DOM, you're probably familiar that all the input elements have an onchange event associated with them. Well forget that, you can't use a refnum to register for an event callback for anything you pull from the hosted browser (someone please correct me if I'm wrong about this). But you still can register for events on the top level WebBrowser2 refnum, so I pulled the BeforeNavigate2 event and registered a callback for that. Now whenever I want to get data out of the web page, all I need to do is trigger a location change, then pull out any data I wish. You can probably imagine a few other ways to skin this one...
There are still some things that are basically off limits in LabVIEW. In the past I've defined entire COM interfaces (via C++), then passed the corresponding IDispatch interface into the browser which allows you to define arbitrary functions and variables which can be called directly from within a hosted document via the global window object available through javascript. I would love to be able to do this in LabVIEW. Imagine being able to call some code like this:
<input type="text" onchange="CallMyVI('Foo', 'Bar');" />
And have a registered callback VI automatically be called with "Foo" and "Bar" being placed in the appropriate terminals of your connector pane.
So what's the point behind this post? I'm really just hoping to seed some discussion on this. I have no idea how many of you have some web-based development under your belts, but I'm hoping even if you don't, that you can see the possibilities that can be opened up by being able to have a more dynamic user interface canvas available to us? Hopefully in time I can get a more thorough example of what I think is possible, but for now the proof I posted above is all I have.
Regards,
-michael