Page 1 of 1

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

Posted: Tue Apr 10, 2012 11:27 am
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?

Posted: Tue Apr 10, 2012 2:58 pm
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;

Posted: Tue Apr 10, 2012 7:17 pm
by Sergey Tkachenko
You can use OnItemHint (+ OnGetItemCursor) instead of OnRVMouseMove.

Posted: Tue Apr 10, 2012 8:49 pm
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?

Posted: Fri Apr 13, 2012 6:31 pm
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

Posted: Fri Apr 13, 2012 6:45 pm
by alexandreq
Yes, wonderful sergey.

I tried and tried the stones way rsrsrs and nothing.

thanks very much. :D