Solved

Disable just my mouse

Posted on 2002-06-17
8
141 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

947 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

23 Experts available now in Live!

Get 1:1 Help Now