Sign in Join
Wiki copytemporary

Create image from Form/de: what changed

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

Title: Create image from Form/de

OldNewLine
1+Für die Beispiele werden folgende [[Unit/de|Units]] benötigt:
2+
3+``` pascal
4+
5+ ...
6+
7+uses
8+ Graphics, Controls, Clipbrd, Forms, ...
9+
10+ ...
11+
12+```
13+
14+Die Funktion erstellt vom übergebenen [[TForm/de|Formular]] einen Bildschirmausdruck (Screenshot).
15+
16+``` pascal
17+
18+ ...
19+
20+uses
21+ Forms, Graphics, Controls, ...
22+
23+ ...
24+
25+Procedure subErstelleFormularImage(Formular: TForm; out Bitmap: TBitmap);
26+var
27+ Breite: Integer;
28+ Hoehe: Integer;
29+ Rechteck: TRect;
30+
31+begin
32+
33+ Breite := Formular.Width;
34+ Hoehe := Formular.Height;
35+ Rechteck := Rect(0, 0, Breite, Hoehe);
36+
37+ Bitmap.Width := Breite;
38+ Bitmap.Height := Hoehe;
39+ Bitmap.Canvas.CopyRect(Rechteck, Formular.Canvas, Rechteck);
40+
41+end;
42+```
43+
44+Demonstration, wie z. B. die obige Funktion verwendet werden kann.
45+
46+``` pascal
47+
48+ ...
49+
50+uses
51+ Clipbrd, ...;
52+
53+ ...
54+
55+procedure Test;
56+var
57+ Bitmap: TBitMap;
58+
59+begin
60+
61+ ...
62+
63+ // Fordert den Speicher für die Bitmap an
64+ Bitmap := TBitmap.Create;
65+
66+ // Ruft die Funktion zum erstellen des Bildschirmausdrucks / Screenshots auf
67+ subErstelleFormularImage(Form1, Bitmap);
68+
69+ // Beispiel 1: Weist den Screenschot einem Image zu
70+ image1.Picture.Assign(Bitmap);
71+
72+ // Beispiel 2: Weist den Screenschot der Zwischenablage zu
73+ Clipboard.Assign(Bitmap);
74+
75+ // Gibt den Speicher der Bitmap frei
76+ FreeAndNil(Bitmap)
77+
78+ ...
79+
80+end;
81+
82+ ...
83+```
84+
85+---
86+*From the Free Pascal wiki, page "Create image from Form/de", as it stood on 2020-02-12 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