DruckenMister WongFacebook

Bugs in TSpeedButton beheben

System Win9x, WinNT, Win2000, WinXP, Vista, Win7
Ab Delphi-Version Delphi 1
Letzte Änderung 28.09.2010

Beim Einsatz der Komponente TSpeedButton im Flat-Style kann es passieren, dass sie sich bei schnellem Überfahren mit der Maus nicht mehr in den Flachzustand zurück begibt. Folgender Code behebt diesen Bug:In der Unit Buttons.pas müssen unter TSpeedButton.MouseUp diese Zeilen eingefügt werden:


        if FDown then FState := bsExclusive;
        Repaint;
      end;
+    if FFlat and Enabled then
+    begin
+      GetCursorPos(P);
+      FMouseInControl := FindDragTarget(P, True) <> Self;
+      if FMouseInControl and not FDragging then
+      begin
+        FMouseInControl := False;
+        Invalidate;
+      end;
+    end;
  end;
end;
 

Datei Forms.pas in TApplication.DoMouseIdle:


  CaptureControl: TControl;
  P: TPoint;
+  ParentForm: TCustomForm;
begin
  GetCursorPos(P);
  Result := FindDragTarget(P, True);
if (Result <> nil) and (Result is TGraphicControl) then
begin
+    ParentForm := GetParentForm(Result);
+    if ParentForm <> nil then
+    begin
+      P := ParentForm.ScreenToClient(P);
+      if not PtInRect(ParentForm.ClientRect, P) then
+        Result := nil;
+    end;
end;
+
  if (Result <> nil) and (csDesigning in Result.ComponentState) then
    Result := nil;
 

Anschließend muss die VCL neu kompiliert werden. Wer ohne Packages auskommt, braucht nur die Dateien Buttons.pas und Forms.pas neu kompilieren, da sich nichts am Interface geändert hat:


cd DelphiSourceVCL
dcc32 -U....LibDebug -N....LibDebug -R....Lib Forms.pas
dcc32 -U....LibDebug -N....LibDebug -R....Lib Buttons.pas
dcc32 -$D- -U....Lib -N....Lib -R....Lib Forms.pas
dcc32 -$D- -U....Lib -N....Lib -R....Lib Buttons.pas