On some sites the new browser window is created to the correct size. On
other sites, the width and height values are bogus or even negative.
Here is my code to handle resizing the browser in the OnBeforeNavigate2()
event (written in MFC 6.0):
void CBrowser::OnBeforeNavigate2(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT
FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT
FAR* Headers, BOOL FAR* Cancel)
{
IWebBrowser2* pWB = NULL;
long newWidth, newHeight;
HRESULT hr = pDisp->QueryInterface( IID_IWebBrowser2, (void**)&pWB );
if (SUCCEEDED(hr))
{
pWB->get_Width(&newWidth); // get window.open, width parameter
pWB->get_Height(&newHeight); // get window.open, height paramter
}
......
On some sites, the newWidth and newHeight values are wrong or even negative
values. For example, the site: www.goped.com/html-products/sport-info.shtml
then click 'View Specs' produces a width of -40 and height of -62 (it should
be 400 x 300). Other web sites get the window size correctly.
Thanks for any help.
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"Kyle Fields" <kfi...@pacbell.net> wrote in message
news:uRbR34WGCHA.2740@tkmsftngp13...
To answer your question, I am handling NewWindow2 to create a new dialog
with another WebBrowser control -- all that works fine.
I tried handling WindowSetWidth and WindowSetHeight, but that produces the
same incorrect results (the Width and Height params passed to the event
handlers are bogus or negative values).
This only occurs on some sites (the goped.com site listed below) -- other
sites work OK.
Thanks for you help -- any ideas?
-Kyle
"Igor Tandetnik" <itand...@whenu.com> wrote in message
news:OuJWDBXGCHA.2296@tkmsftngp12...
I guess you confuse the control when you are sizing it at the same time
it is sizing itself. I suggest you sink those events and remember the
values the control sends to you, but do not resize it in response to
those events. Wait until you receive OnVisible(TRUE), then resize your
form using the coordinates you obtained earlier.
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"Kyle Fields" <kfi...@pacbell.net> wrote in message
news:OJSTEfXGCHA.1600@tkmsftngp13...