The following code centers the cursor and draws a cross on the full screen:
Procedure tform1.button1click (Sender: tobject );
VaR
Fullscreencanvas: TCanvas;
DC: HDC;
Begin
DC: = getdc (0); // obtain the DC of the screen. parameter 0 indicates the screen.
Fullscreencanvas: = TCanvas. Create; // create a canvas object
Fullscreencanvas. Handle: = Dc; // You can associate the canvas with a screen handle to make a picture.
Fullscreencanvas. moveTo (mouse. cursorpos. X, 0 );
Fullscreencanvas. lineto (mouse. cursorpos. X, 768 );
Fullscreencanvas. moveTo (0, mouse. cursorpos. y );
Fullscreencanvas. lineto (1024, mouse. cursorpos. y );
End;
The following code draws a cross in the center of the full screen:
Procedure tform1.button1click (Sender: tobject );
VaR
Fullscreencanvas: TCanvas;
DC: HDC;
Begin
DC: = getdc (0); // obtain the DC of the screen. parameter 0 indicates the screen.
Fullscreencanvas: = TCanvas. Create; // create a canvas object
Fullscreencanvas. Handle: = Dc; // You can associate the canvas with a screen handle to make a picture.
Fullscreencanvas. moveTo (screen. Width Div 2, 0 );
Fullscreencanvas. lineto (screen. Width Div 2,768 );
Fullscreencanvas. moveTo (0, screen. Height Div 2 );
Fullscreencanvas. lineto (1024, screen. Height Div 2 );
End;
// The following code periodically draws a cross, a square, and a circle in the middle of the screen
Procedure tform1.timer1timer (Sender: tobject );
VaR
Mycanvas: TCanvas;
DC: HDC;
Begin
DC: = getdc (0 );
Mycanvas: = TCanvas. Create;
// Mycanvas. Brush. Color: = clblack; // black fill color
Mycanvas. Brush. Style: = bsclear; // No background color
Mycanvas. Handle: = Dc;
// Mycanvas. Brush. Bitmap: = image1.picture. Bitmap;
Mycanvas. moveTo (screen. Width Div 2, 0 );
Mycanvas. lineto (screen. Width Div 2, screen. Height );
Mycanvas. moveTo (0, screen. Height Div 2 );
Mycanvas. lineto (screen. Width, screen. Height Div 2 );
Mycanvas. rectangle (screen. width Div 2-100, screen. height Div 2-100, screen. width Div 2 + 100, screen. height Div 2 + 100); // draw a square in the center of the screen
Mycanvas. ellipse (screen. width Div 2-100, screen. height Div 2-100, screen. width Div 2 + 100, screen. height Div 2 + 100); // draw a circle in the center of the screen
Mycanvas. textout (720,300, 'test again, test the feeling of writing directly on the screen! '); // Add text to the canvas object
End;