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
 TImageEnFolderMView.IncludeSubFolders OnProgress n

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
klausdoege Posted - Sep 15 2019 : 08:14:13
Hello,
the description from TImageEnFolderMView.IncludeSubFolders
say, i can use OnProgress for break the action.
But there is no activity in OnProgress, why ??

TImageEnFolderMView.IncludeSubFolders
Notes:
It will also be slow if there are many sub-folders so use with caution.
- When IncludeSubFolders is enabled, you can use OnProgress to monitor folder filling, and set IEFolderMView1.MIO.Aborting := True; to cancel



Klaus
www.klausdoege.de
9   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Sep 18 2019 : 17:14:31
Sorry Klaus,

You are right. I misread your example above as:

  if *per* > 10 then
    IEFolderMView.MIO.Aborting := True;


And so I was looking at the wrong bit of code. I have implemented your fix (and reverted my change from yesterday).

Nigel
Xequte Software
www.imageen.com
klausdoege Posted - Sep 18 2019 : 05:29:30
Hi Nigel,
I solved the problem.
The mistake is in following procedure unit IexFolderMView.pas:
By inserting "if not IO.Aborting then" see arrow the procedure works perfectly.
Old:

function TImageEnFolderMView.GetFolders(ssDest: TStrings; CallOnProgress: Boolean = False): integer;

  procedure _AddSubFolders(Folder: string);
  var
    DirName : WideString;
    dir: TIEDirContent;
    sNewFolder: String;
  begin
    Folder := IEAddBackSlash( Folder );
    dir := TIEDirContent.Create( Folder + '*.*' );
    try
      while dir.GetItem( DirName, False, True, fShowHiddenFiles ) do
      begin
        // Show progress so user can abort using MIO.Aborting := True;
        if assigned( OnIOProgress ) then
            OnIOProgress( Self, 0 );

        sNewFolder := IEAddBackSlash( Folder + DirName );
        if ssDest.IndexOf( sNewFolder ) = -1 then
        begin
          ssDest.Add( sNewFolder );
          _AddSubFolders( sNewFolder );
          if CallOnProgress and assigned( OnProgress ) then
            TIEProgressEvent(OnProgress)( Self, 0 );
        end;
      end;
    finally
      dir.Free;
    end;
  end;

---------------------
New:
// Return a list of all folders in the "Folder" property and optionally their sub-folders if "IncludeSubFolders" is enabled
function TImageEnFolderMView.GetFolders(ssDest: TStrings; CallOnProgress: Boolean = False): integer;

  procedure _AddSubFolders(Folder: string);
  var
    DirName : WideString;
    dir: TIEDirContent;
    sNewFolder: String;
  begin
    Folder := IEAddBackSlash( Folder );
    dir := TIEDirContent.Create( Folder + '*.*' );
    try
      while dir.GetItem( DirName, False, True, fShowHiddenFiles ) do
      begin
        // Show progress so user can abort using MIO.Aborting := True;
        if assigned( OnIOProgress ) then
            OnIOProgress( Self, 0 );

        sNewFolder := IEAddBackSlash( Folder + DirName );
 -->>   if not MIO.Aborting then
        if ssDest.IndexOf( sNewFolder ) = -1 then
        begin
          ssDest.Add( sNewFolder );
          _AddSubFolders( sNewFolder );
          if CallOnProgress and assigned( OnProgress ) then
            TIEProgressEvent(OnProgress)( Self, 0 );
        end;
      end;
    finally
      dir.Free;
    end;
  end;


Klaus
www.klausdoege.de
xequte Posted - Sep 18 2019 : 03:45:59
Hi Klaus

There are three stages when refreshing the content:

1. Generating the list of folders

Progress will be 0. Will abort if MIO.Aborting is set

2. Getting file list from folders

Progress will be 0 - 100. Will abort if MIO.Aborting is set

3. Generating thumbnails and displaying content

Happens live. There is no progress. Cannot be cancelled


In your code you're aborting at step 2. So it may not return immediately as step 3 will continue with the partial file list.

Can you confirm whether you are seeing all of the images in the sub-folders of the specified folder, or only 10% of them.

You might want to add the ImageEn source folder to your Delphi path, and put a breakpoint on the break line in RefreshFileListEx:

if MIO.Aborting then
Break;

To confirm it is working as expected.

In examining the code, I do see a possible race condition where MIO.Aborting gets reset. It would seem an unlikely occurrence, but you can email me for a fix to try it out.

Nigel
Xequte Software
www.imageen.com
klausdoege Posted - Sep 18 2019 : 02:44:11
Hi Nigel,
this is my procedure in the Demo:

procedure TForm1.IEFolderMViewProgress(Sender: TObject; per: Integer);
begin
  Caption := IntToStr( z );
  inc(z);
  if z > 10 then
    IEFolderMView.MIO.Aborting := True;
  application.ProcessMessages;
end;


Now I can use the buttons.
But nothing happens. The function of the button is not executed.
The routine continues and does not break off. Although IEFolderMView.MIO.Aborting = True.
The caption running and running, not break.
Why, what am I doing wrong?
I test with c: \.

Klaus
www.klausdoege.de
xequte Posted - Sep 17 2019 : 05:14:10
Hi Klaus

In the OnProress event add an Application.ProcessMessages; call and you should be able to push buttons.

Nigel
Xequte Software
www.imageen.com
klausdoege Posted - Sep 17 2019 : 03:12:33
Hi Nigel,
Unfortunately, when the process is running I can not press a button or click with the mouse. How can I set fusercancelled?
I test this with the Demo and a very long directory, e.g. c:\

Klaus
www.klausdoege.de
xequte Posted - Sep 16 2019 : 17:07:01
Hi

I cannot reproduce that. Please try the demo:

\Demos\Multi\FolderMView\FolderMView.dpr


Add this to the TImageEnFolderMView.OnProgress event, and put a breakpoint on it:

procedure TForm1.IEFolderMViewProgress(Sender: TObject; per: Integer);
begin
  Caption := IntToStr( per );
  if fUserCancelled then
    IEFolderMView.MIO.Aborting := True;
end;

Run the demo and enable the sub-folders option under the "Settings" link

Nigel
Xequte Software
www.imageen.com
klausdoege Posted - Sep 16 2019 : 05:20:05
Hi Nigel,
yes is it.

Klaus
www.klausdoege.de
xequte Posted - Sep 15 2019 : 17:14:18
Hi Klaus

Is this with 8.7.0?



Nigel
Xequte Software
www.imageen.com