The problem is that new text is inserted at the caret, or insertion
point. What you ight be able to do is note the current position, do
the insertion at the end, and move the insertion point back to the
saved value. That still leaves you with a possible flashing effect;
you may need to experiment with disabling the update while this
happens and readjusting the top line of the control.
Good luck.
Kurt
Ok... because this possibility exsist e.g. in TListView, I think it's must
be possible in the TRichEdit too... There is of course many possibility to
do it with tracking FirstVisibleLine and LastVisibleLine and counting number
of visible lines, etc - only one problem with losed focus. E.g. if user
want select part of received text, selection will be unselected when new
lines appears. Have used TempBuffer while scrolled = true, but I think there
must be more beautyful solution.
I think there must be some Win Message witch would be killed while
textwindow is scrolled (scrolled := Memo.Lines.Count > LastVisibleLine).
I would like use allso RichEdit insted ListView (code below).
If the dataset is used as datasource there is possibility to
DataSet.DisableControls, etc. without losing any incoming data.
Erkki
procedure TfrmTelnet.IdTelnetDataAvailable(Sender: TIdTelnet;
const Buffer: String);
// update the ListView (LV1) control when we get data}
const
CR = #13;
LF = #10;
var
Start, Stop : Integer;
ListItem : TListItem;
begin
BreakOutData(Buffer);
Start := 1;
Stop := Pos(CR, Buffer);
if Stop = 0 then Stop := Length(Buffer) + 1;
while Start <= Length(Buffer) do
begin
ListItem := LV1.Items.Add;
ListItem.Caption := Copy(Buffer, Start, Stop - Start);
if Autoscroll1.Checked then //Autoscroll1 = TMenuItem
LV1.Scroll(0,(ListItem.Position.Y)+(2*LV1.Font.Height));
if Buffer[Stop] = CR then
begin
// ListItem := LV1.Items.Add;
end;
Start := Stop + 1;
if Start > Length(Buffer) then Break;
if Buffer[Start] = LF then Start := Start + 1;
Stop := Start;
while (Buffer[Stop] <> CR) and (Stop <= Length(Buffer)) do
Stop := Stop + 1;
end;
end;
>Ok... because this possibility exsist e.g. in TListView, I think it's must
>be possible in the TRichEdit too...
No. The insertion logic for an Edit control vs a ListView (all of
which is embedded within Windows) is completely different.
>E.g. if user
>want select part of received text, selection will be unselected when new
>lines appears.
Yes, you need to track that also, and restore it. That is not a
trivial task. Try, for example, restoring a selected portion of text
where the selection is being done from right to left. It can be done,
but it is quite ugly.
>I think there must be some Win Message witch would be killed while
>textwindow is scrolled (scrolled := Memo.Lines.Count > LastVisibleLine).
If you find it, let us know. But really, the scrolling is the least of
the problems; more difficult is the insertion, restoration of th
caret, etc.
>I would like use allso RichEdit insted ListView (code below).
>If the dataset is used as datasource there is possibility to
>DataSet.DisableControls, etc. without losing any incoming data.
I don't understand. The problem here is in the nature of a TEdit
control. It has nothing to do with the source of the updates.
Good luck.
Kurt
>>If the dataset is used as datasource there is possibility to
>>DataSet.DisableControls, etc. without losing any incoming data.
> I don't understand. The problem here is in the nature of a TEdit
> control. It has nothing to do with the source of the updates.
I mean, if e.g. BlobStream has used to carry temporary data, we can take
control how to update incoming data on DbRichEdit control. This is only my
"new idé" I haven't done any tests...
Regards Erkki