FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse Cell ToolTip
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
xBrowse Cell ToolTip
Posted: Mon Mar 22, 2010 08:35 AM

Dear all,

How can I assign ToolTip for each xBrowse Cell?

Regards,
FAP

Kind Regards,

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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Cell ToolTip
Posted: Mon Mar 22, 2010 11:05 AM

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.

Regards



G. N. Rao.

Hyderabad, India
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: xBrowse Cell ToolTip
Posted: Tue Mar 23, 2010 12:58 AM
Dear RAO,

Thanks so much..

I did this:
Code (fw): Select all Collapse
...
with object oBrw
     :aCols[ 2 ]:bToolTip := {| oBrw, nRow, nCol, nKeyFlags| 'Code: '+oBrw:aCols[1]:Value() +CRLF+;
                                                             'Desc: '+oBrw:aCols[2]:Value() }
end 
...


it shows exactly what I wish for..


My best regards,
FAP
Kind Regards,

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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Cell ToolTip
Posted: Tue Mar 23, 2010 05:44 AM

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.

Regards



G. N. Rao.

Hyderabad, India
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: xBrowse Cell ToolTip
Posted: Tue Mar 23, 2010 07:11 AM
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.




Dear RAO,

Yes it is tricky... Shows only the tooltip of current selected row..

Do you have a solution or starting point with this?

Regards,
FAP
Kind Regards,

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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Cell ToolTip
Posted: Tue Mar 23, 2010 10:41 AM

Its rather easier when we browse arrays.

  1. The selected row is
    nAt := oBrw:nArrayAt
  2. Visible Row number of the selected row in the display is
    nRowSel := oBrw:nRowSel.
  3. Visible Row number where the mouse is positioned is
    nToolTipRow := oBrw:MouseRowPos( nRow ) // nRow from the parameter to the codeblock

  4. 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.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Cell ToolTip
Posted: Tue Mar 23, 2010 11:07 AM
I tested just now. This code is working for me with arrays.
Code (fw): Select all Collapse
   oBrw:aCols[ 3 ]:bToolTip := { | oBrw, nRow, nCol, nFlags | ;
     oBrw:aArrayData[ oBrw:nArrayAt - oBrw:nRowSel + ;
     oBrw:MouseRowPos( nRow ), 2 ] }

You may adopt your column numbers and other logic.

Incidentally, there is a minor defect in implementation of this tooltip. Tooltip is not refreshed when we move from row to row in the same column. User has to leave the column and re-enter the column on a different row.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Cell ToolTip
Posted: Tue Mar 23, 2010 11:21 AM
This is the code for non-array browses.
Code (fw): Select all Collapse
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

//------------------------------------------------------------------//

Theoretically this is correct code. But at times this is showing wrong results.
Probably either the result of MouseRowPos() method is not very accurate all the times or the nRow parameter value is not correct all the times.
Please test for yourself
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse Cell ToolTip
Posted: Wed Jun 29, 2011 10:27 PM
Mr. Rao,

I don't know, if it can be used, to display the complete Cell-text ?
I would like to show the full path / name of a selected BMP without using HScroll.



...
...
oBrw1:aCols[ 2 ]:nWidth := 70
oBrw1:aCols[ 2 ]:nEditType := TYPE_IMAGE
oBrw1:aCols[ 2 ]:lBmpStretch := .f.
oBrw1:aCols[ 2 ]:lBmpTransparent := .t.
oBrw1:aCols[ 2 ]:bStrImage := {|oCol, oLbx70| oBrw1:aRow[ 3 ] }
oBrw1:aCols[ 2 ]:nDataBmpAlign := AL_CENTER
oBrw1:aCols[ 2 ]:bPopUp := { | o | ColMenu( o ) }

oBrw1:aCols[ 3 ]:nWidth := 170
oBrw1:aCols[ 3 ]:nEditType := EDIT_BUTTON
oBrw1:aCols[ 3 ]:bEditBlock := {|nRow, nCol, oCol| oCol:Value := GET_BMP()}

oBrw1:CreateFromCode()


Best Regards
Uwe :-) :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Cell ToolTip
Posted: Thu Jun 30, 2011 01:36 AM

Are you using array to browse?

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Cell ToolTip
Posted: Thu Jun 30, 2011 03:10 AM
Mr Uwe

This is the suggested code:
Code (fw): Select all Collapse
#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 ""

//----------------------------------------------------------------------------//

Code for display of bitmaps can be simplified as above.

Still I advise you not to implement this feature. The results are not accurate.

There is something wrong inside xbrowse code, because of which we are not getting the correct row position in all cases. Let us wait till the problem in xbrowse is resolved.
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse Cell ToolTip
Posted: Thu Jun 30, 2011 09:27 AM
Mr. Rao,

Thank You very much for the Info.
I agree with You. It is better, to show only 100 % working Solutions.

Let us wait till the problem in xbrowse is resolved

In the meantime I found a Solution to display the Fileinfo.
Because the Browser-preview is small, I use Col 4 for the full Fileinfo, but showing only a Button.
Next I use FileNoPath of Col 4, to show after Selection only the Filename in Col 3.



Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: xBrowse Cell ToolTip
Posted: Fri Jan 11, 2013 07:48 AM

Frances/Rao, is this feature running smoothly now?

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: xBrowse Cell ToolTip
Posted: Wed Jan 16, 2013 01:19 AM

Dear Hua,

Im using FWH12.05.. still not ideal.. maybe with newer FW version..

Kind Regards,

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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: xBrowse Cell ToolTip
Posted: Wed Jan 16, 2013 01:47 AM

Thanks for the feedback Frances :)

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion