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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnFolderMView.IncludeSubFolders OnProgress n
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

klausdoege

Germany
389 Posts

Posted - Sep 15 2019 :  08:14:13  Show Profile  Reply
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

xequte

38613 Posts

Posted - Sep 15 2019 :  17:14:18  Show Profile  Reply
Hi Klaus

Is this with 8.7.0?



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

klausdoege

Germany
389 Posts

Posted - Sep 16 2019 :  05:20:05  Show Profile  Reply
Hi Nigel,
yes is it.

Klaus
www.klausdoege.de
Go to Top of Page

xequte

38613 Posts

Posted - Sep 16 2019 :  17:07:01  Show Profile  Reply
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
Go to Top of Page

klausdoege

Germany
389 Posts

Posted - Sep 17 2019 :  03:12:33  Show Profile  Reply
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
Go to Top of Page

xequte

38613 Posts

Posted - Sep 17 2019 :  05:14:10  Show Profile  Reply
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
Go to Top of Page

klausdoege

Germany
389 Posts

Posted - Sep 18 2019 :  02:44:11  Show Profile  Reply
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
Go to Top of Page

xequte

38613 Posts

Posted - Sep 18 2019 :  03:45:59  Show Profile  Reply
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
Go to Top of Page

klausdoege

Germany
389 Posts

Posted - Sep 18 2019 :  05:29:30  Show Profile  Reply
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
Go to Top of Page

xequte

38613 Posts

Posted - Sep 18 2019 :  17:14:31  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: