Show the FootNote text as a hint, is it possible?

General TRichView support forum. Please post your questions here
Post Reply
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Show the FootNote text as a hint, is it possible?

Post by alexandreq »

Hello Sergey,

This subject is very interesting to me.

I have some footnotes from my text, I'd like to know whether it is possible when my mouse is over of each footnote number in my text, it appears as a hint with my footnote text for that footnote number.


Did you understand?
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

Post by mohsen24000 »

Hi
This is a simple way:

Code: Select all

function GetFntStr(fntNO:integer;rv:TRichViewEdit):string;
var NoteItem: TCustomRVNoteItemInfo;
stream:TmemoryStream;
s:string;
begin
if fntNo>=0 then
if rv.GetItem(fntNo) is TCustomRVNoteItemInfo then begin
stream:=TmemoryStream.Create;
NoteItem:=(rv.GetItem(fntNo) as TCustomRVNoteItemInfo);
NormalizeRichView (NoteItem.Document);
noteitem.Document.SaveTextToStream('',stream,0,false,true,true,true,0);
stream.Position:=0;
setlength(s,stream.Size div 2);
Stream.ReadBuffer(PWideChar(s)^, Stream.Size);
Stream.Clear;
Stream.Free;
result:=s;
end;
end;

procedure TForm1.rvMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  LRVData: TCustomRVFormattedData;
  LWord: String;
  LItemNo : Integer;
begin
TCustomRichViewEdit(sender).GetWordAt(x,y,LRVData,LItemNo,LWord);
if LItemNo>=0 then begin
if rv.GetItem(LItemNo) is TCustomRVNoteItemInfo then begin
TCustomRichViewEdit(sender).Cursor:=101;
rv.Hint:=GetFntStr(LItemNo,rv);
rv.ShowHint:=True;
end
else begin
rv.Hint:='';
rv.ShowHint:=False;
TCustomRichViewEdit(sender).Cursor:=102;
end;
end else begin
TCustomRichViewEdit(sender).Cursor:=102;
rv.Hint:='';
rv.ShowHint:=False;
end;
end;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You can use OnItemHint (+ OnGetItemCursor) instead of OnRVMouseMove.
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Hello Sergey,

I tried to do what you gave me but I haven't had any success so far.

I tried to do that with DBSRichViewEdit.

Another thing

When I open the event onItemHint, the Delphi complained:
[Error] Unit1.pas(183): Undeclared identifier: 'TCustomRichView'

from the function

Sergey, is it possible to make an example with DBSRichView?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

uses CRVData, RichView, RVGetTextW, RVNote;
// for Delphi 4-2007, use RVGetText instead of RVGetTextW

procedure TForm1.DBSRichViewEdit1ItemHint(Sender: TCustomRichView;
  RVData: TCustomRVData; ItemNo: Integer; var HintText: string);
begin
  if RVData.GetItem(ItemNo) is TCustomRVNoteItemInfo then
    HintText := GetRVDataText(TCustomRVNoteItemInfo(RVData.GetItem(ItemNo)).Document);
end;
Properties:
1) Include rvoShowItemHints in DBSRichViewEdit1.RVOptions
2) Assign DBSRichViewEdit1.ShowHint := True
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Yes, wonderful sergey.

I tried and tried the stones way rsrsrs and nothing.

thanks very much. :D
Post Reply