I am looking to create a Javascript library for ActiveX objects, enabling chainability.
For example, I am looking to replace this:
var dbEngine=new ActiveXObject('DAO.DBEngine.36');
var dbs=dbEngine.OpenDatabase('D:\\Todo.mdb');
var rs=dbs.OpenRecordset('SELECT * FROM ListItems');
with something like this (a la jQuery):
var rs=AX('DAO.DBEngine.36')
.OpenDatabase('D:\\Todo.mdb')
.OpenRecordset('SELECT * FROM ListItems');
I know I can do this:
var rs=new ActiveXObject('DAO.DBEngine.36')
.OpenDatabase('D:\\Todo.mdb')
.OpenRecordset('SELECT * FROM ListItems');
but I have no way of accessing the Database object from the Recordset object.
In order to do this, the AX function should create the DBEngine object internally and inspect its members/properties, then expose corresponding methods on the the returned object.
If the member/property returns an object, that object itself will be returned wrapped in the AX function.
Only objects that implement IDispatchEx can be inspected at runtime. MSDN specifically lists the differences between IDispatch and IDispatchEx:
I’ve made bold the relevant issue.
As Eric points out in the comments, you can use enumerate the members of the objects using foreach (or for…in perhaps?), but I’m not sure, from the question, what you specifically want to do.
Since not all ActiveX controls will implement IDispatchEx (or may not implement all methods of IDispatchEx properly or completely), are there specific controls you’re looking to play with?
More details will lead to better answers.