Access javascript variables in mshtml.IHTMLWindow2

demonraiser

New member
Joined
Jan 11, 2007
Messages
2
Programming Experience
3-5
I have a hta application with javascript as the frontend, and Vb6 library at the backend.
Once I migrated the application to VB.NET, most of the functionalities work fine, but in certain situation, if I try to access javascript variables from VB.NET, the code fails.

e.g I have a handle to the hta application window, oWindow, which is visible as an mshtml.IHTMLWindow2 object. I can access the document tags as well as javascript variables as before.

e.g. oWindow.oTab = Me

Now I have a non-modal child window declared

oHelpWindow = oWindow.showModelessDialog(strHelpPath & "BQHelp.htm", Me, "status:no;dialogwidth:0;dialogheight:0;resizable:yes;")

where oHelpWindow is also declared as a mshtml.IHTMLWindow2.

Within BQHelp.htm, a javascript variable oHelp is defined.
When I try to set this oHelp variable from VB.NEt code in the following manner

oHelpWindow.oHelp = Me

the code throws an exception "Member not found".

How do I get it to work?


 
Return type of mshtml.showModelessDialog is Object (even if it contains reference to the window). If you declare oHelpWindow as Object you should be able to access the oHelp variable utilizing "late binding" feature, ie compiler won't complain about 'unknown' member of Object. If you do use IHtmlWindow2 interface you can leave it but cast to Object when necessary or the other way around what suits best.
VB.NET:
Expand Collapse Copy
DirectCast(ohelpwindow, Object).oHelp = Me
 
Didnt work :(

The same exception:

Message: Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

Stack Trace:
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object o, Type& objType, String name, Object[] args, String[] paramnames, Boolean OptimisticSet, CallType UseCallType)

at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase, CallType CallType)

at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSetComplex(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase)

at BobQuoterQANET.clsHelp.RenderBox()

I am wondering how it works for the Main window, but not the child window.
 
It isn't the showmodeless call that is the problem perhaps? I jsut noticed it is not a member of IHTMLWindow2, but member of IHTMLWindow3
 
Back
Top