views:

247

answers:

3

What would be the easiest way to make a thumbnail view, where you have a panel with a vertical scroll bar, and a matrix of images describing their associated image? I'd also like it such that if the parent frame resized horizontally, the matrix would shrink to as many columns as necessary to display the thumbnails without a horizontal scroll bar. I'd like to be able to drag and rearrange these thumbnails as well. The toolkit that this is written in doesn't really matter so much. If you know of a good way to do it with MFC, that's cool, Delphi/C++ builder is totally cool too. Just some kind of native app framework.

Wow this is sounding a lot like I'm begging for homework help. I swear this is for some software to drive a laser projector.

+3  A: 

Take a look at TMS AdvSmoothImageListBox:

alt text

AFAIK, Registered Delphi customers can download TMS Smooth Components for free from Embarcadero website. If you are not a registered Delphi user, then you can buy the collection from TMS website.

vcldeveloper
I suppose I'm more interested in how one would construct such a thing rather than how to find the component itself.
Evan
I recently came across code (Delphi) doing this. Look for "Threaded thumbnails demo" on http://rmklever.com/
Sertac Akyuz
Awesome! That's more or less what I'm looking for... now I just need to figure out how to do the drag/drop...
Evan
Here is the download link to the TMS Smooth Controls for Delphi and C++Builder 2010 http://cc.embarcadero.com/Item/27470
stukelly
A: 

Here is excerpted code I use to display of a collection of a variable numImages number of webcams.

const MaxImages = 24;

type 
 TForm1 = class(TForm)
  ...
  images: array[1..MaxImages] of TWebcamImage;
  numImages: integer;
  ....
 end;

TWebCamImage is a descendant of TImage with some additional attributes like the origin url of the webcam, the filename for the saved picture, and a handler for the double click to open the picture in a secondary panel.

Here is the code used to arrange the images in a panel.

procedure TForm1.ArrangeImages;
 var i, numh, numv : integer;
 const margin=2;
 begin
  case numImages of
    1: begin numh:=1; numv:=1; end;
    2: begin numh:=2; numv:=1; end;
    3: begin numh:=3; numv:=1; end;
    4: begin numh:=2; numv:=2; end;
    5,6: begin numh:=3; numv:=2; end;
    7,8: begin numh:=4; numv:=2; end;
    9: begin numh:=3; numv:=3; end;
    10: begin numh:=5; numv:=2; end;
    11,12: begin numh:=4; numv:=3; end;
    13,14,15: begin numh:=5; numv:=3; end;
    16: begin numh:=4; numv:=4; end;
    17,18,19,20: begin numh:=5; numv:=4; end;
    else begin numh:=6; numv:=4; end;
  end;
  for i:=1 to numImages do 
   begin
    images[i].Width := (panel2.Width div numh) - margin * 2;
    images[i].Height := (panel2.Height div numv) - margin * 2;
    images[i].Top := (((i-1) div numh) * (panel2.Height div numv)) + margin;
    images[i].Left := (((i-1) mod numh) * (panel2.Width div numh)) + margin;
   end;
 end;

this method is called in the initialization of the form, hooked in the oncreate event and the onresize event.

procedure TForm1.FormCreate(Sender: TObject);
 begin
  ...
  numImages:=0;
  for i:=1 to maxImages do 
    begin
     imageURL:=ini.ReadString('images','imageURL'+intToStr(i),imageURLDefault);
     if imageURL<>'' then 
      begin
       inc(numimages);
       images[numImages]:=TWebCamImage.create(self,panel2,imageURL);
      end;
     ....
    end;
   ....
  ArrangeImages;
   ....
 end;

procedure TForm1.FormResize(Sender: TObject);
 begin
  ArrangeImages;
 end;
PA
A: 

I'm not quite sure I understand you right, but I would have started with a frame holding the image and it's description. I would then use a TFlowPanel to hold instantiations of the frame. There shouldn't be to much work to implement drag and drop, I think. Never tried, though.

If there is a lot images, you should go for a ownerdraw and doublebuffered solution, I think.

In the end, you should just drop in the laser projection component and hook it up to the laser projector steering unit...

Vegar