Autor Beitrag
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Di 13.05.03 21:27 
Hallo zusammen!!

Ich möchte in meinem RichEdit folgendes machen:
  1. die letzten Zweizeilen löschen
  2. eine Zeile mit bestimmten Inhlat löschen
  3. Die corsorpositoin festsetzen

zu 3.: ich habs so probiert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.RichEdit1Change(sender: Tobject);
begin
  RichEdit.CaretPos.x:= 3
end;

Kommt aber:
Zitat:
Der linken Seite kann nichts zu gewiesen werden.

Heißt das, dass das "Readonly" ist????

//Edit:
Und nun die anderen 2:

  1. Schauen ob ein bestimmtes Wort öfter auftaucht als ein anders (z.B.: ob mehr Klammern geöffnet sin als geschlossen)
  2. Verhindern, dass man nach Textende noch scrollen kann bis der Text ganz weg ist

Stefan

Moderiert von user profile iconTino: Code-Tag hinzugefügt.[/list]

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)


Zuletzt bearbeitet von StefanH am Do 22.05.03 19:22, insgesamt 1-mal bearbeitet
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Di 13.05.03 21:45 
1.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
If RichEdit1.Lines.Count > 1 do  // es müssen mindestens zwei Zeilen da sein
  begin
   RichEdit1.Lines.Delete(RichEdit1.Lines.Count-1);
   RichEdit1.Lines.Delete(RichEdit1.Lines.Count-2);
  end;


2.
ausblenden Delphi-Quelltext
1:
2:
3:
For i := 0 to RichEdit1.Lines.Count-1 do
   If RichEdit1.Lines[i] = 'Das soll in der Zeile stehen' then
        RichEdit1.Lines.Delete[i];


3. Dafür habe ich jetzt keinen Code parat, auf jeden Fall musst du mit RichEdit1.SelStart arbeiten (siehe Online-Hilfe).

P.S.: RichEdit.CaretPos ist ReadOnly.

_________________
If accidentally read, induce vomitting.
flow
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mi 14.05.03 07:46 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure GetRichEditRowCol(R: TRichEdit; var Row, Col : LongInt);
begin
  Row := SendMessage(R.Handle, EM_LINEFROMCHAR, R.SelStart, 0);
  Col := M.SelStart-SendMessage(R.Handle, EM_LINEINDEX, Row, 0);
end;

Gibt dir die genaue Zeile und Spalte wo sich der Cursor befindet.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure SetRichEditRowCol(R : TRichEdit; Row, Col : Integer);
begin
  R.SelStart := SendMessage(R.Handle, EM_LINEINDEX, Row, 0) + Col;
end;

Setzt dir die genaue Cursor Position.

FLOW

_________________
die Welt ist eine Scheibe
...und aus Vinyl!!!
Simon Joker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236
Erhaltene Danke: 1



BeitragVerfasst: Mi 14.05.03 11:20 
Hi

zu 1:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
i:=2//löschte die letzten 2 Zeilen wenn vorhanden (ungetestet)
while (Memo1.Lines.Count>0and (i>0do
  begin
    Memo1.Lines.Delete(Memo1.Lines.Count-1);
    dec(i);
  end;

ich würde es so lösen.
@Ex0rzist
dein Vorschlag crasht. Du löschtst erst die letzte Zeile und dann die VORLETZTE! Bei mehr als 2 Zeilen wird die falsche gelöscht und bei 2 Zeilen versuchst du Zeile -1 zulöschen. Die Befehle müssen getauscht werden.
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Mi 14.05.03 15:47 
Jo, Danke!! Werds probieren (wird schon gehen, ich will euch ja nicht schlecht machen :wink: )

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Do 15.05.03 19:36 
@Simon Joker

Stimmt. :shock:

Asche auf mein Haupt.

_________________
If accidentally read, induce vomitting.
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Do 15.05.03 19:38 
Ex0rzist hat folgendes geschrieben:

2.
ausblenden Delphi-Quelltext
1:
2:
3:
For i := 0 to RichEdit1.Lines.Count-1 do
   If RichEdit1.Lines[i] = 'Das soll in der Zeile stehen' then
        RichEdit1.Lines.Delete[i];   <-: Fehlermeldung


Fehlermeldung hat folgendes geschrieben:
Nicht genügend wirkliche Paramenter :(


mfg Stefan

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Do 15.05.03 20:01 
ausblenden Delphi-Quelltext
1:
2:
3:
For i := 0 to RichEdit1.Lines.Count-1 do
   If RichEdit1.Lines[i] = 'Das soll in der Zeile stehen' then
        RichEdit1.Lines.Delete(i);


Da müssen natürlich runde Klammern hin. Immer diese Flüchtigkeitsfehler ...

_________________
If accidentally read, induce vomitting.
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Do 22.05.03 19:26 
Und nun die anderen 2:


  1. Schauen ob ein bestimmtes Wort öfter auftaucht als ein anders (z.B.: ob mehr Klammern geöffnet sin als geschlossen)

  2. Verhindern, dass man nach Textende noch scrollen kann bis der Text ganz weg ist



Stefan

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 25.05.03 12:34 
zu 1.:
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:
procedure CompareWords(text, wort1, wort2: string);
var
 p, p2, cw1, cw2: integer;
begin
   cw1 := 0; cw2 := 0;
   p := 1;
   p2 := 1;
Repeat 
 p := pos(wort1,text);
 if p <> 0 then begin
  inc(cw1);
  delete(text,p,length(wort1));
 end;
 p2 := pos(wort2,text);
 if p2 <> 0 then begin
  inc(cw2);
  delete(text,p2,length(wort2));
 end;
Until (p = 0and (p2 = 0);
  if cw1 > cw2 then showmessage(wort1+' ist häufiger '+wort2);
  if cw1 < cw2 then showmessage(wort2+' ist häufiger als '+wort1);
  if cw1 = cw2 then showmessage(wort1+' ist genauso oft vorhanden wie '+wort2);
end;


mfg
GSE


Moderiert von user profile icontommie-lie: Code- durch Delphi-Tags ersetzt

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)