How to automatically change the style after drag&drop UR

General TRichView support forum. Please post your questions here
Post Reply
JSH2
Posts: 7
Joined: Sat Apr 21, 2007 12:27 pm

How to automatically change the style after drag&drop UR

Post by JSH2 »

To make hyprttext when I drag&drop a URL from internet explorer,
I use OnReadHyperlink and OnJump event as follows:

procedure TForm1.FormCreate(Sender: TObject);
begin
with RichViewEdit1 do begin
RTFReadProperties.UnicodeMode := rvruOnlyUnicode; //To use unicode
Options := Options + [rvoTagsArePChars];
AcceptDragDropFormats := AcceptDragDropFormats + [rvddURL];
Format;
end;

procedure TForm1.RichViewEdit1ReadHyperlink(Sender:TCustomRichView;
const Target, Extras: string; DocFormat: TRVLoadFormat; var StyleNo,
ItemTag: Integer; var ItemName: string);
begin
if DocFormat = rvlfURL then begin
StyleNo := cHyperLinkStyle;
ItemTag := Integer(StrNew(PChar(Target)));
end;
end;

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

It works well.
But after drag&drop a URL, the textstyle remains the cHyperLinkStyle.
After drag&drop a URL, how could I automatocally change the textstyle to the previous textstyle?

Thanks in advance.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Not possible using "normal" methods (well, you can store the current text style and apply it in the next call of OnChange).
I suggest to implement switching to non-hypertext style when user presses space character.
Post Reply