delphi 在窗口作图的源代码


本文整理自网络,侵删。

 unit Unit1; 

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, Buttons, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
UpDown1: TUpDown;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
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);
private
{ Private declarations }
jyX,jyY:integer;
blht:boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
canvas.Pen.color:=clred;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
canvas.Pen.color:=clgreen;
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
canvas.Pen.Color:=clblue;
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
canvas.Pen.Width:=strtoint(edit1.Text);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
blht:=false;
speedbutton1.Down:=true;
canvas.Pen.Color:=clred;
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
jyX:=x;
jyY:=y;
blht:=true;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if blht then
begin
canvas.MoveTo(jyX,jyY);
canvas.LineTo(x,y);
jyX:=x;
jyY:=y;
end;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
blht:= not blht;
end;
end.

相关阅读 >>

Delphi的with…do语句的用法

Delphi byte、pbyte、tbytes的转换

Delphi memo 控件光标定位

Delphi xe7 新的并行库 system.threading

Delphi 一个分割文本文件的代码

cef4Delphi 语言区域设置

Delphi资源文件的详细使用方法

Delphi 十六进制数转换十进制数

Delphi hmac256

Delphi2010安装twordapplication控件

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...