1
votes

In a Delphi 10.4.2 32-bit VCL Application, I use the component TSVGIconImage from the SVGIconImageList library from the GetIt PackageManager.

Although the component supports the OnDblClick event-handler, it does NOT support the OnMouseDown event-handler! I.e., I can add an OnMouseDown event-handler by double-clicking the OnMouseDown event in the Object Inspector, however that event-handler gets never called at run-time:

procedure TformMain.SVGIconImage1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  CodeSite.Send('called!'); // never called!
end;

The TSVGIconImage component is declared in SVGIconImage.pas as:

TSVGIconImage = class(TCustomControl)

So shouldn't the TSVGIconImage component inherit its OnMouseDown event from TCustomControl?

Anyway, how can I add a working OnMouseDown event for TSVGIconImage in my application's code?

EDIT: After testing this in a separate VCL Application I found out that the TSVGIconImage OnMouseDown event handler is working there at run-time. So it must be something else that blocks the TSVGIconImage OnMouseDown event handler in my application. I have still to find out the cause.

1
You could report the issue to the developer github.com/EtheaDev/SVGIconImageListR. Hoek
I have reported it: github.com/EtheaDev/SVGIconImageList/issues/158 But shouldn't it be possible to add a working OnMouseDown event-handler in my application code?user1580348
I had a look at the repository and really couldn't find anything odd about this TCustomControl that would explain why the OnMouseDown doesn't work. So, I somewhat reluctantly downloaded the library using GetIt. After quite a few errors (like the demo project not being runnable because a published property isn't found), I made a small demo app using the TSVGIconImage. My first impression is that this is not a very good SVG renderer: it is by far the slowest SVG renderer I have ever seen, and it doesn't render my math graphs correctly. Still, the OnMouseDown handler works for me!Andreas Rejbrand
(Well, to be fair, the library is probably not meant to be a 100% compliant and high-performance SVG 1.1 renderer; it's probably supposed to be used for fairly simple icons. And it probably is a very good library for such applications.)Andreas Rejbrand

1 Answers

1
votes

A) Place a TApplicationEvents component on your form.

B) Double-click the ApplicationEvents.OnMessage event in the Object Inspector to create an OnMessage event handler and write a case-filter for WM_LBUTTONDOWN:

procedure TForm1.AppEvents1Message(var Msg: tagMSG; var Handled: Boolean);
begin
  case Msg.message of
    WM_LBUTTONDOWN:
      begin
        if Msg.hwnd = SVGIconImag1.Handle then
          DoSomething;
      end;
  end;
end;

Thanks to @AndreasRejbrand and @fpiette for their constructive and helpful input!