移动Image顺序(100)

  • 主题发起人 主题发起人 tjlqp
  • 开始时间 开始时间
T

tjlqp

Unregistered / Unconfirmed
GUEST, unregistred user!
有3个:Image1---3和一个临时Image_ls,想做成其图片位置可以随意在屏幕改变排列顺序。当鼠标单击一个Image_i时,使该图片进入临时Image_ls,其位空出;被单击的Image_i空位随即被原其后Image图片依次向前替换,空出最后一个Image无图片;再用鼠标双击某Image_j,其与其后的Image依次向后移,空出被双击的Image位置;临时Image_ls中图片放在空出的Image位置。
 
期望:点击Image1procedure TLL.Image1Click(Sender: TObject);var i:integer;begin Image_ls.Picture:=Image1.Picture ; //点击Image1,将其图片交给Image_ls Image1.Picture:= Image_null.Picture ;//Image1图片等于一个空Image,Image_null for i:=1 to 2 do //希望从第1个到第2个依次前移 begin TImage('Image' + IntToStr(i)).Picture :=TImage('Image' + IntToStr(i+1)).Picture; end; Image3.Picture:= Image_null.Picture ;//第3个,最后一个与空Image_null相同end;问题:首先这个运行不成功!其次,不简捷。
 
给你一段参考下:(image1,image2,image3共用此事件, 不需要每个图片都写一事件)procedure TForm1.Image3Click(Sender: TObject);var imageName : string;begin if image_ls.Picture.Bitmap.Empty then begin Image_ls.Picture.Graphic.Assign((sender as TImage).Picture.Graphic); imageName := (Sender as TImage).Name; imageName := Copy(imageName, 6, Length(imageName) - 5); case StrToInt(imageName) of 1: begin Image1.Picture := nil; Image1.Repaint; end; 2: begin Image2.Picture.Graphic.Assign(Image1.Picture.Graphic); Image1.Picture := nil; Image2.Repaint; Image1.Repaint; end; 3: begin Image3.Picture.Graphic.Assign(Image2.Picture.Graphic); Image2.Picture.Graphic.Assign(Image1.Picture.Graphic); Image1.Picture := nil; Image3.Repaint; Image2.Repaint; Image1.Repaint; end; end; end;end;
 

Similar threads

回复
0
查看
698
不得闲
D
回复
0
查看
753
DelphiTeacher的专栏
D
D
回复
0
查看
727
DelphiTeacher的专栏
D
后退
顶部