Page 1 of 1

Question about the detecting url while typing

Posted: Sun Aug 12, 2007 10:57 am
by arnor
First, detecting url while typing is ok.
I already tested your demos.

But I have another question about this.

In your \Assorted\Hypertext\URLs demo,
what I want is append the content to another richview,
then click url on richview, but I fail

Here is my code

procedure TForm1.Button1Click(Sender: TObject);
var
myStream : TMemoryStream;
begin
myStream := TMemoryStream.Create();
if RichViewEdit1.SaveRVFToStream(myStream, false) then
begin
myStream.Position := 0;
RichView1.AppendRVFFromStream(myStream, 0);
RichView1.Format;
end;
myStream.free;
end;

the error will occur in "RichView1.AppendRVFFromStream(myStream, 0);"

It will popup an error says

EConvertError, "www.richedit.com" is not a valid integer value.


Please advise

Posted: Sun Aug 12, 2007 11:12 am
by arnor
Here is my another test.

I wrote new demo to test the code to detecting url.

In my test,

I add two event to my richviewedit (copy from your URLs demo),


procedure TForm1.rveKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key in [VK_SPACE, VK_RETURN] then begin
// url detection
DetectURL(rve, URLScanEvent, True);
// closing url if necessary
TerminateHyperlink(rve, URLScanEvent);
end;
end;


procedure TForm1.rveJump(Sender: TObject; id: Integer);
var RVData: TCustomRVFormattedData;
ItemNo: Integer;
url: String;
begin
rve.GetJumpPointLocation(id, RVData, ItemNo);
url := PChar(RVData.GetItemTag(ItemNo));
ShellExecute(0, 'open', PChar(url), nil, nil, SW_SHOW);
end;


then I input a url to edit, then use the same function to append to richview

procedure TForm1.Button3Click(Sender: TObject);
var
myStream : TMemoryStream;
r: Boolean;
begin

myStream := TMemoryStream.Create();
if rve.SaveRVFToStream(myStream, false) then
begin
myStream.Position := 0;
RichView1.AppendRVFFromStream(myStream, 0);
RichView1.Format;
SendMessage(RichView1.Handle,WM_VSCROLL,SB_BOTTOM,0);
end;
myStream.free;
end;


It works fine to append url to richview, BUT..

1) use CTRL + mouse click to click url in richviewedit, it will popup the directory of my program, not browser to the url.

2) mouse click on url on richview, it will cause access violation error.


Please advise

Posted: Sun Aug 12, 2007 3:57 pm
by Sergey Tkachenko
Include rvoTagsArePChars in Options property of all your RichViews and RichViewEdits.

Posted: Sun Aug 12, 2007 4:16 pm
by arnor
Thanks for quick response.

The problem is solved.

Thanks a lot.