Handling mouse events through shaped TWinControl
Original Reporter info from Mantis: ptvs
-
Reporter name:
Original Reporter info from Mantis: ptvs
- Reporter name:
Description:
If you position TGraphicControl decendant under TWinControl decendant, and then
change TWinControl's shape with SetShape so that TGraphicControl become visible,
all mouse events on the TGraphicControl would be handled by the form.
This happens in TWinControl.IsControlMouseMsg():
[code]
// do query wincontrol children, in case they overlap
Control := ControlAtPos(SmallPointToPoint(MouseMessage.Pos),
[capfAllowWinControls]);
if Control is TWinControl then
begin
// there is a TWinControl child at this position
// TWinControl children get their own messages
// => ignore here
Control := nil;
end;
[/code]
ControlAtPos() searches for TWinControl first (capfAllowWinControls in Flags),
finds one, does not check for children (no capfRecursive in Flags) and returns
the control. And the control is set to nil. (This seems a bit senseless to me)
So, as no control found at mouse position the event handling is given to the
form.
I deleted capfAllowWinControls flag from the call, and it worked as expected
(tested on Windows 7).
I attached example project and a patch, please test.
Mantis conversion info:
- Mantis ID: 35270
- OS: Microsoft Windows 7 SP1 x86
- OS Build: 6.1.7601
- Platform: Intel Core i3-7100
- Version: 2.1 (SVN)
- Fixed in revision: r61053 (#60961061)