首页 > 代码库 > delphi Sender和Tag的用法
delphi Sender和Tag的用法
var
Form1: TForm1;
SelectedColor:TColor;//clBlack; //Default
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
SelectedColor:=clBlack; //Default
end;
//将这些控件全部选中然后使用双击 OnClick事件
//OnClick获得返回值
procedure TForm1.img11Click(Sender: TObject);
begin
if TImage(Sender)=img1 then SelectedColor:=clBlack;
if TImage(Sender)=img2 then SelectedColor:=$00002AA5;
if TImage(Sender)=img3 then SelectedColor:=$00404000;
if TImage(Sender)=img4 then SelectedColor:=$00005500;
if TImage(Sender)=img5 then SelectedColor:=$005E0000;
if TImage(Sender)=img6 then SelectedColor:=clNavy;
if TImage(Sender)=img7 then SelectedColor:=$00993333;
if TImage(Sender)=img8 then SelectedColor:=$00282828;
if TImage(Sender)=img9 then SelectedColor:=$0000008B;
if TImage(Sender)=img10 then SelectedColor:=$002068FF;
if TImage(Sender)=img11 then SelectedColor:=$00008B8B;
if TImage(Sender)=img12 then SelectedColor:=$00009300;
if TImage(Sender)=img13 then SelectedColor:=$008E8E38;
if TImage(Sender)=img14 then SelectedColor:=clBlue;
if TImage(Sender)=img15 then SelectedColor:=$00996666;
if TImage(Sender)=img16 then SelectedColor:=$00666666;
if TImage(Sender)=img17 then SelectedColor:=clRed;
if TImage(Sender)=img18 then SelectedColor:=$005BADFF;
if TImage(Sender)=img19 then SelectedColor:=$0032CD32;
if TImage(Sender)=img20 then SelectedColor:=$0071B33C;
if TImage(Sender)=img21 then SelectedColor:=$00D4FF7F;
if TImage(Sender)=img22 then SelectedColor:=$00FF6633;
if TImage(Sender)=img23 then SelectedColor:=clPurple;
if TImage(Sender)=img24 then SelectedColor:=$007F7F7F;
if TImage(Sender)=img25 then SelectedColor:=clFuchsia;
if TImage(Sender)=img26 then SelectedColor:=$0000D7FF;
if TImage(Sender)=img27 then SelectedColor:=clYellow;
if TImage(Sender)=img28 then SelectedColor:=clLime;
if TImage(Sender)=img29 then SelectedColor:=$00D0E040;
if TImage(Sender)=img30 then SelectedColor:=$00FFFFC0;
if TImage(Sender)=img31 then SelectedColor:=$00663399;
if TImage(Sender)=img32 then SelectedColor:=clSilver;
if TImage(Sender)=img33 then SelectedColor:=$00CC99FF;
if TImage(Sender)=img34 then SelectedColor:=$008CB4D2;
if TImage(Sender)=img35 then SelectedColor:=$0099FFFF;
if TImage(Sender)=img36 then SelectedColor:=$0098FB98;
if TImage(Sender)=img37 then SelectedColor:=$00EEEEAF;
if TImage(Sender)=img38 then SelectedColor:=$00FFCC00;
if TImage(Sender)=img39 then SelectedColor:=$00FF99CC;
if TImage(Sender)=img40 then SelectedColor:=clWhite;
//Test
Label1.Color:=SelectedColor;
end;
//OnMouseMove 样式改变
//先手动设置一下
procedure TForm1.img11MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
img_frame.Visible:=True;
img_frame.Visible:=True;
case TImage(Sender).Tag of
1:
begin
img_frame.Left:= img1.Left;
img_frame.Top := img1.Top;
end;
2:
begin
img_frame.Left:= img2.Left;
img_frame.Top := img2.Top;
end;
3:
begin
img_frame.Left:= img3.Left;
img_frame.Top := img3.Top;
end;
4:
begin
img_frame.Left:= img4.Left;
img_frame.Top := img4.Top;
end;
5:
begin
img_frame.Left:= img5.Left;
img_frame.Top := img5.Top;
end;
6:
begin
img_frame.Left:= img6.Left;
img_frame.Top := img6.Top;
end;
7:
begin
img_frame.Left:= img7.Left;
img_frame.Top := img7.Top;
end;
8:
begin
img_frame.Left:= img8.Left;
img_frame.Top := img8.Top;
end;
9:
begin
img_frame.Left:= img9.Left;
img_frame.Top := img9.Top;
end;
10:
begin
img_frame.Left:= img10.Left;
img_frame.Top := img10.Top;
end;
11:
begin
img_frame.Left:= img11.Left;
img_frame.Top := img11.Top;
end;
12:
begin
img_frame.Left:= img12.Left;
img_frame.Top := img12.Top;
end;
13:
begin
img_frame.Left:= img13.Left;
img_frame.Top := img13.Top;
end;
14:
begin
img_frame.Left:= img14.Left;
img_frame.Top := img14.Top;
end;
15:
begin
img_frame.Left:= img15.Left;
img_frame.Top := img15.Top;
end;
16:
begin
img_frame.Left:= img16.Left;
img_frame.Top := img16.Top;
end;
17:
begin
img_frame.Left:= img17.Left;
img_frame.Top := img17.Top;
end;
18:
begin
img_frame.Left:= img18.Left;
img_frame.Top := img18.Top;
end;
19:
begin
img_frame.Left:= img19.Left;
img_frame.Top := img19.Top;
end;
20:
begin
img_frame.Left:= img20.Left;
img_frame.Top := img20.Top;
end;
21:
begin
img_frame.Left:= img21.Left;
img_frame.Top := img21.Top;
end;
22:
begin
img_frame.Left:= img22.Left;
img_frame.Top := img22.Top;
end;
23:
begin
img_frame.Left:= img23.Left;
img_frame.Top := img23.Top;
end;
24:
begin
img_frame.Left:= img24.Left;
img_frame.Top := img24.Top;
end;
25:
begin
img_frame.Left:= img25.Left;
img_frame.Top := img25.Top;
end;
26:
begin
img_frame.Left:= img26.Left;
img_frame.Top := img26.Top;
end;
27:
begin
img_frame.Left:= img27.Left;
img_frame.Top := img27.Top;
end;
28:
begin
img_frame.Left:= img28.Left;
img_frame.Top := img28.Top;
end;
29:
begin
img_frame.Left:= img29.Left;
img_frame.Top := img29.Top;
end;
30:
begin
img_frame.Left:= img30.Left;
img_frame.Top := img30.Top;
end;
31:
begin
img_frame.Left:= img31.Left;
img_frame.Top := img31.Top;
end;
32:
begin
img_frame.Left:= img32.Left;
img_frame.Top := img32.Top;
end;
33:
begin
img_frame.Left:= img33.Left;
img_frame.Top := img33.Top;
end;
34:
begin
img_frame.Left:= img34.Left;
img_frame.Top := img34.Top;
end;
35:
begin
img_frame.Left:= img35.Left;
img_frame.Top := img35.Top;
end;
36:
begin
img_frame.Left:= img36.Left;
img_frame.Top := img36.Top;
end;
37:
begin
img_frame.Left:= img37.Left;
img_frame.Top := img37.Top;
end;
38:
begin
img_frame.Left:= img38.Left;
img_frame.Top := img38.Top;
end;
39:
begin
img_frame.Left:= img39.Left;
img_frame.Top := img39.Top;
end;
40:
begin
img_frame.Left:= img40.Left;
img_frame.Top := img40.Top;
end;
end;
end;
来自为知笔记(Wiz)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。