Autor Beitrag
Fricolas
Hält's aus hier
Beiträge: 8



BeitragVerfasst: Do 03.06.10 15:44 
Hey

Sorry ich bin noch ein blutiger Anfaenger in Delphi...
Ich moechte einen mehrzeiligen Text einfuegen in mein prog.
Ich habe schon gesehen dass man das mit "label1.Caption := 'Erste Zeile' + #13 + 'Zweite Zeile';"
machen kann. Aber wo muss man das eingeben?
Ich krieg das irgendwie nicht hin...

Waer schoen wenn mir jemand helfen koennte :)
Fricolas
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 03.06.10 16:06 
erstze mal #13 durch sLineBreak

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Stundenplan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128
Erhaltene Danke: 32

Win 7
Delphi 7 Pers., C# (VS 2010 Express)
BeitragVerfasst: Do 03.06.10 16:18 
Na wenn du den Text gleich vom Start des Programmes angezeigt haben willst, im FormCreate.
Wenn der Text aber beim Klick auf nen Button erscheinen soll, eben in der entsprechenden ButtonXClick-Methode.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 03.06.10 16:24 
Hi :)

user profile iconKroko: Die Frage ist ja, wo. ;)
Du müsstest den Text an der Stelle einfügen, wo du möchtest, dass er für den Nutzer auf dem Bildschirm erscheint. Ein Paar Möglichkeiten:
ausblenden Quelltext
1:
2:
3:
Form1.OnCreate(Sender: TObject); Wahrscheinlich suchst du das hier, der Text wird beim Erzeugen des Formulars, also zu Meißt bei Programmbeginn eingefügt.
Form1.OnShow(Sender: TObject); Für manches ist OnCreate zu früh, in OnShow wird das Formular gerade dem Nutzer gezeigt. Nützlich, wenn du es zwischendrin mit Form1.Hide/Show ausblendest: Das Ereignis wird jedes mal aufgerufen.
{..jede Menge anderer Methoden gibt es da, du kannst einfach mal im Objekt inspektor kramen.}

Die Methoden oben erreichst du, indem du im Object Inspector(links unten, auf dem Schirm wo du auch die Komponenten auf's Formular ziehst) unter Ereignisse/Events einen Doppelklick auf das leere Feld neben dem Namen(z.B. OnCreate) machst.

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)


Zuletzt bearbeitet von Hidden am Do 03.06.10 21:16, insgesamt 1-mal bearbeitet
Fricolas Threadstarter
Hält's aus hier
Beiträge: 8



BeitragVerfasst: Do 03.06.10 20:31 
Danke, hat geklappt :)
Seehr schoen :P
Georg08
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155
Erhaltene Danke: 6

Win XP
Delphi 7.0 Personal
BeitragVerfasst: Do 03.06.10 22:45 
Du kannst es aber auch anders machen:
Klick auf deim Form und drücke dann Alt+F12
Dann Suchst du dein Label und da Wo shet Caption='Dein TEst' setzt du deinen Text ein. Wichtig ist, dass du kein Komma setzt. Die Datei in der das steht wird dann später als Projektname.dfm gespeichter. Sie sagt Delphi wie dein Programm aussieht. Du kannst wie beim "normalen programmieren" schriftlich Objekte deinem Projekt hinzufügen...

Hier ein Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
object Form1: TForm1
  Left = 192
  Top = 114
  Width = 870
  Height = 640
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 200
    Top = 288
    Width = 116
    Height = 13
    Caption = 'Hallo'#10#13'Wie gehts?'
  end
end
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 03.06.10 23:14 
Hi :)

Ich habe es gerade mal ausprobiert, und Delphi 2010 setzt das Komma ohne Escaping/etc. in die .dfm: Warum darf man das dann manuell nicht? Oder gibt das Probleme mit Kommata und #13?

Sonst hätte ich jetzt eigentlich mal geguckt, wie ein Komma denn escaped werden kann, um dieses manko auszubügeln.

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)
Georg08
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155
Erhaltene Danke: 6

Win XP
Delphi 7.0 Personal
BeitragVerfasst: Do 03.06.10 23:36 
Ich hab Delphi7 bei mir darf man keine Kommas nach den zeilen setzen also keine ";" in delphi 2010 kenn ich mich nicht aus...

Die möglcihkeit die ich gezeigt hat hat eben den Vorteil, dass man keine extra Programmierzeilen schreiben muss, sondern alles sozusagen Direkt editiert...

Mein Beispiel habe ich ausprobirt und es funktioniert...

Falls du mich falsch verstanden hast und denkst, dann man a als string kein "," setzten darf tut es mir leid, dass ich mich nicht genau ausgedrückt hab :D also string darf man es schon setzen, nur ans ende kommt kein Semikolon wie beim "normalen" Quelltext also z.B.
Label1.Caption:= 'Hallo';

Aber bei Object kein ";"
Caption: 'Kommas, darf, man,'#10#13'setzen!';
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 04.06.10 00:35 
Hi :)

Okay, das ist 'was Anderes. Alles klar :)
Ein Komma mit Punkt drauf, nennt man übrigens auch Semikolon :zwinker:

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)