Pour 200 lignes, y'a peu de chance ;)
Mais tu peux poser le PaintBox sur une ScrollBox (Align = alTop) et assez simplement avoir une hauteur de PaintBox au multiple de la taille de l'image (scrollable) mais au minimum de la hauteur de fenêtre.
Juste une ligne de plus dans CreateBitmap :
Et en bonus, la ligne concernée en Hint au survol :Code:
1
2
3
4
5
6
7
8
9
10
11 uses System.Math; procedure TForm1.CreateBitmap; begin Bmp := TBitmap.Create(1, StringGrid1.RowCount); for var Y := 0 to Bmp.Height -1 do Bmp.Canvas.Pixels[0,Y] := IfThen(SameText(StringGrid1.Cells[0,Y], StringGrid1.Cells[1,Y]), clLime, clRed); PaintBox1.Height := Max(ScrollBox1.ClientHeight, Bmp.Height *2); end;
Code:
1
2
3
4
5 procedure TForm1.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin PaintBox1.Hint := Trunc(Y *Bmp.Height /PaintBox1.Height).ToString; Application.ActivateHint(Mouse.CursorPos); end;