Reaching IHTMLDialog (Webbrowser automation)

I am implementing a HTML automation in a site that creates a Dialog Window (window.showModalDialog).

I want to access the IHTMLDocument2 property in the dialog from IHTMLDocument2 of the page tha calls the dialog,this all doesn´t work:

IHTMLWindow2 *win2, *win2b ;

xMillenium->HTMLDoc2->get_parentWindow(&win2b);

win2b->get_self(&win2); win2b->Release();

IDispatch *idp;
HResult hres = win2->get_external(&idp);
win2->Release();
if (hres!=S_OK) {
ShowMessage("Error (WebGetDialog): Failed to get external!");
} else {

IHTMLDialog *dia;
hres = idp->QueryInterface(IID_IHTMLDialog , (void **) &dia);
if (hres!=S_OK) {
ShowMessage("Fail dia");
} else {
dia->Release(); ShowMessage("dia ok");
}

hres = idp->QueryInterface(IID_IHTMLWindow2 , (void **) &win2);
if (hres!=S_OK) {
ShowMessage("Fail window2");
} else {
win2->Release(); ShowMessage("Window2 ok");
}

IHTMLDocument2 *doc2;
hres = idp->QueryInterface(IID_IHTMLDocument2 , (void **) &doc2);
if (hres!=S_OK) {
ShowMessage("Fail doc2");
} else {
doc2->Release(); ShowMessage("doc2 ok");
}

idp->Release();
}

SOMEONE HAVE SOME IDEA?
Topic archived. No new replies allowed.