Board index » cppbuilder » Re: TWebBrowser/TWinControl
Hans Galema
![]() CBuilder Developer |
Hans Galema
![]() CBuilder Developer |
Re: TWebBrowser/TWinControl2006-09-13 03:53:16 AM cppbuilder2 Stefan wrote: QuoteHow can I determine the size of the content of a webform, loaded in the Hans. |
Stefan
![]() CBuilder Developer |
2006-09-13 03:56:44 AM
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 |
Stefan
![]() CBuilder Developer |
2006-09-13 05:47:44 PM
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 QuoteStefan wrote: {smallsort} |
Hans Galema
![]() CBuilder Developer |
2006-09-13 06:12:35 PM
Re:Re: TWebBrowser/TWinControl
Stefan wrote:
QuoteI think htmlpage would have been the right word. 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. |
Stefan
![]() CBuilder Developer |
2006-09-13 10:40:13 PM
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 QuoteStefan wrote: |
Hans Galema
![]() CBuilder Developer |
2006-09-14 02:56:57 AM
Re:Re: TWebBrowser/TWinControl
Stefan wrote:
QuoteThe sample-html which I am displaying is a little big bigger 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. |
Mark Finkle
![]() CBuilder Developer |
2006-09-14 11:43:00 AM
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 QuoteHow can I determine the size of the content of a webform, loaded in the |
Stefan
![]() CBuilder Developer |
2006-09-14 07:37:20 PM
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 |