Autor Beitrag
CarstenSchmidt
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Mo 20.06.05 09:45 
Moin!

Ich suche eine Memo Komponente (Kann auch Grid sein), in die ich Strings reinschieben kann, ohne dass sich die Komponente immer dahingehend aktualisiert, dass sie immer an den Anfang oder das Ende des Textes springt. Ich will quasi eine Zeile lesen können, gleichzeitig Strings in das Memo schreiben ohne dass der Text weiter wandert.
Kennt jemand so eine freie Komponente oder entsprechende Einstellungen an bestehenden Komponenten?

Gruß
Carsten
Hansi@OMG
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: Mo 20.06.05 14:16 
Schau dir mal die Jedi Komponenten an, da findest du bestimmt was, aber es gibt mit Sicherheit auch eine komfortablere Lösung.

Du kannst lesen mit
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
test:string;
begin
test:=memo1.Lines.Strings[15]; //Liest Zeile 15

end;


Dann ist es auch wurst mit scrollen oder versteh ich dich da falsch?

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
CarstenSchmidt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Mo 20.06.05 14:44 
Mir ist schon klar wie man einzelne Zeilen aus dem Memofeld auslesen kann. Mir geht es darum, dass, wenn dauernd neue Strings in das Memo geschrieben werden, der Text nach oben auswandert. Wenn ich (persönlich und leibhaftig, nicht das Programm) die erste Zeile lesen will, ist sie verschwunden (nach oben). Auch wenn ich an den Anfang des Memos scrolle, springt das Memo wieder an die letzte Zeile, sobald ein neuer String geschrieben wird.
Es scheint eine Eigenschaft des Memos zu sein (automatic scrolling oder so etwas), die ich gerne ein- bzw- ausschalten möchte.

Gruß
Carsten
Hansi@OMG
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: Mo 20.06.05 20:37 
Dann wie gesagt, schau dir mal die Jedis an.

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
CarstenSchmidt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Mo 20.06.05 21:01 
Du wirst lachen (oder auch nicht) aber die JVCL habe ich mir installiert und auch die Hilfe runtergeladen. Das JVMemo ist nicht dokumentiert und auch langes Suchen hat mir keine Hilfe gebracht. Ich wäre dankbar für einen etwas genaueren Hinweis, wie die Eigenschaft heisst damit ich mir dann selber weiterhelfen kann.

Carsten
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: Mo 20.06.05 22:35 
Hallo,

so geht es ohne JVCL, musst Du halt noch an deine Umgebung anpassen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var i : Integer;
begin
with Memo1 do
  begin
    i := SendMessage (Memo1.Handle, EM_GETFIRSTVISIBLELINE, 0, 0);
    Memo1.Lines.Add('Neue Zeile');
    SelStart := Perform(EM_LINEINDEX, i, 0);
    Perform(EM_SCROLLCARET, 0, 0);
  end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
CarstenSchmidt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Di 21.06.05 06:08 
Danke, das sieht schon nach dem aus, was ich machen möchte. Ich werde es heute abend mal ausprobieren.
Ich hatte eigentlich gedacht, dass es eine Eigenschaft wäre, die ich einfach auf true oder false setzen könnte (autoscrolling := false;).

Vielen Dank
Carsten
CarstenSchmidt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Do 23.06.05 06:00 
Ich habe Deine Tipps als Anregung zu folgendem Code genutzt. Ibin zu dem Schluss gekommen, dass ein stringgrid mir mehr Möglichkeiten bietet.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
z := stringgrid2.TopRow; //oberste sichtbare Zeile ermitteln

for y:= 1 to stringgrid2.RowCount -1 do
 begin
 if stringgrid2.Cells[0,y] = '' then break; //nächste leere Zeile ermitteln
 end;

//erweitern und neuen Text schreiben
if stringgrid2.RowCount = y then  stringgrid2.RowCount := y+1;
stringgrid2.Cells[0,y] :=inttostr(y);

zeilenzahl:=StringGrid2.Height div StringGrid2.DefaultRowHeight -3;
if y > zeilenzahl then begin
if checkbox1.Checked = true then
 begin
  StringGrid2.TopRow:=StringGrid2.RowCount-zeilenzahl;
 end
 else stringgrid2.TopRow := z;
end;



Gruß
Carsten

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 23.06.05 07:16 
Kannst du mal den Quelltext in Delphi-Tags packen?

Etwas ist mir aber noch an deinem Quelltext aufgefallen. Wenn der Anwender irgendeine Zeile zw. anderen befüllten Zeilen leer macht, wird später keine leere-Zeile mehr hinzugefügt, solange die eine leere Zeile noch da ist. Wenn man dann aber 100 000 Zeilen hat muss der Anwender lange suchen um die zu finden. Diese leerern Zeilen solltest du am besten mit entfernen ;). Der Quelltext unten ist ein Bsp., wie ich es in einem Programm gelöst habe (ist eine Tabelle in der RGB-Werte eingetragen werden).

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:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
unit Farbauswahl_Unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids;

type
  TForm3 = class(TForm)
    FarbStringGrid: TStringGrid;
    procedure FormResize(Sender: TObject);
    procedure FarbStringGridKeyPress(Sender: TObject; var Key: Char);
    procedure FormActivate(Sender: TObject);
    procedure FarbStringGridKey(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;

implementation
 uses Unit1;
{$R *.dfm}

procedure TForm3.FormResize(Sender: TObject);
begin
 Form3.FarbStringGrid.Width:=Form3.ClientWidth-16;
 Form3.FarbStringGrid.Height:=Form3.ClientHeight-16;
 Form3.FarbStringGrid.ColWidths[0]:=Form3.FarbStringGrid.ClientWidth div 3-1;
 Form3.FarbStringGrid.ColWidths[1]:=Form3.FarbStringGrid.ClientWidth div 3-1;
 Form3.FarbStringGrid.ColWidths[2]:=Form3.FarbStringGrid.ClientWidth div 3-1;
end;

procedure TForm3.FarbStringGridKeyPress(Sender: TObject; var Key: Char);
begin
 if not (Key in [#8, '0'..'9']) then
  begin
   Key:=#0
  end
 else
  begin
   with Form3.FarbStringGrid do
    begin
     if (Key<>#8) and (length(Cells[Col, Row])=3) then
      begin
       Key:=#0
      end
    end
  end
end;

procedure TForm3.FormActivate(Sender: TObject);
begin
 Form3.FarbStringGrid.Cells[0, 0]:='Rot';
 Form3.FarbStringGrid.Cells[1, 0]:='Grün';
 Form3.FarbStringGrid.Cells[2, 0]:='Blau'
end;

procedure TForm3.FarbStringGridKey(Sender: TObject; var Key: Word;
  Shift: TShiftState);
  var i: integer;
begin
 with Form3.FarbStringGrid do
  begin
   if (length(Cells[Col, Row])=3) and (StrToIntDef(Cells[Col, Row], 0)>255) then
    begin
     Cells[Col, Row]:='255'
    end;
   if (Cells[0, Row]='') and (Cells[1, Row]='') and ((Cells[2, Row]='')) then
    begin
     if Row<RowCount-1 then
      begin
       for i:=Row to RowCount-2 do
        begin
         Cells[0, i]:=Cells[0, i+1];
         Cells[1, i]:=Cells[1, i+1];
         Cells[2, i]:=Cells[2, i+1]
        end;
       RowCount:=RowCount-1 
      end
    end;
   if (Cells[0, Row]<>'') and (Cells[1, Row]<>'') and ((Cells[2, Row]<>'')) then
    begin
     if Row=RowCount-1 then
      begin
       RowCount:=RowCount+1
      end;
    end
  end;
 Form1.KoordinatenSystemZeichnen;
 for i:=0 to High(Funktionen) do
  begin
   Form1.DrawFunction(i)
  end
end;

end.
CarstenSchmidt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Do 23.06.05 09:02 
Entschuldigung: Was heisst "Quelltext in Delphi-Tags packen"?

Ich brauche auf Eingaben des Benutzers keine Rücksicht zu nehmen, weil es sich um ein Readonly stringgrid handelt.

Gruß
Carsten
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 23.06.05 09:21 
Die Delphi-Tags hat raziel jetzt geseztz ;). Das ist hier im DF um Quelltexte ordentlich formatiert anzuzeigen (also deine Einrückung und so bleibtr in dem Bereich).

Und die Eingabebehandlumng kannst du ja rausnehmen. Es ist ja nur der Quelltext wo ich es brauchte.
frank-wob
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 25.11.05 09:54 
Wenn es nur darum geht das die Strings nicht scrollen, nimm doch einfach eine ListBox. Die scrollt nicht mit und du benötigst keine einzige Zeile Code dazu.