0

I have a Delphi app with a TImgView32 control (part of Graphics32). I am handing the mouse move and mouse down event, and that is working. The problem is that whenever I use the right mouse button within the image, when I let go of the right mouse button (still within my image--I didn't go outside of the image before letting go)--the left mouse button does not run the button, checkbox, minimize, or any other control's events. It does an extra mouse down event in TImgView32 until click a second time. How can I get mouse clicks to go to the proper control when the mouse is no longer in my image without clicking twice? I compiled with both XE3 and 2007, and the result was the same.

menjaraz
  • 7,551
  • 4
  • 41
  • 81
Robert Richter
  • 278
  • 2
  • 9
  • I get the same behavior on Vista (32bit) and Windows7 (64 bit). – Robert Richter Nov 22 '12 at 16:50
  • are you catching mouse events on your own via WM_RBUTTONxxx, with perhaps missing to set message result? – bummi Nov 22 '12 at 17:06
  • I have an event for OnMouseDown, OnMouseMove, OnMouseWheel (which is ineffective, but the one on the main form works), OnResize, OnBitmapResize, OnPaintStage, OnScroll. All these events belong to my TImgView32 control. I am not intercepting the normal event handler, but using the event handler as set up in Delphi. – Robert Richter Nov 22 '12 at 17:10
  • And what are you *doing* in those events? I'm particularly interested in OnMouseDown. – Rob Kennedy Nov 22 '12 at 18:35
  • I disabled both by adding an "exit;" as the first line of the procedure. While the image is dead when I click, it still acts the same. If I click the right mouse button within the image, then a left mouse button anywhere outside is ignored the first time and then processed the second time. – Robert Richter Nov 22 '12 at 18:53
  • I've traced it down to adding a layer to the TImgView32 collection. Even without any events, a layer added to this control causes this behavior. – Robert Richter Nov 22 '12 at 19:10
  • This seems to fix it: "imgOriginalBitmap.Layers.MouseEvents:=False;" – Robert Richter Nov 22 '12 at 19:46
  • Looking through the source code, it is definitely a Graphics32 bug. So, I will be submitting a bug report. What is happening is that on a left mouse click, an inherited tControl.MouseCapture is set to true and released on mouse release. On a right mouse click, it is getting set, but not released. This is not a Delphi bug, but a third party component bug. – Robert Richter Nov 22 '12 at 21:14
  • @Robert - Then you can probably `ReleaseCapture` instead of disabling MouseEvents. – Sertac Akyuz Nov 22 '12 at 23:08

2 Answers2

0

As a quick and dirty fix you could just simulate a left mouse click at the end of handling the right mouse button event?

Donovan Boddy
  • 489
  • 1
  • 6
  • 14
  • Since I am not handling mouse events on layers, but only on the image, the easiest work around was to tell the layers not to capture the mouse events, and then this bug doesn't occur. As far as I am concerned, the issue is resolved, and I have submitted a bug report. – Robert Richter Nov 25 '12 at 20:06
0

This proved to be a bug in a third party component and not in Delphi or its VCL library. A bug report has been submitted. If mouse events are captured by a layer, make certain that the image or image viewer resets "MouseCapture", but if only the image needs events and not the layers, set Layers.MouseEvents to false as a work around.

Robert Richter
  • 278
  • 2
  • 9