IE Automation

N

Nikhil Khedkar

I am working on developing a test application in java. I
use java for UI only. I use JNI to communicate with a VC
MFC DLL. I launch an IE browser instance in one JNI method
(init()), which works fine.

OleInitialize(NULL);
CLSID clsid;
CLSIDFromProgID(OLESTR("InternetExplorer.Application"),
&clsid);
HRESULT hr = CoCreateInstance(clsid, NULL,
CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (void**)
&m_spBrowser);

I store the browser pointer (IWebBrowser2 *) as a C++
class instance variable. BTW, I start a
thread on the native side (_beginthread) which in turn
calls the method that launches the browser.
Previously I was facing the problem of marshalling, the
IWebBrowser2 pointer was getting correupted, when used in
different methods (even the simple properties of
IWebBrowser2 (like IWebBrowser2::fullname) were not
accessible). So now I have added the code of marshalling
after the browser is launched. In almost all the other
methods, I first unmarshall the interface and then
marshall it back at the end of it. This solved my earlier
mentioned problem.

void CIECanvas::MarshallInterface()
{
HRESULT hr;
if(SUCCEEDED(hr = ::CreateStreamOnHGlobal(NULL,
TRUE, &pstm)))
{
LARGE_INTEGER bZero = {0, 0};
pstm->Seek(bZero, STREAM_SEEK_SET, NULL);

if(SUCCEEDED:):CoMarshalInterface(pstm,
IID_IWebBrowser2, m_spBrowser, MSHCTX_INPROC, NULL,
MSHLFLAGS_NORMAL)))
{
pstm->Seek(bZero, STREAM_SEEK_SET,
NULL);
}
}
}

void CIECanvas::UnmarshallInterface()
{
LARGE_INTEGER bZero = {0, 0};
pstm->Seek(bZero, STREAM_SEEK_SET, NULL);
HRESULT hr = ::CoUnmarshalInterface(pstm,
IID_IWebBrowser2, (void**)&m_spBrowser);
if(FAILED(hr))
{
showMessageBox
("CIECanvas::UnmarshallInterface()", "%s %ld", "FAILED.
ERROR CODE = ", GetLastError());
}
}

Then for recording I use AfxConnectionAdvise(), which is
working fine.

The problem I am facing is in Replaying the events.
1)The VM crashes with a hotspot error, when on the first
page some link click event is present, which loads a new
page. One observation here is the VM crashes after
onBeforeNavigate2 or TitleChange events are fired.
2)I also tried Yahoo's registration page (having a lot of
dropdowns and checkboxes), it works fine for the first few
events, but then the VM crashes.

My questions are
1)Does IE handle the events like page loading (tiltle
change etc.) and click on some link in different threads?
How are the events handled (any useful info on this)?
2)How should I fix the problem?
3)Is it related to marshalling of IE COM pointers?

Please replay ASAP,
Nikhil
 
R

Robert Aldwinckle

Nikhil,

Try a programming NG? IE6 Browser is for end user discussion
about the UI, including error recovery. Unfortunately there aren't any
IE6 newsgroups dedicated to discussions of developer topics
so some spill over into here but I suspect you will find more expertise
on coding issues in the IE5 programming newsgroups.

See if you can find a list of newsgroups using this link
(or do the necessary setup in your news reader):

< news://msnews.microsoft.com/ >

ie5 programming appears to be a useful pattern to filter out
IE Programming newsgroups. E.g. if OE opens the above link
press Ctrl-w and type ie5 pro

(AFAIK there are no IE6 Programming newsgroups but you may find
there are other online web forums you can try--e.g. via Developer's links.
And I am just assuming that most people just use the ones under IE55.
I have never actually looked at any of them.)


Good luck

Robert Aldwinckle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top