I download the chat demo at :
Advanced demo with rich text text input
http://www.trichview.com/support/files/ ... ysiwyg.zip
and it works fine. But I have 2 questions about it:
1.Why the HScrollVisible and VScrollVisible of rv have no effect? I set them to True, but the scrollbar is still hidden. Just when the text too long to going to scroll, it is showing. How can I set the scrollbar visible always, even if the text is empty?
2.How can I made the rv support "returns"? When I paste multi-line text into rve, and click "send", then the text will show in rv, but all of return(CRLF) are missing.
Thanks!
Question about the chat demo
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
1) If *ScrollVisible=True, scrollbars are displayed only when necessary.
If they are False, scrollbars are never displayed.
TRichView has no mode for displaying scrollbars when they are not necessary (unlike TRichViewEdit that always displays vertical scrollbar).
2) This demo inserts ' | ' instead of line breaks. You can see the code in TForm1.Encode:
How to support line breaks.
a) Exclude rvoDoNotWantReturns from rve.EditorOptions.
In FormCreate, change the assignment to rve.EditorOptions:
b) Change rve.OnKeyDown to send message on Ctrl+Return instead of Return:
c) Change TForm1.Encode to insert #13 instead of ' | ':
d) Change TForm1.ParseString:
Empty lines will still not be inserted. But I think this is good, because it prevents flooding.
If they are False, scrollbars are never displayed.
TRichView has no mode for displaying scrollbars when they are not necessary (unlike TRichViewEdit that always displays vertical scrollbar).
2) This demo inserts ' | ' instead of line breaks. You can see the code in TForm1.Encode:
Code: Select all
if (i>0) and rve.IsFromNewLine(i) then
Result := Result +' | ';
a) Exclude rvoDoNotWantReturns from rve.EditorOptions.
In FormCreate, change the assignment to rve.EditorOptions:
Code: Select all
rve.EditorOptions := rve.EditorOptions+[rvoNoImageResize]-
[rvoDoNotWantReturns,rvoWantTabs];
Code: Select all
procedure TForm1.rveKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
...
if (Key=VK_RETURN) and (Shift=[[color=red]ssCtrl[/color]]) and (rve.InplaceEditor=nil) then begin
btnEnterClick(nil);
Key := 0;
end;
end;
Code: Select all
if (i>0) and rve.IsFromNewLine(i) then
Result := Result +[color=red]#13[/color];
Code: Select all
...
for i := 1 to Length(s) do [color=red]begin
if s[i]=#13 then begin
AddStringWithURLs(StartIndex, i-1);
ParaNo := 0;
ReadState := rsNormal;
StartIndex := i+1;
continue;
end[/color];
if i>=StartIndex then
case ReadState of
...
end;
[color=red]end;[/color]
AddStringWithURLs(StartIndex, Length(s));
end;