There was a bug in my code. So here is the (hopefully) bugfree code:
function TForm2.GetImageCountPerRow(const AImageEnMView: TImageEnMView): Integer;
var
i: Integer;
begin
Result := -1;
for i := 0 to AImageEnMView.ImageCount - 1 do
begin
if AImageEnMView.ImageRow[i] = 1 then
begin
Result := i;
BREAK;
end;
end;
end;
function TForm2.GetIndexOfFirstVisibleImage(const AImageEnMView: TImageEnMView): Integer;
var
c: Integer;
begin
c := GetImageCountPerRow(AImageEnMView);
if c = -1 then
begin
// not enough images to fill a row + 1
Result := 0;
end
else
Result := (AImageEnMView.ViewY div AImageEnMView.ThumbHeight) * c;
end;
CodeSite.Send('Index of first visible Image', GetIndexOfFirstVisibleImage(ImageEnMView1));
Can please anybody test this.