After loading navigating to a url how can I determine the required size of
the browser to show the page without any scroll bars.
I'd then like to resize the Dialog and WebBrowser control to show the
complete page.
I guess you could look through the HTML for table or div specifiers and try
to determine the widest point, but that would be hit and miss in my opinion.
You will also not like be able to do anything vertically since many pages
can go on for several screens.
Are you using a specific page or list of pages that you know something
about?
Tom
"Michael Tissington" <mic...@nospam.newsgroups.com> wrote in message
news:%23sw3GuK...@TK2MSFTNGP02.phx.gbl...
The following code is from a CDHTMLDialog derived class, but your WebBrowser
control also has an OnDocumentComplete() method. It uses the WIDTH and
HEIGHT attributes in the <body> of the HTML. I don't know if you can ensure
those are properly set, but if so:
void CDHtmlPopupDlg::OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl)
{
// defaults to show a small window, but it probably won't be the right
size
long width = 320;
long height = 240;
// Read document's body for WIDTH and HEIGHT
CComQIPtr<IWebBrowser2> spWebBrowser2(pDisp);
if ( spWebBrowser2 )
{
CComPtr<IDispatch> spDocDispatch;
spWebBrowser2->get_Document(&spDocDispatch);
CComQIPtr<IHTMLDocument2> spDoc(spDocDispatch);
if ( spDoc )
{
// Find body.style.width and body.style.height
CComPtr<IHTMLElement> spBodyElement;
spDoc->get_body(&spBodyElement);
if ( spBodyElement )
{
// Get Body style
CComPtr<IHTMLStyle> spBodyStyle;
spBodyElement->get_style(&spBodyStyle);
if ( spBodyStyle )
{
// Finally get dimensions - both will be 0 the first
time through
spBodyStyle->get_pixelWidth (&width);
spBodyStyle->get_pixelHeight(&height);
}
}
}
// Resize dialog and web browser control based on width and height
}
-- David
Just curious, is this something that gets set automatically somewhere?
Aside from perhaps as part of a style tag I've never seen width or height
as part of the HTML body tag options. How is this calculated. I could
possibly use this if I understand what's going on .
Tom
"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:4B1216F6-4355-48C4...@microsoft.com...
Use SetWindowPos to resize the dialog to whatever size you want. In
its OnSize handler, you can size the WebBrowserControl to the desired
size.
--
Ajay
I think you can specify in your HTML :
<body width="640" height="320">
and that is what I am accessing via the browser DOM.
-- David
Tom
"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:AD0C21A8-77AA-4445...@microsoft.com...
Actually, the syntax is:
<body style="width: 600; height: 577">
Mostly I am showing HTML pages which I control (or can coordinate with the
web server people), so it's no problem to get things like this put in.
-- David
Tom
"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:56704633-DFB2-4391...@microsoft.com...