Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 21.02.10 10:18 
Hi, Delpher,

ich habe eben ne ganze Runde gegooglet, aber nichts brauchbares gefunden: Was ist eigentlich der Unterschied bei einem Label zwischen den Zuweisungen Labelx.caption und Labelx.canvas?

Wer kann das gut erklären?
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: So 21.02.10 10:22 
Caption ist die Beschriftung (eine String-Variable)
Canvas ist die Zeichenfläche, da kannst du dann mit den Zeichenfunktionen von Delphi in dem Label rummalen.

ausblenden Delphi-Quelltext
1:
2:
Label1.Canvas.MoveTo(0,0);
Label1.Canvas.LineTo(10,10);


Anmerkung: Du kannst auch per Canvas schreiben:

ausblenden Delphi-Quelltext
1:
Label1.Canvas.TextOut('mööp');					

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)


Zuletzt bearbeitet von Xion am So 21.02.10 10:27, insgesamt 3-mal bearbeitet
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8549
Erhaltene Danke: 478

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 21.02.10 10:23 
Caption ist ein String, Canvas eine Zeichenfläche. Oder anders ausgedrückt: Ein Apfel ist ein Apfel, und eine Birne eine Birne. :nixweiss:

_________________
We are, we were and will not be.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 21.02.10 11:15 
Ich stelle mir gerade vor, ich bin Schüler und ihr zwei meine Lehrer.
Wer bei dieser Frage/Antwort der bessere ist, darüber habe ich keinen Zweifel,
aber über eine "Antwort" habe ich sehr gelacht.

Gruß, Detlef

Was ich mit meiner Frage meinte, ist: Was geht mit canvas, was mit caption nicht geht und umgekehrt?

Dazu noch ne Idee?

_________________
ut vires desint, tamen est laudanda voluntas
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 21.02.10 11:20 
Mit Canvas kannst du auch Bilder malen, mit Caption kannst du dauerhaft einen Text auf dein Label zaubern ohne aufs Neuzeichnen zu reagieren.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 21.02.10 11:22 
Das klingt schon verständlicher (wohl nicht nur für mich)
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 21.02.10 11:36 
P.S. Wie kann man die Canvas wieder löschen / neu zeichnen?

_________________
ut vires desint, tamen est laudanda voluntas
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: So 21.02.10 11:43 
Hi :)

Wahrscheinlich ist TLabel für dich die falsche Komponente, wenn du auf ein Canvas malen willst. Besser wären TPaintbox(die dir vollen Zeichenzugriff bei jedem Repaint gibt, und wo danach wieder alles weg ist wie beim label) oder auch TImage(was du hier draufmalst, ist permanent).

Bei einem TLabel kannst du wahrscheinlich wie bei jeder anderen Win-Komponente ein Neuzeichnen durch .Repaint auslösen(gerade kein Delphi zur Hand).

lg,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 21.02.10 11:47 
Hi, Daniel,
ich vermute ganz stark, dass du recht hast (für meine Zwecke), ich bin da jetzt auch schon misstrauisch geworden. Repaint werde ich noch mal ausprobieren.

Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 21.02.10 11:51 
Ein Invalidate reicht aus. Damit sagt man, dass der aktuelle Inhalt der Komponente nicht mehr aktuell ist und daher neu gezeichnet werden muss. Aber Repaint geht natürlich auch.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 21.02.10 13:07 
Leider geht weder repaint noch invalidate, diese Properties sind unbekannt.
:(

_________________
ut vires desint, tamen est laudanda voluntas
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 21.02.10 13:09 
Das muss dann an deiner alten Delphiversion liegen, bei mit kennt ein Label beide Methoden. :nixweiss:

// EDIT:
Ich hoffe doch du suchst nach den Befehlen nicht im Objektinspektor...
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: So 21.02.10 13:11 
ausblenden Delphi-Quelltext
1:
Label1.Repaint;					


soweit ich weiß, nicht Canvas.Repaint

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 21.02.10 13:43 
Nein, Sebastian, ich setze es im Code.

aber jetzt hab ich's.
Natürlich musste die Zeile heißen:
ausblenden Delphi-Quelltext
1:
if kompo is TLabel then TLabel(kompo).Invalidate;					


Danke, Xion.
Man muss eben immer genau hingucken!
Gruß, Det

_________________
ut vires desint, tamen est laudanda voluntas