TAdvRichEditor and hyperlink to a file

Hi,

how to hyperlink to a file? 

I've used this code: 
void __fastcall TFormCreateEditObject::MakeHyperlinkOfSelectedTextBitBtnClick(TObject *Sender)
{
UnicodeString str = FreeTextAdvRichEditor->SelectedText();
FreeTextAdvRichEditor->SetSelectionHyperlink(str);
}

The selected text is like "c:\temp\example.txt" 
How to start Explorer and show this file with Ctrl+mouseclick?

Kind regards,
Lars  

A proper file URL should have the prefix file:// in this case.

Thx Bruno! 

One more question though, if I have a "space" in the path it doesn-t work. I've tried %20 but it doesn't work either. 


Example: file://c:\temp\example.txt works but not: 
file://c:\temp\example file.txt

Kind regards,
Lars

I have retested this here with:

  advricheditor1.SetSelectionHyperlink('file://c:\temp\test me.html');
but also
  advricheditor1.SetSelectionHyperlink('file://c:\temp\test me.txt');

and then ctrl-click the hyperlink and it opens the clicked file URL with either Internet Explorer or Notepad. 
Do you use the latest version of the component?

Hi Bruno,

when I run this:
AdvRichEditor->InsertText("file://d:\temp\test me.txt");
only
"file://d:\temp\test " (upto the space after 'test')
is marked as a link. 

When I save it and opens the editor only "file://d:\temp\test " is shown in blue. 
I googled and it seems I must replace the ":" in ":" with "|" and the spaces to "%20". 
Moreover the string "file://" must be changed to "file:///". 

So I change the string "file://d:\temp\test me.txt" to "file:///d|\temp\test%20me.txt"
I've tested that and it works. 

BR, Lars

It was not clear you were just using InsertText as you first indicated you used SetSelectionHyperlink. For using InsertText(), auto URL handling will only work when the text you insert has no spaces. The auto URL cannot know a space starts a new word or is part from the URL.

Yes, you're right. Of course not. Thx.