Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable just my mouse

Posted on 2002-06-17
8
Medium Priority
?
149 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

916 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