Sign in Join
Wiki copytemporary

Canvas draw vertical line on form/de: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Canvas draw vertical line on form/de

OldNewLine
1+Zurück zur Seite [[code examples/de|Code Beispiele]].
2+
3+Das Unterprogramm zeigt, wie mit Canvas auf einem [[TForm/de|Formular]] eine vertikale Linie gezeichnet wird.
4+
5+``` pascal
6+uses
7+ Forms, Graphics, ...;
8+
9+ ...
10+
11+procedure subVertikaleLinie(Form: TForm; w32X, w32Y : LongWord; bytStrich: Byte; w16Farbe: Word);
12+// Alle Zahlen und Berechnungen sind in Pixel
13+begin
14+
15+ with Form do
16+ begin
17+ // Legt den Punkt fest, ab dem das Zeichnen beginnt
18+ Canvas.MoveTo(w32X, w32Y);
19+ // Legt die Farbe des Strichs fest
20+ Canvas.Pen.Color := w16Farbe;
21+ // Legt die Breite des Strichs fest
22+ Canvas.Pen.Width := bytStrich;
23+ // Zeichnet einen Strich
24+ // Parameter:
25+ // LineTo(Länge ab dem Startpunkt, Abstand zur Oberen Formularkante)
26+ Canvas.LineTo(Width - w32X, w32Y);
27+ end;
28+
29+end;
30+
31+...
32+```
33+
34+Wenn dieses Unterprogramm im Ereignis OnPaint des Formulars eingetragen wird, wird die Linie bei jeder Formularänderung neu gezeichnet.
35+
36+Beispiel:
37+
38+``` pascal
39+uses
40+ Forms, Graphics, ...;
41+
42+ ...
43+
44+procedure TForm1.FormPaint(Sender: TObject);
45+begin
46+ // Parameter für das Unterprogramm:
47+ // Formularname, X-Startkoordinate, Y-Startkoordinate, Strichbreite, Farbe
48+ subVertikaleLinie(Form1, 10, 50, 2, clred);
49+end;
50+
51+...
52+```
53+
54+---
55+*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](/wiki-contact).*

Back to history