Discussion:
HELP!!! Why pDisp on NewWindow2 is not the same than on NavigateComplete?
(too old to reply)
Jorge Bergasa
2003-11-28 13:43:08 UTC
Permalink
Hello all!

I am developing an Internet Explorer toolbar that performs some actions on
NavigateComplete only if the page is loaded in a pop-up window.

In order to know whether the page is loaded in a pop-up window, I catch
NewWindow2 to create my own InternetExplorer object and store its IDispatch
into a vector. Then, on NavigateComplete, I look for the pDisp that comes as
a parameter in the vector. If the pDisp is in the vector, this means that
the page is being loaded in the pop-up created on NewWindow2. Easy.

The problem is that the pDisps of each event do not match. I have made sure
that my vector is working properly, and I also tried to see what the values
of Container and Application were, with no luck.

Anyone has an idea of what I am doing wrong / is going wrong? If not, anyone
has an idea of how to know whether a navigation is made from a pop-up window
or not, on NavigateComplete?

Here are some code snippets:

void __stdcall CCoMyToolbar::OnNewWindow2 (IDispatch **ppDisp, VARIANT_BOOL
*cancel)
{
CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER,
IID_IDispatch, (LPVOID*)ppDisp);
ATLASSERT(*ppDisp != NULL);

m_newWindows->Add(*ppDisp);
}

void __stdcall CCoBrowserFilter::OnOBNavigateComplete (IDispatch *pDisp,
VARIANT *vtUrl)
{
if (m_newWindows->Exists(pDisp) == S_OK)
{
... Do something...
}
else
{
...Do something else...
}
}
Igor Tandetnik
2003-12-01 23:29:20 UTC
Permalink
What's m_newWindows? You seem to have two member variables named
m_newWindows in two different classes, CCoMyToolbar and
CCoBrowserFilter. So one class stores pointers in one container, while
the other tries to look them up in a different container. Am I missing
something obvious?
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Post by Jorge Bergasa
Hello all!
I am developing an Internet Explorer toolbar that performs some actions on
NavigateComplete only if the page is loaded in a pop-up window.
In order to know whether the page is loaded in a pop-up window, I catch
NewWindow2 to create my own InternetExplorer object and store its IDispatch
into a vector. Then, on NavigateComplete, I look for the pDisp that comes as
a parameter in the vector. If the pDisp is in the vector, this means that
the page is being loaded in the pop-up created on NewWindow2. Easy.
The problem is that the pDisps of each event do not match. I have made sure
that my vector is working properly, and I also tried to see what the values
of Container and Application were, with no luck.
Anyone has an idea of what I am doing wrong / is going wrong? If not, anyone
has an idea of how to know whether a navigation is made from a pop-up window
or not, on NavigateComplete?
void __stdcall CCoMyToolbar::OnNewWindow2 (IDispatch **ppDisp,
VARIANT_BOOL
Post by Jorge Bergasa
*cancel)
{
CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER,
IID_IDispatch, (LPVOID*)ppDisp);
ATLASSERT(*ppDisp != NULL);
m_newWindows->Add(*ppDisp);
}
void __stdcall CCoBrowserFilter::OnOBNavigateComplete (IDispatch *pDisp,
VARIANT *vtUrl)
{
if (m_newWindows->Exists(pDisp) == S_OK)
{
... Do something...
}
else
{
...Do something else...
}
}
Jorge Bergasa
2003-12-02 10:54:24 UTC
Permalink
Hi Igor,

The different class names in the code snippet is a typo. I just replaced
CCoBrowserFilter with CCoMyToolbar to make it less cryptic to the public,
although I forgot to change it in the second method so it has confused you
rather than making it easier to read. Sorry about that.

Summarising, both methods belong to the same class, and every instance of
the class share the same vector. I have made sure about that. In fact, if
you forget about the vector, the pointer created on NewWindow2 will never
appear on NavigateComplete (comparing IUnknowns, as Jan pointer out).

By the way, I changed CLSCTX_SERVER to CLSCTX_LOCAL_SERVER following the
example in "Programking Internet Explorer 5" by Microsoft Press.

The confusing thing is that I think I have demonstrated that the pointer
created on NewWindow2 is used to display the page (using theatreMode), so it
should be the same pointer appearing on Navigate complete, shouldn't it?

With best regards,

Jorge Bergasa.
Post by Igor Tandetnik
What's m_newWindows? You seem to have two member variables named
m_newWindows in two different classes, CCoMyToolbar and
CCoBrowserFilter. So one class stores pointers in one container, while
the other tries to look them up in a different container. Am I missing
something obvious?
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Post by Jorge Bergasa
Hello all!
I am developing an Internet Explorer toolbar that performs some
actions on
Post by Jorge Bergasa
NavigateComplete only if the page is loaded in a pop-up window.
In order to know whether the page is loaded in a pop-up window, I
catch
Post by Jorge Bergasa
NewWindow2 to create my own InternetExplorer object and store its
IDispatch
Post by Jorge Bergasa
into a vector. Then, on NavigateComplete, I look for the pDisp that
comes as
Post by Jorge Bergasa
a parameter in the vector. If the pDisp is in the vector, this means
that
Post by Jorge Bergasa
the page is being loaded in the pop-up created on NewWindow2. Easy.
The problem is that the pDisps of each event do not match. I have made
sure
Post by Jorge Bergasa
that my vector is working properly, and I also tried to see what the
values
Post by Jorge Bergasa
of Container and Application were, with no luck.
Anyone has an idea of what I am doing wrong / is going wrong? If not,
anyone
Post by Jorge Bergasa
has an idea of how to know whether a navigation is made from a pop-up
window
Post by Jorge Bergasa
or not, on NavigateComplete?
void __stdcall CCoMyToolbar::OnNewWindow2 (IDispatch **ppDisp,
VARIANT_BOOL
Post by Jorge Bergasa
*cancel)
{
CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER,
IID_IDispatch, (LPVOID*)ppDisp);
ATLASSERT(*ppDisp != NULL);
m_newWindows->Add(*ppDisp);
}
void __stdcall CCoBrowserFilter::OnOBNavigateComplete (IDispatch
*pDisp,
Post by Jorge Bergasa
VARIANT *vtUrl)
{
if (m_newWindows->Exists(pDisp) == S_OK)
{
... Do something...
}
else
{
...Do something else...
}
}
Loading...