4

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]);
3
  • d2d1.dll is a part of MS Direct2D
    – OnTheFly
    Jan 4, 2012 at 16:20
  • Possible duplicate gastonx.net/?p=10 :D
    – TLama
    Jan 4, 2012 at 17:12
  • @kobik, funny is that Google translator detects the language as Swedish :) Anyway +1; it seems that no one from MS has fixed that.
    – TLama
    Jan 4, 2012 at 17:27

1 Answer 1

2

try to disable FPU exceptions:

System.Set8087CW($133F);

In the newer versions of Delphi:

Math.SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);
5
  • Thank-you very much. SetExceptionMask prevents the exception... See my edit. Can there be side effects from this?
    – Bill
    Jan 4, 2012 at 16:37
  • Yeah and all of them in whole application.
    – TLama
    Jan 4, 2012 at 16:39
  • I had a long discussion about this issue. my conclusion is that there are no side effects.
    – kobik
    Jan 4, 2012 at 16:41
  • @TLama - What do you mean "Yeah and all of them in whole application"... not a good idea to use SetExceptionMask?
    – Bill
    Jan 4, 2012 at 16:43
  • @Bill, nothing more than if you divide somewhere in your application by 0 you won't get the exception. And that KB2488113 update I have already on my computer so nothing is fixed. What to say, just MS :)
    – TLama
    Jan 4, 2012 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.