Thema: Delphi MouseMove außerhalb

Einzelnen Beitrag anzeigen

Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.337 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: MouseMove außerhalb

  Alt 21. Jan 2014, 11:21
aus einem älteren Projekt von mir:

Delphi-Quellcode:
function IsMouseOverControl(const ctrl: TControl): boolean;
var
  sr: TRect;
begin
  sr := Rect(ctrl.ClientToScreen(Point(0, 0)), ctrl.ClientToScreen(Point(ctrl.Width, ctrl.Height)));
  result := PtInRect(sr, Mouse.CursorPos);
end;

procedure TFormSettingKo.TimerZoomTimer(Sender: TObject);
var
  YD, XD, YG: Integer;
  SY, Y: Integer;
  F: Boolean;
begin
  YD := odDesignerKo.Top + odDesignerKo.Height;
  XD := odDesignerKo.Left;
  YG := GroupBoxZoom.Top - 12;
  SY := GroupBoxZoom.Height;
  GroupBoxZoom.Parent := odDesignerKo.Parent;
  GroupBoxZoom.Left := XD;
  Y := YD - YG;
  if (IsMouseOverControl(GroupBoxZoom)) and (IsMouseOverControl(Self)) then
    begin
      F := Y <> SY;
      Y := Min(Y, SY);
      if F then
        begin
          GroupBoxZoom.Width := Round(200 * (Y / SY));
          TimerZoom.Interval := 1;
          Inc(Y);
        end
      else
        TimerZoom.Interval := 1000;
      GroupBoxZoom.Top := YD - Y + 12;
      GroupBoxZoom.Left := XD;
    end
  else
    begin
      F := Y <> 12;
      Y := Max(Y, 12);
      if F then
        begin
          GroupBoxZoom.Width := Round(40 * (Y / 12));
          TimerZoom.Interval := 1;
          Dec(Y);
        end
      else
        TimerZoom.Interval := 1000;
      GroupBoxZoom.Top := YD - Y + 12;
      GroupBoxZoom.Left := XD;
    end;
  CheckBoxZoomAuto.Visible := GroupBoxZoom.Width > 60;
  GroupBoxZoom.Visible := True;
  GroupBoxZoom.BringToFront;
end;
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat