3
votes

When TWebBrowser control is too small it becomes greyed.

If TWebBrowser control is aligned to alClient and there are no other controls on the form I can make it really small (50x10 for example). However, when I add other controls like panels, toolbar, main menu and so on which all float on top (alTop) - the more controls I add it seems, the smaller window of TWebBrowser I can get without greying itself. When window is resized to become larger, then it becomes ungreyed again.

In this example I placed TToolBar with 2 buttons aligned to alTop, and TWebBrowser aligned to alClient. If I make toolbar invisible, I can make web browser really small. However, with toolbar visible it greys itself. The more controls I add it seems to have less and less usable space before greying itself.

WebBrowser greyed

As you can see in last example web browser is even smaller than in second example but still visible and everything is the same except there is no toolbar on top. Same applies if used on Windows 7 or 8 or with Internet Explorer 10 or 11.

The examples here are just examples. I don't have a problem with having 100x100 control as minimum size. The problem is that when I place quite a bit of controls then it doesn't allow me to have smaller control than 550x250, which is quite large.

Can anyone enlighten me why other controls have an effect on web browser not being able to use smaller size when it can do this perfectly normally when there are no other controls on form?

1
I believe it's the scroll bars of the TWebBrowser you see that are grayed. if you'll drop the TWebBrowser on a panel with alClient (for both controls), you could set Constraints for the panel with MinWidth and MinHeight to 100 for example. so that the TWebBrowser could not be re-sized to 10x10. - kobik
I would be perfectly happy with 100x100 (no point in using 10x10) but the problem is the whole webbrowser becomes greyed if I have toolbar and other controls if size is smaller than 300x200 which is quite large. No, whole control is greyed, scrollbars disappear completely. Same thing happens during design mode too if form is resized to be too small. - Coder12345
Post some pictures to illustrate what you mean (before and after resize). I can't reproduce. - kobik
I can reproduce this behavior with D2009, XE but but with XE3. I can't say why it occurs, but as workaround you could place the webbrowser on e.g. panel (both align alClient). - bummi
Coder, when you refer to someone with comment, use e.g. @bummi :) - kobik

1 Answers

5
votes

Many thanks to bummi in the comments up there for finding a following workaround:

It appears that the problem with greyed control doesn't appear in XE3 and later but can be reproduced in earlier versions like XE2, XE, 2010 and 2009.

For these earlier versions the workaround is to place TWebBrowser on another control such as TPanel and then align both controls to alClient (so that the TWebBrowser fills entire TPanel and TPanel fills entire area previously filled by TWebBrowser). Of course, alignment here is not an issue but the workaround is just to place one control on another.

The same works for TEmbeddedWB and probably other controls that host Internet Explorer ActiveX control.

When placed on container control like TPanel, web browser can be resized to any size without the problem described above.