Finding out if scrollbar is needed



Hello Everyone!

In my webbrowser control, I don't want to show the default scrollbar,
but want to do some different stuff outside the browser when the
scrollbar would be needed (talking only about vertical scrollbar).
Hiding the scrollbar was easy, with DOCHOSTUIINFO structure and
DOCHOSTUIFLAG_SCROLL_NO flag.

Also I found some posts which helped me figure out what code to use to
know if scrollbar is needed. The result is fine (tells me the right
answer), but for some reason my browser paints differently (wrongly)
if this code is inserted. This is the first time I had to deal with
the webbrowser control, so please, could anyone check if the following
code is good?

CComPtr<IHTMLElement> pHTMLBody;
hr = pHTMLDoc2->get_body(&pHTMLBody);
if (SUCCEEDED(hr) && pHTMLBody) {
CComQIPtr<IHTMLElement2>pHTMLBody2(pHTMLBody);
if (pHTMLBody2) {
long lScrollH, lClientH;
m_bScrollNeeded =
SUCCEEDED(pHTMLBody2->get_scrollHeight(&lScrollH))
&& SUCCEEDED(pHTMLBody2->get_clientHeight(&lClientH))
&& (lScrollH > lClientH);
}
}

pHTMLDoc2 is a CComPtr<IHTMLDocument2> variable, and right before the
above call there's a successful pHTMLDoc2->write(pSafeArray); call.
(using dynamic HTML content described in Joan Murt's article:
http://www.codeproject.com/miscctrl/htmlctrlsample.asp )

I've tried to place the same code after pHTMLDoc2->close(); without
success (still paints wrongly).

Thank you in advance,
Chris

.



Relevant Pages

  • Re: Unnecessary scrollbars
    ... scrollbars should appear, where they are big, scrollbar should appear ... the side of the document in the Hebrew version, ... If you are bringing this up, is it because you believe that such has some relationship to the other layout issues and long, complex CSS code you brought so far. ... Identify the browser and browser versions which show what you believe to be problems. ...
    (comp.infosystems.www.authoring.html)
  • Re: Mozilla/Opera vertical scrollbars
    ... Even if forced to display the ... What browser version do you have? ... What extension and theme do you use? ... Does IE really show a scrollable scrollbar, ...
    (alt.html)
  • Re: Centering divs in firefox and scrollbar issue
    ... The behaviour of IE is that the scrollbar is always ... browser and the browser is the users, ... What anti-virus program do you use? ... Customer: Oh, sorry...Internet Explorer. ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: border on 100% height body creates scroll
    ... Browser is IE 7 - using XHTML 1.0. ... of 100% and then I want to put a border around the whole viewport. ... block but not the 100% sized viewport (and thus the scrollbar). ... When you add borders to an element, the content part of the element does ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: Links to Pages within Frames
    ... >> It's all very well the browser having a certain function, ... > key that does it, they've still got a scrollbar, surely? ... mouse/touchpad) to return to the nav bar, ... it beats those bus doors that are labelled boldly "THIS IS ...
    (uk.net.web.authoring)