trichview.com Forum Index trichview.com
TRichView support forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question about the chat demo

 
Post new topic   Reply to topic    trichview.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
cakk



Joined: 17 Dec 2009
Posts: 14

PostPosted: Wed May 19, 2010 11:53 pm    Post subject: Question about the chat demo Reply with quote

I download the chat demo at :

Advanced demo with rich text text input
http://www.trichview.com/support/files/chatcodeswysiwyg.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!
Back to top
View user's profile Send private message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6607

PostPosted: Thu May 20, 2010 9:54 am    Post subject: Reply with quote

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:
Code:
    if (i>0) and rve.IsFromNewLine(i) then
      Result := Result +' | ';


How to support line breaks.
a) Exclude rvoDoNotWantReturns from rve.EditorOptions.
In FormCreate, change the assignment to rve.EditorOptions:
Code:
  rve.EditorOptions := rve.EditorOptions+[rvoNoImageResize]-
    [rvoDoNotWantReturns,rvoWantTabs];

b) Change rve.OnKeyDown to send message on Ctrl+Return instead of Return:
Code:
procedure TForm1.rveKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  ...
  if (Key=VK_RETURN) and (Shift=[ssCtrl]) and (rve.InplaceEditor=nil) then begin
    btnEnterClick(nil);
    Key := 0;
  end;
end;

c) Change TForm1.Encode to insert #13 instead of ' | ':
Code:
    if (i>0) and rve.IsFromNewLine(i) then
      Result := Result +#13;

d) Change TForm1.ParseString:
Code:
  ...
  for i := 1 to Length(s) do begin
    if s[i]=#13 then begin
      AddStringWithURLs(StartIndex, i-1);
      ParaNo := 0;
      ReadState := rsNormal;
      StartIndex := i+1;
      continue;
    end
;
    if i>=StartIndex then
      case ReadState of
        ...
      end;
  end;
  AddStringWithURLs(StartIndex, Length(s));
end;


Empty lines will still not be inserted. But I think this is good, because it prevents flooding.
Back to top
View user's profile Send private message Visit poster's website
cakk



Joined: 17 Dec 2009
Posts: 14

PostPosted: Thu May 20, 2010 11:10 am    Post subject: Reply with quote

ok! its works fine!! Thanks a lots! Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    trichview.com Forum Index -> Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group