Solved

Disable just my mouse

Posted on 2002-06-17
8
143 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 150
Delphi XE10 Round Image 2 158
Convert a string into a TDateTime 5 64
MS Access from Delphi 31 60
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…

839 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