Einzelnen Beitrag anzeigen

Joe24

Registriert seit: 21. Dez 2004
Ort: Berlin
51 Beiträge
 
#8

Re: Maus abschalten je nach Form

  Alt 27. Dez 2004, 02:19
So funktioniert es:

Delphi-Quellcode:
var
  r : TRect;
begin
  r := Rect( Left, Top, Right, Bottom);
  ClipCursor( @r);
end;
mit Right = Left
und Bottom = Top.

ClipCursor ist eine API-Funktion.


Oder ander Variante über OnMouseMove-Event

Delphi-Quellcode:
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState;
    X, Y: Integer);
var
  CurPos : TPoint;
begin
  CurPos := Mouse.CursorPos;
  if ( X < Width div 2) and
     ( Y > X) and
     ( Y < Height -X) then
    CurPos := Point( Left , CurPos.Y) else
  if not ( X < Width div 2) and
     ( Y > Width -X) and
     ( Y < Height -( Width -X)) then
    CurPos := Point( Left +Width , CurPos.Y) else
  if ( Y < Height div 2) and
     ( X > Y) and
     ( X < Width -Y) then
    CurPos := Point( CurPos.X, Top) else
  if not ( Y < Height div 2) and
     ( X > Height -Y) and
     ( X < Width -( Height -Y)) then
    CurPos := Point( CurPos.X, Top +Height);
  if ( CurPos.X = Mouse.CursorPos.X) and
     ( CurPos.Y = Mouse.CursorPos.Y) then
    ShowCursor( TRUE) else
    begin
      CurPos := Mouse.CursorPos;
      ShowCursor( FALSE);
    end;
end;
  Mit Zitat antworten Zitat