Sign in Join
Wiki copytemporary

Canvas draw vertical line on form/de

Zurück zur Seite Code Beispiele.

Das Unterprogramm zeigt, wie mit Canvas auf einem Formular eine vertikale Linie gezeichnet wird.

pascal
uses
  Forms, Graphics, ...;

  ...

procedure subVertikaleLinie(Form: TForm; w32X, w32Y : LongWord; bytStrich: Byte; w16Farbe: Word);
// Alle Zahlen und Berechnungen sind in Pixel
begin
  
  with Form do
  begin
    // Legt den Punkt fest, ab dem das Zeichnen beginnt
    Canvas.MoveTo(w32X, w32Y);
    // Legt die Farbe des Strichs fest
    Canvas.Pen.Color := w16Farbe;
    // Legt die Breite des Strichs fest
    Canvas.Pen.Width := bytStrich;
    // Zeichnet einen Strich
    // Parameter:
    // LineTo(Länge ab dem Startpunkt, Abstand zur Oberen Formularkante)
    Canvas.LineTo(Width - w32X, w32Y);
  end;
  
end;

...

Wenn dieses Unterprogramm im Ereignis OnPaint des Formulars eingetragen wird, wird die Linie bei jeder Formularänderung neu gezeichnet.

Beispiel:

pascal
uses
  Forms, Graphics, ...;

  ...

procedure TForm1.FormPaint(Sender: TObject);
begin
  // Parameter für das Unterprogramm:
  // Formularname, X-Startkoordinate, Y-Startkoordinate, Strichbreite, Farbe
  subVertikaleLinie(Form1, 10, 50, 2, clred);
end;

...

From the Free Pascal wiki, page "Canvas draw vertical line on form/de", as it stood on 2020-02-10 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 4 people, 2013–2020

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
OlafCreated page
Olaf (minor)
Olaf (minor)
Olaf (minor)
Olaf (minor)
Michl
FTurtle
TrevFixed syntax highlighting; deleted category already in page template (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.