|
Delphi Tutorial Graphics - Draw cross on the desktop on mouse click,
basic technique over hears is use of full screen transparent form.
Download this example
In
order to create a full screen form, please do following changes
to the form using Object
Inspector
Window
state – Maximized
Border
style – None
Use following commands to make transparent form and set line width
and color at form create.
procedure
TForm1.FormCreate(Sender: TObject);
begin
{
Set transparent background }
Brush.Style:=bsClear;
{
Set pen color and width }
Canvas.Pen.Color:=clBlack;
Canvas.Pen.Width:=10;
end;
This
one does the drawing of crosses at mouse position.
procedure
TForm1.FormClick(Sender: TObject);
Var
X, Y : Integer;
begin
{Use
Mouse to get information about the system’s mouse,
including which window (if any) has captured
the mouse,
the position of the mouse, and mouse
settings from the
Control panel.
Use CursorPos to get the position of
the mouse cursor
in global coordinates.}
X:=Mouse.CursorPos.X;
Y:=Mouse.CursorPos.Y;
Canvas.MoveTo(0,Y);
Canvas.LineTo(Form1.Width,Y);
Canvas.MoveTo(X,0);
Canvas.LineTo(X,Form1.Height);
end;
DOWNLOAD this example
Click
here
to download this complete example for Delphi 6. (File size 6KB)

|