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
 Bug in TImageEnMView.IsVisible?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

933 Posts

Posted - Jan 06 2017 :  20:20:46  Show Profile  Reply
Please look at the attached simple test program which demonstrates a behavior which seems a bug to me:

attach/PeterPanino/201716201343_VisibleThumbsProblem.zip
50.17 KB

When the TImageEnMView is initially hidden on a second pager control tab sheet page on program start TImageEnMView.IsVisible gives an incorrect value:

1. Run the program and DO NOT CLICK ON TABSHEET 2!

2. Then click the button and see the bug: All thumbs visible?

3. Then select Tabsheet 2 and then click the button again:
Now the correct number of visible thumbs is displayed!

4. Then resize the window and click the button again:
Again the correct number of visible thumbs is displayed!

5. Now select Tabsheet 1 and then resize the window and then click the button again:
Again the correct number of visible thumbs is displayed!

How can this problem be fixed?

w2m

USA
1990 Posts

Posted - Jan 07 2017 :  10:02:51  Show Profile  Reply
I am not sure if this is a bug or if the component itself must be visible for it to work properly because it is a TCustomControl which is a WindowedControl. Anyway, this resolves the problem:
procedure TForm2.btnCountVisibleThumbsClick(Sender: TObject);
var
  i: Integer;
  VisibleThumbs: Integer;
begin
  if pgc1.ActivePageIndex = 0 then
  begin
    pgc1.ActivePageIndex := 1;
    ImageEnMView1.ViewY := 0; // show first row
    VisibleThumbs := -1;
    for i := 0 to ImageEnMView1.ImageCount - 1 do
    begin
      if not ImageEnMView1.IsVisible(i) then
      begin
        VisibleThumbs := i;
        BREAK;
      end;
      pgc1.ActivePageIndex := 0;
    end;
  end
  else
  begin
    VisibleThumbs := -1;
    for i := 0 to ImageEnMView1.ImageCount - 1 do
    begin
      if not ImageEnMView1.IsVisible(i) then
      begin
        VisibleThumbs := i;
        BREAK;
      end;
    end;
  end;
  lblVisibleThumbs.Caption := 'Visible thumbs (even partially visible): ' + IntToStr(VisibleThumbs);
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

PeterPanino

933 Posts

Posted - Jan 07 2017 :  12:25:10  Show Profile  Reply
Hello Bill,

thanks, this could be a workaround, but I found this one less intrusive because it needs to be executed only once at program start when the form is still not visible for the user:

procedure TForm2.FormShow(Sender: TObject);
begin
  // Workaround:
  pgc1.ActivePageIndex := 1;
  pgc1.ActivePageIndex := 0;
  // Works only in FormShow (or FormActivate)!
end;


But IMHO it's obviously a bug in the component because even a windowed control should work on a hidden tab sheet page in the same way as on a visible tab sheet page. (The only permitted exception is that it cannot be focused when on a hidden tab sheet page).

The reason I need this is that I need to make some calculations with ImageEnMView1.IsVisible while the control is on a hidden tab sheet page.
Go to Top of Page

xequte

38610 Posts

Posted - Jan 08 2017 :  19:54:57  Show Profile  Reply
Hi Peter

For performance reasons, these calculations are not made until necessary. You can get around it by calling ImageEnMView1.Update();


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jan 09 2017 :  10:19:03  Show Profile  Reply
Nigel is correct. There is no bug. This functions without making the tabsheet visible:
procedure TForm2.btnCountVisibleThumbsClick(Sender: TObject);
var
  i: Integer;
  VisibleThumbs: Integer;
begin
  ImageEnMView1.ViewY := 0; // show first row
  VisibleThumbs := -1;
  for i := 0 to ImageEnMView1.ImageCount - 1 do
  begin
    ImageEnMView1.UpdateImage(i);
    if not ImageEnMView1.IsVisible(i) then
    begin
      VisibleThumbs := i;
      ImageEnMView1.UpdateImage(i);
      BREAK;
    end;
  end;
  ImageEnMView1.Update;
  lblVisibleThumbs.Caption := 'Visible thumbs (even partially visible): ' + IntToStr(VisibleThumbs);
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

PeterPanino

933 Posts

Posted - Jan 09 2017 :  10:44:05  Show Profile  Reply
Thank you, Bill.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: