高手請進
我依照別人做了一個小小的繪圖程序,現拿出來與大家共同討論!該程序可以直接在畫板上畫直線、矩形、圓三種圖形。
==========================================================================================
unit Unit1;
interface
uses
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之值好象就是拖放鼠標時的起點座標與釋放時的終點座標?請高手不吝賜教!
问题点数:20、回复次数:4Top
1 楼root4137(超人)回复于 2004-12-01 20:43:57 得分 0
为什么没有人回答?也可能问题太简单了?见笑了,我是Delphi新手!Top
2 楼FCU(吃羊肉串居然上火,郁闷!)回复于 2004-12-01 21:00:07 得分 20
我用DELPHI没有做过图,哎。。数学不行啊!Top
3 楼root4137(超人)回复于 2004-12-01 21:06:35 得分 0
其中我主要是对
rctDrawn:TRect;
rctDrawn.Left:=intX
rctDrawn.top:=intY;
rctDrawn.Right:=X;
rctDrawn.Bottom:=y;
image1.Canvas.FrameRect
几句不懂,而且我也根本就没有用这几句,完全用自己的方法也可以实现同样功能。大家是不是对繁体字很讨厌,没有办法,我现在台湾人企业,只好用繁体!不过我现在也可以在繁体系统下输入简体字。Top
4 楼root4137(超人)回复于 2004-12-03 07:55:22 得分 0
郁闷呀,来者有分,本人结贴!Top




