PDA

Ver la Versión Completa : mover raton con cursores


elcaracas
01-05-2005, 17:11:59
Podría decirme alguien, cómo puedo mover el raton con los cursores?

Gracias!!

Neftali [Germán.Estévez]
02-05-2005, 09:40:58
Puedes utilizar las API's GetCursorPos y SetCursorPos.
Un ejemplo sencillo puedes verlo con ésto; Crea un form nuevo y en el evento FormKeyDown coloca el siguiente código:


procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
pt:TPoint;
begin
// Posicion actual
GetCursorPos(pt);

// Segun la tecla movemos....
if key = VK_UP then begin // arriba
SetCursorPos(pt.x, pt.y - 1);
end
else if key = VK_DOWN then begin // abajo
SetCursorPos(pt.x, pt.y + 1);
end
else if key = VK_LEFT then begin // izquierda
SetCursorPos(pt.x - 1, pt.y);
end
else if key = VK_RIGHT then begin // derecha
SetCursorPos(pt.x + 1, pt.y);
end;
// procesar mensajes en cola
Application.ProcessMessages;
end;

elcaracas
02-05-2005, 10:54:13
Muchas Gracias.

En C++ Builder no es TPoint pt; sino tagPOINT* pt;

Un saludo