How to automatically change the style after drag&drop UR
Posted: Mon Aug 27, 2007 12:45 pm
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.
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.