TWebBrowser with Align setting for alClient will not change when client area changes

I have a form with several splitters and panels. In the middle is the panel in which TWebBrowser is installed to align alClient.

In the past, this worked well. However, in Windows 7 with Internet Explorer 8, the browser is not correctly modified. Everything else (i.e. Panels) is the correct size, not a web browser. Sometimes, when you click in the browser, or more often when you view the browser, you go to the right size. This does not occur for 100% of the time.

I am trying to deal with resizing directly and getting the control to resize. I cannot find a method that has any meaning (i.e. .Invalidate; .Repaint; .Update;)

TWebBrowser is an OLE (ActiveX) control that wraps an Internet Explorer control. Any ideas on how I can resize?

Updated Background:

I narrowed this down only when I have a child form that I am changing my parent to place it in another form. My TWebBrowser control is in a child form that I use anytime I need to display an HTML document.

In my parent form, I have a Grid, a separator and a panel with a grid set to align on top, and a panel configured to align the client. My child form (called THtmlViewer) has a parent set in the panel. The THtmlViewer form is set to alClient, and the TWebBrowser control in the child form is also configured to align the client.

- THtmlViewer, . , FormResize , align. , , .

, THtmlViewer. OnResize , , , .

, , (THtmlViewer).

, Delphi 2007 Windows 7 ​​ " " IDE.

, , OnResize nil, ForceResize OnResize. THtmlViewer , .

+1
4

, , , "just" Align:

  • Anchors Align, Align alCustom alNone, . Align , , .

  • OnResize , TWebBrowser TWebBrowser ( , ).

, Windows7, , .

TWebBrowser , , , , .

, - . OnResize, , " TWebBrowser".

- "" Invalidate Update, csOpaque ControlStyle, . , TWebBrowser / , .

, WM_PAINT ( ) TWebBrowser. OnResize TWebBrowser , . WM_Paint TWebBrowser OleDraw, ActiveX ClientRect, OnResize.

+2

, : AcroPDF Delphi

OnResize:

if Visible and (WebBrowser1 <> nil) then 
begin
  FocusControl(nil);
  FocusControl(WebBrowser1);
end;
+1

.

This was resolved by placing TPanelβ€œunder” TWebBrowserand aligning the web browser with alClient.

+1
source

I would try something like

  • change WebBrowser1.Align to alLeft,
  • setting WebBrowser1.Width for WebBrowser1.Width - 1 and
  • setting WebBrowser1.Align for alClient again

in the OnResize handler.

0
source

All Articles