diff --git a/lcl/controls.pp b/lcl/controls.pp index f66b152c69..ef0dcdeb33 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -2651,44 +2651,52 @@ var begin //DebugLn('SetCaptureControl Old=',DbgSName(CaptureControl),' New=',DbgSName(Control)); if (CaptureControl=Control) then exit; - if Control=nil then begin + + if Control = nil then + begin {$IFDEF VerboseMouseCapture} DebugLn('SetCaptureControl Only ReleaseCapture'); {$ENDIF} // just unset the capturing, intf call not needed - CaptureControl:=nil; + CaptureControl := nil; ReleaseCapture; - exit; + Exit; end; - OldCaptureWinControl:=FindOwnerControl(GetCapture); + + OldCaptureWinControl := FindOwnerControl(GetCapture); if Control is TWinControl then - NewCaptureWinControl:=TWinControl(Control) + NewCaptureWinControl := TWinControl(Control) else - NewCaptureWinControl:=Control.Parent; - if NewCaptureWinControl=nil then begin + NewCaptureWinControl := Control.Parent; + + if NewCaptureWinControl = nil then + begin {$IFDEF VerboseMouseCapture} DebugLN('SetCaptureControl Only ReleaseCapture'); {$ENDIF} // just unset the capturing, intf call not needed CaptureControl:=nil; ReleaseCapture; - exit; + Exit; end; - if NewCaptureWinControl=OldCaptureWinControl then begin + + if NewCaptureWinControl = OldCaptureWinControl then + begin {$IFDEF VerboseMouseCapture} DebugLN('SetCaptureControl Keep WinControl ',DbgSName(NewCaptureWinControl), ' switch Control ',DbgSName(Control)); {$ENDIF} // just change the CaptureControl, intf call not needed - CaptureControl:=Control; - exit; + CaptureControl := Control; + Exit; end; + // switch capture control {$IFDEF VerboseMouseCapture} DebugLN('SetCaptureControl Switch to WinControl=',DbgSName(NewCaptureWinControl), ' and Control=',DbgSName(Control)); {$ENDIF} - CaptureControl:=Control; + CaptureControl := Control; ReleaseCapture; SetCapture(TWinControl(NewCaptureWinControl).Handle); end; diff --git a/lcl/include/speedbutton.inc b/lcl/include/speedbutton.inc index 777ebf81bd..7a79a68a0a 100644 --- a/lcl/include/speedbutton.inc +++ b/lcl/include/speedbutton.inc @@ -48,11 +48,11 @@ begin SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y); ControlStyle := ControlStyle + [csCaptureMouse]-[csSetCaption, csClickEvents, csOpaque]; - FLayout:= blGlyphLeft; - FAllowAllUp:= false; + FLayout := blGlyphLeft; + FAllowAllUp := False; FMouseInControl := False; FDragging := False; - FShowAccelChar:=true; + FShowAccelChar := True; FSpacing := 4; FMargin := -1; Color := clBtnFace; diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 34222688a9..3595f7a735 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -4148,29 +4148,30 @@ end; ------------------------------------------------------------------------------} function TWinControl.IsControlMouseMsg(var TheMessage: TLMMouse) : Boolean; var - Control : TControl; - ScrolledOffset, - P : TPoint; + Control: TControl; + ScrolledOffset, P: TPoint; ClientBounds: TRect; begin { CaptureControl = nil means that widgetset has captured input, but it does not know anything about TControl controls } - if (FindOwnerControl(GetCapture) = Self) and (CaptureControl <> nil) - then begin + if (FindOwnerControl(GetCapture) = Self) and (CaptureControl <> nil) then + begin Control := nil; //DebugLn(['TWinControl.IsControlMouseMsg A ', DbgSName(CaptureControl), ', ',DbgSName(CaptureControl.Parent),', Self: ', DbgSName(Self)]); - if (CaptureControl.Parent = Self) - then Control := CaptureControl; + if (CaptureControl.Parent = Self) then + Control := CaptureControl; end - else begin + else + begin // do query wincontrol childs, in case they overlap Control := ControlAtPos(SmallPointToPoint(TheMessage.Pos), [capfAllowWinControls]); - if Control is TWinControl then begin + if Control is TWinControl then + begin // there is a TWinControl child at this position // TWinControl childs get their own messages // => ignore here - Control:=nil; + Control := nil; end; end;