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: Mi 08.01.14 07:22 
Hi Delpher,

es existiert ein Memo mit z.B. 150 Zeilen.
Ich adde jetzt Zeilen mit memo1.lines.add() ...

Beim Dateiaufruf ist der Cursor aber in Zeile 1. Wie kann ich
den Cursor schon gleich in die letzte Zeile positionieren?

Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
baumina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 305
Erhaltene Danke: 61

Win 7
Delphi 10.2 Tokyo Enterprise
BeitragVerfasst: Mi 08.01.14 08:21 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  memo1.SetFocus;
  memo1.CaretPos := Point(0,Memo1.Lines.Count-1); // springt vor erstes Zeichen der letzten Zeile
  // ODER
  memo1.CaretPos := Point(length(Memo1.Lines[Memo1.Lines.Count-1]),Memo1.Lines.Count-1); // springt hinter letztes Zeichen der letzten Zeile
  SendMessage(memo1.Handle, EM_SCROLLCARET, 0, Memo1.Lines.Count-1);

Für diesen Beitrag haben gedankt: D. Annies
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: Mi 08.01.14 08:42 
Danke für den Tipp, funzt aber leider nicht, es gibt keine Veränderung.
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
baumina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 305
Erhaltene Danke: 61

Win 7
Delphi 10.2 Tokyo Enterprise
BeitragVerfasst: Mi 08.01.14 08:45 
Komisch, habe den Code bei mir getestet. Und funktioniert mit Delphi XE einwandfrei.
Mathematiker
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2622
Erhaltene Danke: 1448

Win 7, 8.1, 10
Delphi 5, 7, 10.1
BeitragVerfasst: Mi 08.01.14 08:52 
Hallo,
ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
procedure TForm1.Button1Click(Sender: TObject);
var
   itemp: Integer;
begin
   with RichEdit1 do
   begin
     // Move to the last line:
     // Zur letzten Zeile scrollen:
     SelStart := Length(Text);
     Perform(EM_SCROLLCARET, 00);

     // or: Perform(WM_VSCROLL, SB_BOTTOM,0);

     // Move to the first line:
     // Zur ersten Zeile Scrollen:
     SelStart := Perform(EM_LINEINDEX, 00);
     Perform(EM_SCROLLCARET, 00);

     // Move to Line 5, Character 3:
     // Cursor auf Linie 5, Postion 3 setzen:
     SelStart := Perform(EM_LINEINDEX, 50) + 3;
     Perform(EM_SCROLLCARET, 00);

     // Scroll down 1 Line
     // Eine linie nach unten scrollen
     with RichEdit1 do
     begin
       itemp := SendMessage(Handle, EM_LINEFROMCHAR, SelStart, 0);
       SelStart := Perform(EM_LINEINDEX, itemp + 10);
       Perform(EM_SCROLLCARET, 00);
     end;

     // Set the focus on the RichEdit:
     // Den Fokus aufs RichEdit setzten:
     SetFocus;
   end;
end;

Quelle: SwissDelphiCenter
Das RichEdit1 durch ein Memo ersetzen und es müsste funktionieren.

Beste Grüße
Mathematiker

_________________
Töten im Krieg ist nach meiner Auffassung um nichts besser als gewöhnlicher Mord. Albert Einstein

Für diesen Beitrag haben gedankt: D. Annies
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: Mi 08.01.14 09:47 
Der Compiler meckert über die Variable? / Entität? "itemp".
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
vagtler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 96
Erhaltene Danke: 24


Delphi 2010, C# (VS 2012), Objective-C, Java
BeitragVerfasst: Mi 08.01.14 10:01 
Warum sollte er?
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: Mi 08.01.14 10:19 
Ich habe nicht beachtet, dass das Memo auf form2 liegt, also alles mit form2.memo1 ...

(Wie kann man nur so xxxxxxxxxxx)

LG, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
baumina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 305
Erhaltene Danke: 61

Win 7
Delphi 10.2 Tokyo Enterprise
BeitragVerfasst: Mi 08.01.14 10:24 
Und spätestens jetzt sollte man ernsthaft darüber nachdenken den Formularen, den Memos und allen anderen Komponenten vernünftige Namen zu geben.

Für diesen Beitrag haben gedankt: Tastaro
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: Mi 08.01.14 11:45 
Hast ja recht :)
LG, Detlef

P.S. Hast du noch einen Tipp, wie man form2 und form2.komponente_xxx möglichst "geräuschlos"
umbenennen kann?

_________________
ut vires desint, tamen est laudanda voluntas
vagtler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 96
Erhaltene Danke: 24


Delphi 2010, C# (VS 2012), Objective-C, Java
BeitragVerfasst: Mi 08.01.14 11:57 
GExperts oder CnPack

Zum architektonischen Aufbau solcher Konstrukte sag ich jetzt mal lieber nichts...
baumina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 305
Erhaltene Danke: 61

Win 7
Delphi 10.2 Tokyo Enterprise
BeitragVerfasst: Mi 08.01.14 11:58 
Hauptmenü Suchen/Ersetzen in .pas und .dfm
Perlsau
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 08.01.14 16:06 
user profile iconD. Annies hat folgendes geschrieben Zum zitierten Posting springen:
Wie kann ich den Cursor schon gleich in die letzte Zeile positionieren?

Bei mir funktioniert folgende Methode tadellos:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TFormMain.Button_AnsEndeClick(Sender: TObject);
begin
  Memo_Test.SelStart := Length(Memo_Test.Text);
  Memo_Test.SetFocus;
end;

Der Cursor wandert auf diese Weise zuverlässig ans Ende deines Memo-Textes. Wenn du nichts davon siehst, liegt das daran, daß das Memo nicht von alleine dort hinscrollt, wo dein Cursor steht. Spätenstens bei der nächsten Eingabe tut es das aber.

Für diesen Beitrag haben gedankt: D. Annies
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 14.01.14 12:17 
user profile iconD. Annies hat folgendes geschrieben Zum zitierten Posting springen:
P.S. Hast du noch einen Tipp, wie man form2 und form2.komponente_xxx möglichst "geräuschlos"
umbenennen kann?
Ab Turbo Delphi sollte das mit Refactoring problemlos gehen.
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 19.01.14 04:38 
Jo, Danke.

_________________
ut vires desint, tamen est laudanda voluntas