There are a lot of small software about the doodle desktop, it is really fun, now use Delphi to achieve it. I recommend using delphi because he is too much.
Easy!
First, create a new Application, set the WindowsTate of Form1 to WSMaximized, and BorderStyle is set to BSNON. The purpose of this is
You can make the window's Client area full screen, then we can paint on it.
Next, write the code of the client area displaying the screen picture in the Form's oncreate event (Key Step)
Procedure TForm1.FormCreate (Sender: TOBJECT); Beginbrush.Style: = BSCLEAR; / / The implementation method here is the easiest end of Delphi;
Ok, you can add the program that will be added later. Here is all Delphi code, this program debugged in Win2000 Delphi6!
Unit unit1;
Interface
Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs
type TForm1 = class (TForm) procedure FormCreate (Sender: TObject); procedure FormMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure FormMouseUp (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); private {Private declarations} public {Public declarations} END;
Var Form1: TFORM1; Implementation
{$ R * .dfm} // The top is Delphi automatically generated code procedure TFORM1.FormCreate (Sender: TOBJECT); beginbrush.style: = BSCLEAR; TAG: = 0; // Using Form's Tag attribute as flag end END ;
Procedure TForm1.FormMousedown (Sender: Tobject; Button: TMouseButton; Shift: TshiftState; x, y: integer; begintag: = 1; // Set Canvas.Moveto (x, y); // Move PEN's position to Current // Take the random number Randomize; canvas.pen.width: = Random (30); // Set the width of the brush canvas.pen.color: = RGB (Random (255), Random (255), Random (255)) ; // Set the color end of the brush;
procedure TForm1.FormMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); beginif Tag = 1 thenbegin Canvas.LineTo (x, y); // draw a line end; end; procedure TForm1.FormMouseUp (Sender: TObject Button: TMouseButton; Shift: TshiftState; x, y: integer; begintag: = 0; // flag end;
Procedure TFORM1.FORMKEYDOWN (Sender: Tobject; var key: word; shift: tshiftstate); beginif key = 27 Then Close (); // Decision If you press the ESC button to exit the program END;
End.