Page 1 of 1

How to automatically change the style after drag&drop UR

Posted: Mon Aug 27, 2007 12:45 pm
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.

Posted: Mon Aug 27, 2007 2:33 pm
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.