Dear all,
How can I assign ToolTip for each xBrowse Cell?
Regards,
FAP
Frances
Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
Dear all,
How can I assign ToolTip for each xBrowse Cell?
Regards,
FAP
You can use oCol:bToolTip.
This codeblock is evaluated with parameters oBrw, nRow,nCol,nKeyFlags. nRow and nCol are in pixels relative to the browse. The text returned by evaluating the codeblock is displayed as cell's tooltip.
Important Caution: The cell for which the tooltip being displayed may be in a row different from the current row of browse. It is your responsibility to know which row the tooltip cell belongs to and retrieve the values.
...
with object oBrw
:aCols[ 2 ]:bToolTip := {| oBrw, nRow, nCol, nKeyFlags| 'Code: '+oBrw:aCols[1]:Value() +CRLF+;
'Desc: '+oBrw:aCols[2]:Value() }
end
...This does not give you the correct result all the times.
For example, the browse cursor is on 3rd row.
The user hovers the mouse on 5th row. The tooltip is expected to show the information relating to the 5th row, but actually shows information relating to the 3rd row.
Coding this bToolTip is really tricky. You need to find the aCol[ 1 ]:Value if the browse cursor is moved to 5th row.
nageswaragunupudi wrote:This does not give you the correct result all the times.
For example, the browse cursor is on 3rd row.
The user hovers the mouse on 5th row. The tooltip is expected to show the information relating to the 5th row, but actually shows information relating to the 3rd row.
Coding this bToolTip is really tricky. You need to find the aCol[ 1 ]:Value if the browse cursor is moved to 5th row.
Its rather easier when we browse arrays.
Visible Row number where the mouse is positioned is
nToolTipRow := oBrw:MouseRowPos( nRow ) // nRow from the parameter to the codeblock
We want the Array Row Number where the mouse is hovering:
nToolTipAt := oBrw:nArrayAt - oBrw:nRowSel + oBrw:MouseRowPos( nRow )
Value to display in the tooltip is oBrw:aArrayData[ nToolTipAt ][ <your column> ]
In case of non array datasource, we need to move to the new record, read data and reposition to the original record. I don't think it is worthwhile.
In any case, first test with an Array Browse and then decide.
oBrw:aCols[ 3 ]:bToolTip := { | oBrw, nRow, nCol, nFlags | ;
oBrw:aArrayData[ oBrw:nArrayAt - oBrw:nRowSel + ;
oBrw:MouseRowPos( nRow ), 2 ] }function XbrDbfToolTip()
local oDlg, oBrw, oFont
USE CUSTOMER
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE DIALOG oDlg SIZE 400,300 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
ALIAS 'CUSTOMER' AUTOCOLS CELL LINES NOBORDER
oBrw:aCols[ 2 ]:bToolTip := { | oBrw, nRow, nCol, nFlags | MyToolTip( oBrw, nRow, nCol, nFlags) }
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
CLOSE CUSTOMER
return nil
//------------------------------------------------------------------//
static function MyToolTip( oBrw, nRow, nCol, nFlags )
local nSaveRec := oBrw:BookMark
local nMouseRow := oBrw:MouseRowPos( nRow )
local cRet := ''
if nMouseRow > 0
oBrw:Skip( nMouseRow - oBrw:nRowSel )
// or alternatively,
// oBrw:KeyNo( oBrw:KeyNo() + nMouseRow - oBrw:nRowSel )
cRet := ( oBrw:cAlias )->First
oBrw:BookMark := nSaveRec
endif
return cRet
//------------------------------------------------------------------//
Are you using array to browse?
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"
#include "hbcompat.ch"
REQUEST DBFCDX
#xtranslate <x> [is] between <a> and <b> => ( <x> >= <a> .and. <x> <= <b> )
#xtranslate <x> [is] not between <a> and <b> => !( <x> between <a> and <b> )
//----------------------------------------------------------------------------//
FUNCTION main()
local oDlg, oBrw, oFont
local aBmp := { ;
"c:\fwh\bitmaps\16array.bmp", ;
"c:\fwh\bitmaps\16back.bmp", ;
"c:\fwh\bitmaps\16block.bmp", ;
"c:\fwh\bitmaps\16char.bmp", ;
"c:\fwh\bitmaps\16clip.bmp", ;
"c:\fwh\bitmaps\16code.bmp", ;
"c:\fwh\bitmaps\16COPY.bmp", ;
"c:\fwh\bitmaps\16date.bmp", ;
"c:\fwh\bitmaps\16dbgbrk.bmp" }
SetBalloon( .t. )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 600,400 PIXEL FONT oFont
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg COLUMNS 1,1 ;
ARRAY aBmp HEADERS "Bmp", "File" SIZES 32 LINES CELL
oBrw:aCols[ 1 ]:cDataType := "F"
ADD TO oBrw AT 1 DATA oBrw:KeyNo() HEADER "No." PICTURE "99"
oBrw:bToolTips := { | oBrw, nRow | ShowBmpFileName( oBrw, nRow ) }
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//----------------------------------------------------------------------------//
static function ShowBmpFileName( oBrw, nRow )
local nMouseRow := oBrw:MouseRowPos( nRow )
if nMouseRow > 0
return oBrw:aArrayData[ oBrw:nArrayAt - oBrw:nRowSel + nMouseRow ]
endif
return ""
//----------------------------------------------------------------------------//
Frances/Rao, is this feature running smoothly now?
Dear Hua,
Im using FWH12.05.. still not ideal.. maybe with newer FW version..
Thanks for the feedback Frances ![]()