Question

I created a TEventObject to provide OnMouseDown and OnMouseMove events for TWebBrowser. The events work perfectly when moving the mouse and when clicking in the webbrowser, but when I scroll or click the webbrowser's vertical scrollbar a EZeroDivide exception ocurs. EurekaLog reports a EZeroDivide exception in d2d1.dll. I tried to trap the exception but nothing I have tried seems to work:

function TEventObject.Invoke( DispID: integer; const IID: TGUID; LocaleID: integer; Flags: Word; var Params;
  VarResult, ExcepInfo, ArgErr: Pointer ): HResult;
begin
  try
    if ( DispID = DISPID_VALUE ) then
    begin
      if Assigned( FOnEvent ) then
        FOnEvent;
      Result := S_OK;
    end
    else
    begin
      FOnEvent := nil;
      Result := E_NOTIMPL;
    end;
  except
    on EZeroDivide do
    begin
      FOnEvent := nil;
      Result := E_NOTIMPL;
    end;
  end;
end;

My question is can I prevent the exception somehow or can mousedown on the TWebbrowser vertical scrollbar be detected to prevent the exception? This exception is a difficult one for me to solve because I do not know much about TEventObject and I do not understand why the exception only ocurs when clicking or dragging the vertical scrollbar. I can provide more infomation if needed. Compiler: Delphi 2010.

[Edit] See this post: http://www.codenewsfast.com/cnf/article/0/waArticleBookmark.7401953 A very simple demo app is available at: http://dl.dropbox.com/u/2167512/bugs/ie9/ie9_bug.zip

This prevents the bug:

Math.SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,exOverflow, exUnderflow, exPrecision]);
Was it helpful?

Solution

try to disable FPU exceptions:

System.Set8087CW($133F);

In the newer versions of Delphi:

Math.SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top