在一个combolistbox里绘出某个目录下的所有图片,就象qq列人头像那种效果.
谁有demo,或者给点提示,image好像只能显示一幅图片.不知道该用什么图控件?

解决方案 »

  1.   

    自己自理重绘事件就可以了..
    DELPHI中好像有例子吧...
      

  2.   

    我发现我这个人就是动手能力太差,是不是懒阿,
    我基本上是这么写的,但是有n多bug,我想看看你们的,.比较快,这也是csdn论坛火热的原因把,
    谢谢
    procedure TFrmPrint.UpdateImageList;
    var
      MyImage:TAllImage;
      MyLabel:TLabel;
      SPos,i, j:integer;
      NumOfDICOMFrame:integer;
    begin
        for i := scbImageList.ComponentCount - 1 downto 0 do
            scbImageList.Components[i].free;
        //图象列表
        //FindFiles(sPath:string;var FileBuf:TStringList;var fileCount:integer);    //返回目录下所有文件名 ,数目
          FindFiles( CurrentExam.ImagePath,FileBuf,ImageNum);    if ImageNum=0 then
        begin
          exit;//没有图象的情况
          pictureNum:=1;
        end;
       ImageNum:=fileCount;//图象数目
        j:=1;
        for i := 1 to (ImageNum) do
        begin
            //为图像预留空间
          MyImage := TAllImage.Create(scbImageList);
          MyImage.Parent := scbImageList;
          imgPath:=FileBuf[i];
          if imgPath[length(imgPath)]<>'\' then
            imgPath:=imgPath+'\';                     //得到图像路径
          MyImage.Hint := FileBuf[i];    //图像的提示性文字是该图像的文件名      MyImage.Filename:=MyImage.Hint;        SPos := scbImageList.VertScrollBar.ScrollPos;
            MyImage.TOP := (j - 1) * 75+25*j -sPos;;
            //MyImage.TOP := (j - 1) * 100 + 5*j -sPos;;
            MyImage.Left := 10;
            MyImage.Height := 75;
            MyImage.Width := 100;
            MyImage.Stretch := true;        MyImage.Filename:=MyImage.Hint;
        //    MyImage.GetFirstFrame;        MyImage.ShowHint := true;
            MyImage.OnClick  := OnImgClick;                  {---加图象到报表中---}
            j:= j + 1;    end;        MyImage.Free;
      

  3.   

    在FORM上放一个ImageList,将高和宽设为32
    再放一个TComboBox,将Style设为csOwnerDrawVariable再加上如下代码就可以了
    procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    var
      tmp: TBitmap;
    begin
      Tmp := TBitmap.Create;
      ImageList1.GetBitmap(Index, Tmp);
      TComBobox(Control).Canvas.Draw(Rect.Left, Rect.Top, Tmp);
      Tmp.free;
    end;procedure TForm1.ComboBox1MeasureItem(Control: TWinControl; Index: Integer;
      var Height: Integer);
    begin
      Height := 32;
    end;
      

  4.   

    对了,记得在ImaegList里面加上32*32的BMP图片.
      

  5.   

    收到,我自己调通了出问题的代码,(不过还不能显示jpeg,可以显示bmp了)
    剑神一笑 ^_^:
    呢的代码我以后试,(任务紧最近),多谢了.
      

  6.   

    用控件吧mxoutlookbarpro
    delphi盒子有下
      

  7.   

    1, ComboBox.style := csOwnerDrawFixed;
    2。ComboBox1.ItemHeight = 32;
    3。ComboBox1.DropDownCount = 2;
    在Form上放一个TImageList,把它的Height属性设为32,然后随便加几个OICQ的bmp文件;procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    begin
      ComboBox1.Canvas.Brush.Color := clWindow;
      if odSelected in State then ComboBox1.Canvas.Brush.Color := clHighLight;
      ComboBox1.Canvas.FillRect(Rect);
      ImageList1.Draw(ComboBox1.Canvas, Rect.Left, Rect.Top, Index);
    end;
    procedure TForm1.ComboBox1DropDown(Sender: TObject);
    begin
      if ComboBox1.Items.Count <> ImageList1.Count then
        ComboBox1.Items.Text := StringOfChar(#13, ImageList1.Count);
    end;