我想做一个 6*11的 格子,同时有3盏灯(红色,绿色,黄色),当我按下键盘的“1”键时,格子[0,0] 显示红色灯,按下“2”键时格子[0,1] 显示绿色灯,按下“3”键时格子[0,2] 显示黄色灯,再按下“2”键时格子[0,3] 显示绿色灯,依次类推。。当排满后就从新从格子[0,0]开始
请问DELPHI用什么控件能实现??希望能提供程序代码!!!谢谢!!!
请问DELPHI用什么控件能实现??希望能提供程序代码!!!谢谢!!!
解决方案 »
- 谁一个Speex.dll和Speex.pas文件啊?
- 与DBCHART相关,高淫们进来看看,另。我是花心小鱼。希望认识我的朋友顶我!!!
- 关于存取图片的问题
- 关于STRINGGRID的问题,如何知道已退出某个cell?急……
- 有关最顶部窗体的问题?
- 请教!我的表中有一个日期字段。我要查询出所有在某一时间段内的数据。
- 请教DELPHI图片浏览的问题
- 关于TrayIcon 控件的问题
- 使用過 devExpress 控件組中TdxDBGrid 控件的朋友,進來看一下好碼!
- (const char *)&p转化为delphi语言该是什么?
- 报表制作请教
- 问个计算的问题,说简单也简单,看大家有什么好的办法没有
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MCForms, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Panel1: TPanel;
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
Grids: array[0..10,0..5] of TLabel;
CurrPoint: TPoint;
Created: Boolean;
procedure UpdatePoint;
procedure CreateGrid;
public
{ 公共成员(变量、函数)声明 }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.UpdatePoint;
begin
if CurrPoint.x >= 5 then
begin
if CurrPoint.y >= 10 then Exit;
CurrPoint.x := 0;
Inc(CurrPoint.y);
end
else
Inc(CurrPoint.x);
end;procedure TForm1.CreateGrid;
var
I, J, FLeft, FTop, FWidth, FHeight : Integer;
begin
if Created then
begin
for I := 0 to 10 do
for J := 0 to 5 do
Grids[I,J].Color := clWhite;
CurrPoint.x := 0;
CurrPoint.y := 0;
Exit;
end; Created := True;
FLeft := 5;
FTop := 5;
FWidth := (Panel1.Width - 5*6 - FLeft) div 6;
FHeight := (Panel1.Height - 5*11 - FTop) div 11;
for I := 0 to 10 do
begin
for J := 0 to 5 do
begin
Grids[I,J] := TLabel.Create(Self);
with Grids[I,J] do
begin
AutoSize := False;
Caption := EmptyStr;
Left := FLeft;
Top := FTop;
Width := FWidth;
Height := FHeight;
Color := clWhite;
Parent := Panel1;
end;
FLeft := FLeft + FWidth + 5;
end;
FTop := FTop + FHeight + 5;
FLeft := 5;
end;
FillChar(CurrPoint,SizeOf(CurrPoint),0);
end;procedure TForm1.Button4Click(Sender: TObject);
begin
CreateGrid;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
if Not Created then CreateGrid;
Grids[CurrPoint.y,CurrPoint.x].Color := clRed;
UpdatePoint;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
if Not Created then CreateGrid;
Grids[CurrPoint.y,CurrPoint.x].Color := clGreen;
UpdatePoint;
end;procedure TForm1.Button3Click(Sender: TObject);
begin
if Not Created then CreateGrid;
Grids[CurrPoint.y,CurrPoint.x].Color := clYellow;
UpdatePoint;
end;end.
var
btn: TComponent;
begin
if Key in ['1'..'3'] then
begin
btn := FindComponent('Button'+Key);
if Assigned(btn) and (btn is TButton) then
(btn as TButton).Click;
end;
end;
设置Button1的Caption 为 Button1(&1)
设置Button1的Caption 为 Button2(&2)
设置Button1的Caption 为 Button1(&3)