Autor Beitrag
firediver
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Sa 03.12.05 17:49 
Hallo,

Ich habe noch ein Problem und bin leider bei der Forumsuche auch nicht fündig geworden.
Ich würde gerne die komplette StringList (siehe Code) in die Zwischenablage kopieren.
Wie muss ich dazu die Funktion Clipboard einsetzen? Clipbrd ist bei uses schon eingetragen.
Meine bisherigen Versuche schlugen aber fehl, es wurde immer der Code der Stringlist in der Zwischenablage abgespeichert.
Wie muss der Code richtig aussehen?

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:
24:
 SL := TStringList.Create;

  SL.Clear; // StringList leeren

      SL.Add(Textfeld1.Text); 
      SL.Add(Auswahlbox1.Text);
      SL.Add(Memo1.Text);
      SL.Add(Memo2.Text);
      SL.Add(Textfeld2.Text);
      SL.Add(Textfeld3.Text);
      SL.Add(Textfeld4.Text);
      SL.Add(Textfeld5.Text);
      SL.Add(Auswahlbox2.Text);
      SL.Add(Auswahlbox7.Text);
      SL.Add(Auswahlbox8.Text);
      SL.Add(Auswahlbox3.Text);
      SL.Add(Auswahlbox4.Text);
      SL.Add(Auswahlbox5.Text);
      SL.Add(Auswahlbox6.Text);
      SL.Add(Textfeld6.Text);
      SL.Add(Textfeld7.Text);
      SL.Add(Auswahlbox9.Text);
      
SL.Free;




greetz

firediver


---

Hab' Sonne im Herzen und Pizza im Bauch denn dann bist du glücklich und satt bist du auch. ;-)

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 03.12.05 18:39 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var i:integer;s:string;

clipboard.open;

for i := 0 to SL.count-1 do
begin
s:=s+SL.strings[i]+#13;
end;

clipboar.astext:=s;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.12.05 20:09 
@Koller: Wäre identisch mit Clipboard.AsText := SL.Text; ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
firediver Threadstarter
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Sa 03.12.05 20:10 
Hi,

das funktioniert leider auch nicht.

[highlight][Warnung] metatag.pas(327): FOR-Schleifenvariable muss eine einfache lokale Variable sein
[Fehler] metatag.pas(329): Inkompatible Typen: 'String' und 'TLabel'
[Fehler] metatag.pas(332): Inkompatible Typen: 'String' und 'TLabel'[/highlight]
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 03.12.05 20:13 
Hallo

ohne deinen Quelltext kann da viel stehen und die Warnung ist eindeutig.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
firediver Threadstarter
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Sa 03.12.05 20:17 
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:
24:
25:
procedure TForm1.Zwischenablage1Click(Sender: TObject);
begin
  SL := TStringList.Create;
  SL.Clear;
  SL.Add(Textfeld1.Text);
  SL.Add(Auswahlbox1.Text);
  SL.Add(Memo1.Text);
  SL.Add(Memo2.Text);
  SL.Add(Textfeld2.Text);
  SL.Add(Textfeld3.Text);
  SL.Add(Textfeld4.Text);
  SL.Add(Textfeld5.Text);
  SL.Add(Auswahlbox2.Text);
  SL.Add(Auswahlbox7.Text);
  SL.Add(Auswahlbox8.Text);
  SL.Add(Auswahlbox3.Text);
  SL.Add(Auswahlbox4.Text);
  SL.Add(Auswahlbox5.Text);
  SL.Add(Auswahlbox6.Text);
  SL.Add(Textfeld6.Text);
  SL.Add(Textfeld7.Text);
  SL.Add(Auswahlbox9.Text);

  Clipboard.AsText := SL.Text
end;


Das war alles, es funktioniert prima. Oder meint ihr man könnte das mit einer Schleife noch einfacher machen?

THX


greetz firediver
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.12.05 20:51 
Der Source funktioniert nur unter der Annahme, dass Memo1 und Memo2 einzeilig sind. Und selbst dann, sollte man eher Memo1.Lines.Text nutzen. Für mehrzeilige Dinge innerhalb einer StringList sollte man entweder eine Encodierung vornehmen oder ein Count der Zeilen vornranstellen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 03.12.05 21:09 
Hallo,

ich würde für Memos mit mehreren Zeilen das verwenden:
ausblenden Delphi-Quelltext
1:
SL.AddStrings(Memo1.Lines);					

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )