Solved

Disable just my mouse

Posted on 2002-06-17
8
140 Views
Last Modified: 2010-04-04
I know how to disable the keyboard & the mouse.
But how can I disable just the mouse ? I wish to move my cursor through codes so if the user move the mouse I get an uggly effect.
0
Comment
Question by:ginsonic
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 2

Expert Comment

by:333
ID: 7086003
and how you disable keyboard & mouse? are you using hooks or something else?
0
 
LVL 17

Expert Comment

by:geobul
ID: 7086241
Hi,
Perhaps hiding the mouse cursor is a solution.

procedure TForm1.Button1Click(Sender: TObject);
begin
  Screen.Cursor := crNone;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Screen.Cursor := crDefault;
end;

If it's not then:

procedure TForm1.CursorMoveToAndClip(cx,cy: integer);
var
  x,y: integer;
  p: TPoint;
  r: TRect;
begin
  ClipCursor(nil);
  p.x := cx;
  p.y := cy;
  p := Form1.ClientToScreen(p);
  SetCursorPos(p.x, p.y);
  r.TopLeft := p;
  r.BottomRight := p;
  ClipCursor(@r);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  CursorMoveToAndClip(10, 10);
  Sleep(2000);
  CursorMoveToAndClip(Form1.ClientWidth - 10, ClientHeight - 10);
end;

// and finally release the cursor
procedure TForm1.Button4Click(Sender: TObject);
begin
  ClipCursor(nil);
end;

Regards, Geo
0
 
LVL 6

Expert Comment

by:edey
ID: 7089923
you'd also want to unclip this cursor in your main form's onclose or perhaps in your project files after the Application.Run; , just to make sure that it's called before your app exits.

GL
Mike
0
 
LVL 9

Author Comment

by:ginsonic
ID: 7090202
No way . I create an animation movement so the cursor can't be hidden .
This is the ideea . When I make the animation and the user move the mouse I get an uggly effect :(
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 6

Expert Comment

by:edey
ID: 7091021
or just clip the cursor to a really small rect

GL
Mike
0
 
LVL 17

Accepted Solution

by:
geobul earned 100 total points
ID: 7091849
ginsonic,
please read my comment again (especially its second part).

Regards, Geo
0
 
LVL 6

Expert Comment

by:edey
ID: 7091869
and you can with clipcursor, check this :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var
   r : TRect;
begin
     r.Left := (screen.width div 2)+round(cos(3.14159265*tag/180)*(screen.width div 2));
     r.top := (screen.height div 2)+round(sin(3.14159265*tag/180)*(screen.height div 2));
     r.Right := r.Left;
     r.Bottom := r.Top;
     clipCursor(@r);
     tag := tag + 1;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     clipCursor(nil);
end;

end.


GL
Mike
0
 
LVL 9

Author Comment

by:ginsonic
ID: 7097799
Isn't exactly what I want but ...
Thanks for suppoert.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now