我依照別人做了一個小小的繪圖程序,現拿出來與大家共同討論!該程序可以直接在畫板上畫直線、矩形、圓三種圖形。
==========================================================================================unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Button1: TButton;
Label1: TLabel;
ComboBox1: TComboBox;
Image1: TImage;
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
intX,intY:integer;implementation{$R *.DFM}procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);(其中之X,Y代表什麼?)
begin
intX:=X;
intY:=Y;
if comboBox1.ItemIndex<3 then
image1.canvas.MoveTo(X,Y);//Moveto的用法?
end;procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
rctDrawn:TRect;//我想問TRect是不是象Integer類型一樣定義?
begin
rctDrawn.Left:=intX;//我不明白以下四句是干嘛的?
rctDrawn.top:=intY;
rctDrawn.Right:=X;
rctDrawn.Bottom:=y;
case ComboBox1.ItemIndex of
0:
image1.Canvas.LineTo(X,Y);
1:
image1.Canvas.Rectangle(intX,intY,X,Y);//這一句原為:image1.Canvas.FrameRect(rctDraw);
2:
image1.Canvas.Ellipse(intX,intY,X,Y);
end
end;end.
=============================================
為了討論方便我簡化了一部分細節功能,程序中有image/GroupBox/ComboBox構件各一個,主要功能是在image的MouseDown/MouseUp功能中實現的,我想問的就是那個“rctDrawn:TRect;”好象rctDrawn被定義成TRect類型以後就有了left/top/right/bottom四個點,可是我發現根本就不需要用這個也可以實現畫圖的。另外那個MouseDown/MouseUp事件中的X,Y之值好象就是拖放鼠標時的起點座標與釋放時的終點座標?請高手不吝賜教!
==========================================================================================unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Button1: TButton;
Label1: TLabel;
ComboBox1: TComboBox;
Image1: TImage;
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
intX,intY:integer;implementation{$R *.DFM}procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);(其中之X,Y代表什麼?)
begin
intX:=X;
intY:=Y;
if comboBox1.ItemIndex<3 then
image1.canvas.MoveTo(X,Y);//Moveto的用法?
end;procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
rctDrawn:TRect;//我想問TRect是不是象Integer類型一樣定義?
begin
rctDrawn.Left:=intX;//我不明白以下四句是干嘛的?
rctDrawn.top:=intY;
rctDrawn.Right:=X;
rctDrawn.Bottom:=y;
case ComboBox1.ItemIndex of
0:
image1.Canvas.LineTo(X,Y);
1:
image1.Canvas.Rectangle(intX,intY,X,Y);//這一句原為:image1.Canvas.FrameRect(rctDraw);
2:
image1.Canvas.Ellipse(intX,intY,X,Y);
end
end;end.
=============================================
為了討論方便我簡化了一部分細節功能,程序中有image/GroupBox/ComboBox構件各一個,主要功能是在image的MouseDown/MouseUp功能中實現的,我想問的就是那個“rctDrawn:TRect;”好象rctDrawn被定義成TRect類型以後就有了left/top/right/bottom四個點,可是我發現根本就不需要用這個也可以實現畫圖的。另外那個MouseDown/MouseUp事件中的X,Y之值好象就是拖放鼠標時的起點座標與釋放時的終點座標?請高手不吝賜教!
解决方案 »
- TClientdataset beforepost方法
- 猜猜这是什么语言
- TComponentList的Add既然有毒!
- 请教:如何将octet string类型转换成string类型显示
- 通过FTP取得的文件怎么分开信息的??? 新手问
- 请问delphi入门的书都是哪些啊
- 请问socket5代理和用socket做代理有什么联系,我做了一个代理服务器软件,但是不能代理oicq!为什么?
- 我一菜鳥,問一簡單問題.
- SOS....帮帮我
- table1中的字段过虑,能否单个字符匹配,像用query中的下划线_?
- 怎么改变toolbutton的大小?
- DbGrid的问题 关于DbGrid的列的宽度的问题?
rctDrawn:TRect;
rctDrawn.Left:=intX
rctDrawn.top:=intY;
rctDrawn.Right:=X;
rctDrawn.Bottom:=y;
image1.Canvas.FrameRect
几句不懂,而且我也根本就没有用这几句,完全用自己的方法也可以实现同样功能。大家是不是对繁体字很讨厌,没有办法,我现在台湾人企业,只好用繁体!不过我现在也可以在繁体系统下输入简体字。