用delphi作平面图的问题 我刚开始学习delphi,想做一个下面的东西,请大家帮帮忙吧,要是有源码就更好了,在此先谢谢了。1.在一个平面内,根据简易的坐标画几个填充了不同颜色的方块,每个方块有自己的名字2.当光标移至方块上时提示方块的名字真的很着急,在线等 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果仅仅是为了画几个色块的话,可以考虑动态生产Shape 把楼上的意思给你写城代码:procedure TForm1.Button1Click(Sender: TObject);varsp : TShape;begin sp := TShape.Create(nil); sp.Parent := Form1; sp.Width := 100; sp.Height := 100; sp.Left := 100; sp.Top := 100; sp.ShowHint := true; sp.Hint := 'sp'; //sp.OnMouseMove := bMouseMoveEvent;end; 用了wudi_1982的代码后确实可以,但是还有3个问题:1.怎么让每个shape有自己的颜色呢?2.还有就是在点击不同的shape时,弹出不同的对话框?3.shape里面怎么填充字?在帮帮忙吧,谢谢了 不用TShape,用TLabel:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure aLabelClick(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; i:integer=0;implementation{$R *.dfm}procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var aLabel:TLabel;begin i:=i+1; Randomize; aLabel:=TLabel.Create(self); with aLabel do begin Color:=Random($FFFFFF); Caption:=IntToStr(i); Top:=Y; Left:=X; Width:=50; Height:=50; Alignment:=taCenter; Layout:=tlCenter; Parent:=Form1; ShowHint:=True; Hint:=Caption; OnClick:=aLabelClick; end;end;procedure TForm1.aLabelClick(Sender: TObject);begin ShowMessage(TLabel(Sender).Caption);end;end. 有沒有什麽好用的,不要錢的二維碼控件 从A.exe中打开B.exe的问题 Webbrowser移动闪的问题,搞了一个月了,各位兄弟进来看一下 如何删除TStringList类型中的一行值? 请帮忙:我如何才能修改statusbar上的汉字的颜色? 100分,左轻侯大侠的大富翁离线源码解释 一个问题 聊天记录 在家里的电脑上装了delphi,开发了数据库程序,想到另一个台没有装delphi的电脑上面运行,总是报错 如何在开机时运行一个可执行文件 用delphi作平面图的问题 黑龙江软通国际这个公司到底怎么样,怎么总是在招人?
procedure TForm1.Button1Click(Sender: TObject);
var
sp : TShape;
begin
sp := TShape.Create(nil);
sp.Parent := Form1;
sp.Width := 100;
sp.Height := 100;
sp.Left := 100;
sp.Top := 100;
sp.ShowHint := true;
sp.Hint := 'sp';
//sp.OnMouseMove := bMouseMoveEvent;
end;
1.怎么让每个shape有自己的颜色呢?
2.还有就是在点击不同的shape时,弹出不同的对话框?
3.shape里面怎么填充字?
在帮帮忙吧,谢谢了
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure aLabelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
i:integer=0;
implementation{$R *.dfm}procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var aLabel:TLabel;
begin
i:=i+1;
Randomize;
aLabel:=TLabel.Create(self);
with aLabel do
begin
Color:=Random($FFFFFF);
Caption:=IntToStr(i);
Top:=Y;
Left:=X;
Width:=50;
Height:=50;
Alignment:=taCenter;
Layout:=tlCenter;
Parent:=Form1;
ShowHint:=True;
Hint:=Caption;
OnClick:=aLabelClick;
end;
end;procedure TForm1.aLabelClick(Sender: TObject);
begin
ShowMessage(TLabel(Sender).Caption);
end;end.