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
 Bug in TImageEnMView.IsVisible?

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
PeterPanino Posted - Jan 06 2017 : 20:20:46
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?
5   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Jan 09 2017 : 10:44:05
Thank you, Bill.
w2m Posted - Jan 09 2017 : 10:19:03
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
xequte Posted - Jan 08 2017 : 19:54:57
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
PeterPanino Posted - Jan 07 2017 : 12:25:10
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.
w2m Posted - Jan 07 2017 : 10:02:51
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