2008. február 8., péntek

How to fix the incorrect painting of an ActiveX control, which occurs when a web page is scrolled


Problem/Question/Abstract:

How to fix the incorrect painting of an ActiveX control, which occurs when a web page is scrolled

Answer:

In Delphi 4, when an ActiveForm is larger than the browser window the control is on top of IE's scroll bars. In Delphi 5 they changed the code to fix this but didn't get it quite right resulting in the painting problem when scrolling. You need to edit the Delphi 5 AxCtrls unit as follows:


function TActiveXControl.SetObjectRects(const rcPosRect: TRect;
  const rcClipRect: TRect): HResult;
var
  WinRect: TRect;
begin
  try
    IntersectRect(WinRect, rcPosRect, rcClipRect);
    {BEGIN FIX}
    WinRect := Bounds(rcPosRect.left, rcPosRect.Top, WinRect.Right - WinRect.Left +
      rcClipRect.Left - rcPosRect.Left, WinRect.Bottom - WinRect.Top +
      rcClipRect.Top - rcPosRect.Top);
    {END FIX}
    FWinControl.BoundsRect := WinRect;
    Result := S_OK;
  except
    Result := HandleException;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése