[Solved] Questions about Thumbviewer lazarus / 39-Graphics ---------------------------------------------------------------------- madepabloh · 2014-10-10 22:16 I am using Thumbviewer component to see thumbnail of images in a directory. However, i explored the code of this component, but i don´t see how to figure out some issues. So, i have some questions may be you could help me to solve. On the first hand, I would like to capture the image name of the selected thumbnail. This name is showed in the caption of each image, but i dont know how to capture it as string to be used in other procedures. Thanks! ---------------------------------------------------------------------- wp · 2014-10-10 22:29 I suppose you refer to theo's ThumbViewer (https://github.com/theo222/lazarus-thumbviewer). The Thumbviewer has put all info on loaded images into the "ImageLoaderManager" which is accessible by the equally-named property. Call its method "ItemFromImage(AImageIndex)" to get to an image at a specific index. This image is type TThreadedImage which exposes the filename in property "URL". Just navigate through the thumbcontrol and threadedimageloader units and look at the properties and public methods and you'll easily find what you need. The structure of this component is relatively easily understood. ---------------------------------------------------------------------- madepabloh · 2014-10-10 22:34 Thanks @wp Yes i am talking about this component. Thanks for point me toward this imageloadermanager. I will explore it with more detail.  Cheers, ---------------------------------------------------------------------- madepabloh · 2014-10-11 09:24 I solved the issue to extract the name of the thumbnail based on what @wp explained. I made this code, to search for the thumbnail code, and to search for the image name into an stringlist, to select that line. May beit could be interesting for others: Code: [Select]procedure TMain.ThumbControl1SelectItem(Sender: TObject; Item: TThreadedImage); var  pic2: string;  i: integer  item1: integer; begin   thumbcontrol1.LoadSelectedBitmap(Image1.Picture.Bitmap);   if ToolButton22.Down = true then  // this button show/hide the stringgrid. If hided, the next setfocus returns and error     begin       pic2 := ExtractFileNameOnly(thumbcontrol1.ImageLoaderManager.ActiveItem.URL);       for i:= 0 to PicturesGrid.RowCount-1 do         begin           if PicturesGrid.Cells[1,i] = pic2 + '.jpg' then  // this is because it is case sensitive.             begin               item1 := i;               PicturesGrid.Options := PicturesGrid.Options + [goRowSelect];               break; // I only expect to have one file with the same name, so, once the image is located, it is not necessary to continue the loop             end           else             begin               item1 := 0;               PicturesGrid.Options := PicturesGrid.Options - [goRowSelect];             end;         end;       PicturesGrid.Row:= item1;       PicturesGrid.SetFocus;     end; end; ---------------------------------------------------------------------- madepabloh · 2014-10-11 09:38 I also prepared a code to search and select an image of the thumbcontrol based on a file name located into a selected row of a stringgrid. Code: [Select]procedure TMain.PicturesGridSelection(Sender: TObject; aCol, aRow: Integer); var   pic1: string; begin   pic1 := ExtractFileNameOnly(PicturesGrid.Cells[1,aRow]);   for i:= 0 to Thumbcontrol1.ImageLoaderManager.CountItems-1 do     begin       Thumbcontrol1.ImageLoaderManager.ActiveIndex := i;       Thumbcontrol1.ImageLoaderManager.ItemFromIndex(i);       if AnsiContainsStr(Thumbcontrol1.ImageLoaderManager.ActiveItem.URL, pic1) = true then         begin           Thumbcontrol1.ImageLoaderManager.ActiveIndex := i;           thumbcontrol1.LoadSelectedBitmap(Image1.Picture.Bitmap);           break;         end       else         begin            Thumbcontrol1.ImageLoaderManager.ActiveIndex := 0;         end;     end; end;  I hope those things could help others to work with that component. Thanks Werner for your explanations because they pointed me to the correct path. Cheers,