我正在做一个看图软件,怎么把用户选择的多个图像文件装入IMAGE控控件。
有两种装载方式,主要是怎样获得用户选择文件的名字和路径。随机和循环。最好有代码。谢谢大侠,本人迷惑了一天。

解决方案 »

  1.   

    function tform2.findimage(i:integer;t:integer):integer;                    //查找图象文件函数
    var temp:boolean;
    begin
     temp:=false;
     i:=i+t;
     image1.AutoSize:=true;
     if (i>-1) and (i<form1.shelllistview1.Items.Count) then
      begin
       form1.ShellListView1.Selected:=form1.ShellListView1.Items.Item[i];
       if form1.shelllistview1.SelCount>0 then
        begin
         try
          image1.Picture.LoadFromFile(form1.shelllistview1.SelectedFolder.pathname);
         except
           begin
           temp:=true;
           end;
         end;
        end; //if form1.shelllistview1.SelCount>0 then
      end       // if (i>0) or (i<form1.shelllistview1.Items.Count) then
      else
       begin
        i:=-1;
       end;
      if temp then i:=findimage(i,t);        //找不到时图象文件时继续递归
      findimage:=i;         //返回当前I;
    end;
    这是利用递归在shelllistview 里查找图象文件的位置,输入当前文件位置和增量,找到时返回下一个图象文件位置,当到达SHELLISTVIEW底部或顶部仍找不到时,返回-1。其它的功能可以通过调用这函数实现。给分!
      

  2.   

    首先是不明白“选中的多个图像文件装载入IMAGE控件”是什么意思。不过如果你只是做一个图片流览程序的话可以这么干:
    第一、你要有一个列表供用户选择图象文件。
    第二、因此你可以知道用户选择了哪些文件。
    第三、如果必要的话,使用ExpandFileName来取得文件的完整路径。
    第四、做一个循环或用Timer,在循环中取一个随机数。用这个数字作为索引从列表中取得文件名。
    第五、显示文件。
      

  3.   

    为什么非要把多个图像装入一个image中呢?有什么必要?多用几个image难道不行吗?