Hello,
I use a TRichViewEdit 11.0.5 with Delphi 2009.
Before using TRichViewEdit, I used TMemo. and TMemo automatically detects the hyperlinks, and this without same to have finished to write it. Example: I type www.micr and the control detected automatically was a hyperlink but I dont finished to write It. I insert it in TMemo with EM_AUTOURLDETECT message in CreateWnd procedure.
I'd like to know how to make so that TRichViewEdit reacts exactly in the same way, for not that the users of our software see a difference at first sight?
Thanks in advance.
Auto detection URL - TRichViewEdit
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
(TMemo can detect URLs? I thought only TRichEdit can do it).
In TRichViewEdit, you need to call procedure for URL detection when the user presses Space, Tab or Enter key (or may be colon and semicolon too). In addition, you need to call a procedure for closing hyperlink (to detect that URL ended).
Use OnKeyDown to detect Enter (Key=VK_RETURN) and OnKeyPress to detect other keys.
If you use RichViewActions, use the methods of TrvActionInsertHyperlink1:
You can find an example in the ActionTest demo.
Properties of hyperlinks (like blue and underlined) are defined in properties of TrvActionInsertHyperlink action.
If you do not use RichViewActions, see the demo in Assorted\Hypertext\URLs\
This demo has unit URLScan.pas. You can add this unit to your project. This unit have DetectURL and TerminateHyperlink procedures. These procedures use a custom function of TRVURLScanProcedure type. In this function, you can define properties of hyperlinks (like blue and underlined). You can copy implementation of this function from this demo.
In TRichViewEdit, you need to call procedure for URL detection when the user presses Space, Tab or Enter key (or may be colon and semicolon too). In addition, you need to call a procedure for closing hyperlink (to detect that URL ended).
Use OnKeyDown to detect Enter (Key=VK_RETURN) and OnKeyPress to detect other keys.
If you use RichViewActions, use the methods of TrvActionInsertHyperlink1:
Code: Select all
procedure TForm3.RichViewEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key in [#9, ' ', ',', ';'] then begin
rvActionsResource.rvActionInsertHyperlink1.DetectURL(RichViewEdit1);
rvActionsResource.rvActionInsertHyperlink1.TerminateHyperlink(RichViewEdit1);
end;
end;
Properties of hyperlinks (like blue and underlined) are defined in properties of TrvActionInsertHyperlink action.
If you do not use RichViewActions, see the demo in Assorted\Hypertext\URLs\
This demo has unit URLScan.pas. You can add this unit to your project. This unit have DetectURL and TerminateHyperlink procedures. These procedures use a custom function of TRVURLScanProcedure type. In this function, you can define properties of hyperlinks (like blue and underlined). You can copy implementation of this function from this demo.
With this code :
the TUrlEdit detect automaticaly URL after press "www.c".
This is possible to have a same detection with TRichView?
Code: Select all
unit UrlEdit;
interface
uses
ComCtrls;
type
TUrlEdit = class(TRichEdit)
protected
procedure CreateWnd; override;
end;
procedure Register;
implementation
uses
Classes, Windows, RichEdit;
procedure TUrlEdit.CreateWnd;
var
mMask: Longint;
lAutoUrlDetect: Boolean;
begin
inherited CreateWnd;
mMask := ENM_CHANGE or ENM_SELCHANGE or ENM_REQUESTRESIZE or ENM_LINK;
lAutoUrlDetect := True;
SendMessage(Handle, EM_SETEVENTMASK, 0, mMask);
SendMessage(Handle, EM_AUTOURLDETECT, Longint(lAutoUrlDetect), 0);
end;
procedure Register;
begin
RegisterComponents('URL Edit', [TUrlEdit]);
end;
end.
This is possible to have a same detection with TRichView?
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: