Einzelnen Beitrag anzeigen

Volker Z.

Registriert seit: 3. Dez 2012
Ort: Augsburg, Bayern, Süddeutschland
419 Beiträge
 
Delphi XE4 Ultimate
 
#8

AW: Umgang mit TScrollbox/TImage/TPaintbox

  Alt 9. Aug 2013, 01:51
Hallo,

ich weiß jetzt nicht, ob ich Dein Problem so richtig verstanden habe; aber vielleicht bringt Dich nachfolgender Code ein Stückchen weiter.
Delphi-Quellcode:
uses System.Math;

procedure TForm1.FormCreate(Sender: TObject);
begin
  PaintBox1.Font.Size := 14;
  Randomize
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  px , py : Integer;
begin
  px := ScrollBox1.HorzScrollBar.Position;
  py := ScrollBox1.VertScrollBar.Position;

  ScrollBox1.HorzScrollBar.Position := 0;
  ScrollBox1.VertScrollBar.Position := 0;
  PaintBox1.SetBounds (0, 0, RandomRange (4000, 5000), RandomRange (4000, 5000));

  ScrollBox1.HorzScrollBar.Position := px;
  ScrollBox1.VertScrollBar.Position := py
end;

procedure TForm1.PaintBox1Paint(Sender: TObject);
var
  x, y : Integer;
begin
   y := 0;
   while y < Paintbox1.Height do
     begin
       x := 0;
       while x < Paintbox1.Width do
         begin
           PaintBox1.Canvas.TextOut (x, y, Format ('(%d, %d)', [x, y]));
           Inc (x, 200)
         end;

       Inc (y, 100)
     end
end;
Gruß
Volker Zeller
  Mit Zitat antworten Zitat