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 

Auto detection URL - TRichViewEdit

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



Joined: 23 Mar 2009
Posts: 6

PostPosted: Fri Feb 26, 2010 2:55 pm    Post subject: Auto detection URL - TRichViewEdit Reply with quote

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.
Back to top
View user's profile Send private message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6599

PostPosted: Fri Feb 26, 2010 5:47 pm    Post subject: Reply with quote

(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:
Code:
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;

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.
Back to top
View user's profile Send private message Visit poster's website
Marcer



Joined: 23 Mar 2009
Posts: 6

PostPosted: Mon Mar 08, 2010 2:17 pm    Post subject: Reply with quote

With this code :


Code:
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.


the TUrlEdit detect automaticaly URL after press "www.c".

This is possible to have a same detection with TRichView?
Back to top
View user's profile Send private message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6599

PostPosted: Tue Mar 09, 2010 12:52 pm    Post subject: Reply with quote

No, URL detection is possible only using the ways I described in my previous reply.
TRichViewEdit is not based on TRichEdit, so EM_AUTOURLDETECT means nothing to it.
Back to top
View user's profile Send private message Visit poster's website
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