ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Stop Loading Thumbnails

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
plumothy Posted - Nov 16 2012 : 06:54:57
I am just starting out with ImageEn.

I have a TImageEnMView loading thumbnails with the FillFromDirectory method.

How can I stop loading thumbnails before it finishes? (A user might want to do this if they accidentally select a folder with thousands of images and it is taking a long time to load them all.)

Steve Bailey,
ImageEn 4.1.4
Delphi XE3 Professional
Windows 7 Professional
4   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Nov 18 2012 : 02:36:24
Because FillFromDirectory just create a list of images to load that will be loaded using multiple threads, you can cancel loading just calling TImageEnMView.Clear. Of course it will remove also already loaded images.
plumothy Posted - Nov 16 2012 : 13:43:39
OK - that's a shame.

Perhaps it's something the developers could consider for a future release.

Steve Bailey,
ImageEn 4.1.4
Delphi XE3 Professional
Windows 7 Professional
w2m Posted - Nov 16 2012 : 11:46:11
If you look at the FillFromDirectory code you will see that there are no provisions to abort the 'Fill' in the current version. The current version only breaks when you set a limit on the number of files to be loaded.
if (Limit>-1) and (count=limit) then
  break;

So if you get a count on the number of images in the folder you can call FillFromDirectory with limits or allow the user to load all the files anyway.

function GetFileCount(AFolder, AWildCard: string): Integer;
//Return the AFolder file count
var
  iIntegerFound: Integer;
  iSearchRec: TSearchRec;
begin
  Screen.Cursor := crHourGlass;
  try
    Result := 0;
    if (AFolder <> '') and (AFolder[Length(AFolder)] <> '\') then
      AFolder := AFolder + '\';
    iIntegerFound := FindFirst(AFolder + AWildCard, faAnyFile, iSearchRec);
    while (iIntegerFound = 0) do
    begin
      if not (iSearchRec.Attr and faDirectory = faDirectory) then
        Inc(Result);
      iIntegerFound := FindNext(iSearchRec);
    end;
    FindClose(iSearchRec);
  finally
    Screen.Cursor := crDefault;
  end;
end;

procedure TForm1.FillFromDirectory1Click(Sender: TObject);
var
  iResult: integer;
  iFileCount: integer;
  iMax: integer;
  iMessage: string;
begin
  // Fill ImageEnMView with images from a folder
  if DirectoryExists(AFolder) then
  begin
    iFileCount := GetFileCount(AFolder, '*');
    iMax := StrToIntDef(Max1.Text, 5);
    if iFileCount > iMax then
    begin
      iMessage := 'The Folder Has ' + IntToStr(iFileCount) + ' Files.' + #10#13 + #10#13 +
        'Select "Yes" to load all files, select "No" to load ' + IntToStr(iMax) +
          ' files.  Select "Cancel" to abort.';
      iResult := MessageBox(0, PWideChar(iMessage),
        'Add All Images', MB_ICONQUESTION or MB_YESNOCANCEL);
      if iResult = idYes then
        iMax := -1
      else if iResult = idNo then
        iMax := StrToIntDef(Max1.Text, 5)
      else
        exit;
    end;
    ImageEnMView1.Clear;
    ImageEnView1.Clear;
    iResult := MessageBox(0, 'Add supported image types only?' + #10#13 + #10#13 +
      'If Yes then only known and supported file formats will be loaded, if No then all files will be loaded.  If Cancel then abort.',
      'Add Supported Images Only', MB_ICONQUESTION or MB_YESNOCANCEL);
    if iResult = idYes then
    begin
      Caption := 'ImageEnMView Thumbnail Spacing From A To Z With DragAndDrop- All Supported Images In '
        + AFolder;
      ImageEnMView1.FillFromDirectory(AFolder, iMax, False, '', True, '', False);
    end
    else if iResult = idNo then
    begin
      Caption := 'ImageEnMView Thumbnail Spacing From A To Z With DragAndDrop- All Supported Files In '
        + AFolder;
      ImageEnMView1.FillFromDirectory(AFolder, iMax, True);
    end
    else if iResult = idCancel then
    begin
      Caption := 'ImageEnMView Thumbnail Spacing From A To Z With DragAndDrop';
      exit;
    end;
    Screen.Cursor := crHourGlass;
    try
      ImageEnMView1.GridWidth := StrToIntDef(Columns1.Text, 3);
      ImageEnMView1.Width := ((ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder) *
        ImageEnMView1.GridWidth) + ImageEnMView1.HorizBorder * 2;
      ImageEnMView1.Update;
      ImageEnMView1.SelectedImage := 0;
      AFilename := ImageEnMView1.ImageFileName[0];
      ImageEnView1.IO.LoadFromFile(AFilename);
      if Fit1.Checked then
        ImageEnView1.Fit;
      ImageEnMView1.GridWidth := StrToIntDef(Columns1.Text, 3);
      ImageEnMView1.Width := ((ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder) *
        ImageEnMView1.GridWidth) + ImageEnMView1.HorizBorder * 5;
      ImageEnMView1.Update;
      ImageEnView1.Bitmap.Modified := False;
      StatusBar1.Panels[0].Text := ExtractFileDir(AFilename);
      StatusBar1.Panels[1].Text := ExtractFileName(AFilename);
    finally
      Screen.Cursor := crDefault;
    end;
  end
  else
    MessageBox(0, PChar('The folder ' + AFolder + ' does not exist.'), 'Warning', MB_ICONWARNING or
      MB_OK);
end;


William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
cpstevenc Posted - Nov 16 2012 : 10:51:33
I have something similar going on myself. A user has a dropbox folder they use for images and some have hundreds of images. So takes forever to populate thumbnails for him sometimes.