Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make cursor move ??

Status
Not open for further replies.

delphinewbie

Programmer
Dec 10, 2003
14
0
0
MY
Can anyone help me with the following problem:

I want to wite a program that can move the cursor around on the top
of the desktop after i click at the "Move" button on the main form...
the cursor should not be inside the form.. but on the top of the desktop
and outside the main form .. can anyone help me that ..
ur help is appreciated ... thx...
 
Modification here ..
Once i click at the button, the cursor will move verticallly from top of the desktop to the bottom of the desktop .. And bottom to top .. the action is repeat and repeat until i click at "Stop" button on the main form .. hope ya guys can help.. thx..
 
This example makes the cursor go from left to right and vice versa at top of desktop with steps of 40 pixels each 100ms.
I can't say anything about if this snippet is correct code..

paste this code into a mainform:


unit Unit1;

interface

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

type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
x: Integer;
xstep: Integer;
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
x := x + xstep;
if (x >= Screen.Width) or (x<=0) then
xstep := xstep * -1;
Mouse.CursorPos := Point(x,0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
xstep := 40;
end;

end.
 
i copy ur source code ...
and then i create another new form(form2) and put a button on that form ..

Once the user click at the button on form 2, I will call the Timer1Timer(Sender: TObject) procedure .... so what should i put as the parameter for (Sender : TObject) .. again .. thanks for ya help..
 
Dont call timer.timer ... the system des that for ya ;P
just enabled / disble the timer:

Timer1.enabled := True;


grtn
- fruNNik
 
But i need to click a button .. so the cursor will move around.. what code should i put for the button then ??
 
for ya info, i put the button on another form, and once i click at the bottom , i want the cursor to move up and down .. what should i do ?? i had try, but still can't make it .. cos i'm only newbie ..hope ya guys can help...thx again
 
Ok .
Everything is done ..
and another problem arise ..

Once i click at the &quot;Move&quot; button, the cursor is move unstopply .. Cos i'm using the loop function to do it .. so i guess it might exhausted the RAM .. so is that any way i can improve it ??

Err .. prolly i can use the time to control the movement of the cursor .. let's say for every 5 seconds, the cursor will move to top of the screen, and another 5 seconds, the cursor will move to the bottom of the screen... can anyone help me with this ? thx ..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top