as part of the HTML body tag options. How is this calculated. I could
possibly use this if I understand what's going on .
"Michael Tissington" <michael@nospam.newsgroups.com> wrote in message
news:%23sw3GuKOJHA.1896@TK2MSFTNGP02.phx.gbl...
I have a CDialog which has a single WebBrowser control.
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.
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