Board index » cppbuilder » Re: TWebBrowser/TWinControl

Re: TWebBrowser/TWinControl


2006-09-13 03:53:16 AM
cppbuilder2
Stefan wrote:
Quote
How can I determine the size of the content of a webform, loaded in the
TWebBrowser Component.
What do you mean with webform ?
A piece of htmlcode between <form>... </form>?
Hans.
 
 

Re:Re: TWebBrowser/TWinControl

How can I determine the size of the content of a webform, loaded in the
TWebBrowser Component.
I want to implement a AutoSize function for the Form containing the
WebBrowser component.
Regards
Stefan
 

Re:Re: TWebBrowser/TWinControl

Hello Hans,
I think htmlpage would have been the right word.
I think in in a piece of htmlcode in general.
Regards
Stefan
"Hans Galema" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
Stefan wrote:
>How can I determine the size of the content of a webform, loaded in the
>TWebBrowser Component.

What do you mean with webform ?

A piece of htmlcode between <form>... </form>?

Hans.
 

{smallsort}

Re:Re: TWebBrowser/TWinControl

Stefan wrote:
Quote
I think htmlpage would have been the right word.
So the control loads and displays .html files.
That file can contain a very long not-wrapped sentence.
The control (as every browser) will wrap that sentence according
to the width of its visible area. Not the other way round.
Now please explain what you consider to be
"the size of the content".
Hans.
 

Re:Re: TWebBrowser/TWinControl

At the moment I have a form which contains a TWebBrowser
which has the alignment set to alClient
The sample-html which I am displaying is a little big bigger
than the TWebBrowser. Because of this the TWebBrowser
component displays scrollbars to make the rest of the content visible.
I would like to know at what size I have to resize the form containing
so that the html fits exactly. So I need to know what is the original size
of the html what the WebBrowser wants to display (the values it
calculates his scrollbar settings).
Stefan
"Hans Galema" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
Stefan wrote:

>I think htmlpage would have been the right word.

So the control loads and displays .html files.

That file can contain a very long not-wrapped sentence.

The control (as every browser) will wrap that sentence according
to the width of its visible area. Not the other way round.

Now please explain what you consider to be
"the size of the content".

Hans.
 

Re:Re: TWebBrowser/TWinControl

Stefan wrote:
Quote
The sample-html which I am displaying is a little big bigger
than the TWebBrowser. Because of this the TWebBrowser
component displays scrollbars to make the rest of the content visible.
So you do not want the TCppWebBrowser to come up with scrollbars.
To calculate when they will vanisch looks an impossible task to me.
What you probably can do however is monitoring if scrollbars
are displayed. If they are visible then ClientRect will
be different from the outside rect. Did you investigate
Clientrect already?
If srollbars are displayed you will adjust width and or hight
untill they vanish.
Hans.
 

Re:Re: TWebBrowser/TWinControl

Try this:
IDispatch* pDocDisp = 0;
HRESULT hr = pWebBrowser->get_Document(&pDocDisp);
IHTMLDocument2* pDoc = 0;
hr = pDocDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc);
if (SUCCEEDED(hr)) {
IHTMLElement* pBodyElem;
hr = pDoc->get_body(&pBodyElem);
if (SUCCEEDED(hr)) {
IHTMLElement2* pBodyElem2;
hr = pBodyElem->QueryInterface(IID_IHTMLElement2,
(void**)&pBodyElem2)
if (SUCCEEDED(hr)) {
long iScrollWidth = 0;
pBodyElem2->get_scrollWidth(&iScrollWidth);
long iScrollHeight = 0;
pBodyElem2->get_scrollHeight(&iScrollHeight);
pWebBrowser->Width = iScrollWidth;
pWebBrowser->Height = iScrollHeight;
pBodyElem2->Release();
}
pBodyElem->Release();
}
pDoc->Release();
}
pDocDisp->Release();
Mark Finkle
"Stefan" < XXXX@XXXXX.COM >wrote in message
Quote
How can I determine the size of the content of a webform, loaded in the
TWebBrowser Component.

I want to implement a AutoSize function for the Form containing the
WebBrowser component.

Regards
Stefan


 

Re:Re: TWebBrowser/TWinControl

Thank you Mark,
that was exactly what I searched for.
Unfortunately the values returned aren't acurate, but a good estimation.
Regards
Stefan