一个form放了8张image(每个image控件有两张不同状态的图片),现在要求做一个程序,当用户点击某个按键后,这8个图片轮流显示,如8张图片默认的image分别是,1,2,3,4,5,6,7,8,当轮到image1是,他的显示的图片就变成11。类似一些赌博游戏
解决方案 »
- Oracle数据库 dephi 7.0,在修改DBGridEh2一个字段时发生错误“缺少用于更新或刷新的基本表信息”
- fastreport
- windows 关机效果 那样的最上层的模式窗口
- 关于一复杂的字符串问题(Ip型).哥哥姐姐帮帮忙啦~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 求助!
- ★★★★★究竟谁是垃圾,CSDN有史以来最有影响力的两大高手开始辩论★★★★★--上海交大的migthline和亡灵法师alienbat
- 为什么有记录却找不到?SQL语句的关键部分是:WHERE (时间 = #5/13/2003 15:13:13# )
- 如何让popup消失
- 打印问题
- 怎么通过回车激发一个事件?
- 关于数据实时刷新的问题
- 关于delphi字符串一个很怪诞的问题!
1.直接Load.
2.将图片做成资源文件.
3.使用ImageList.
如第一种:
img1.Picture.LoadFromFile('c:\1.bmp');
“当轮到image1是,他的显示的图片就变成11了” ——什么意思?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ImgList, ExtCtrls;type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Image3: TImage;
Image4: TImage;
Image5: TImage;
Image6: TImage;
Image7: TImage;
Image8: TImage;
ImageList1: TImageList;
Button1: TButton;
Timer1: TTimer;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
ImgIndex: Integer = 0;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled := True; //开始
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled := False; //停止
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
tmp: TBitMap;
I: Integer;
begin
ImgIndex := ImgIndex + 1;
if ImgIndex > 8 then ImgIndex := 0; for i := self.ControlCount -1 downto 0 do
begin
if self.Controls[i] is TImage then
begin
tmp := TBitmap.Create; //临时图片资源
if (self.Controls[i] as TImage).Name = 'Image' + IntToStr(ImgIndex) then
ImageList1.GetBitmap(ImgIndex - 1, tmp) //当前激活图片
else
ImageList1.GetBitmap(8, tmp); //表示你希望的图片11 (self.Controls[i] as TImage).Picture.Assign(tmp);
tmp.Free;
end;
end;
end;end.
更换图片简单的算法,设置i,如果i mod 10即可显示ImageList中的第n个
to kampan
现在有一疑问,每个pictureBox都有轮转限制次数。如pictureBox8最多可以轮转3次,第一次轮转结束选择到pictureBox8 ,第三次和第5次也选到pictureBox8,那么以后的轮转,pictureBox8就不能参加轮转啦!