TO NAGES : ALSO ON ARRAY XBROWSE AND TOOLTIP

Post Reply
User avatar
MdaSolution
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

TO NAGES : ALSO ON ARRAY XBROWSE AND TOOLTIP

Post by MdaSolution »

nageswaragunupudi wrote:Is what is wanted something like this?
Image

Logic to load data into array is very simple, as can be seen from the LoadData() function given below. (Length of array in each row is different. But Xbrowse can handle that.)

Even coding of xbrowse can be much shorter.

Code: Select all

#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

#define NUM_TABLES  3

function Main()

   RDDSetDefault( 'DBFCDX' )
   CreateDBF()  // Create Sample Data
   ShowTables(  LoadData() )

return nil

static function LoadData()

   local i, n, aRes  := Array( NUM_TABLES, 0 )
   local dMonth      := AddMonth( BOY( DATE() ), 2 ) //  1st March

   for n := 1 to 7
      for i := 1 to NUM_TABLES
         AAdd( aRes[ i ], Array( LastDayOM( dMonth ) + 1 ) )
         AFill( aRes[ i ][ -1 ], .f. )
         aRes[ i ][ -1 ][ 1 ]   := cMonth( dMonth )
      next i
      dMonth      := AddMonth( dMonth, 1 )
   next n

   USE RESERVATION

   do while ! Eof()
      for n := FIELD->DATAIN to FIELD->DATAFIN
         aRes[ FIELD->NUMTABLE ][ Month( n ) - 2 ][ Day( n ) + 1 ] := .t.
      next
      SKIP
   enddo

   CLOSE RESERVATION

return aRes

static function ShowTables( aRes )

   local oTabs, aTabs   := {}
   local oDlg, oBrw, oCol, n


   DEFINE DIALOG oDlg SIZE 960,200 PIXEL
   @ 05,05 XBROWSE oBrw SIZE 470, 80 PIXEL OF oDlg ;
      ARRAY aRes[ 1 ] AUTOCOLS LINES CELL NOBORDER

   oBrw:aCols[ 1 ]:cHeader    := 'Month'
   for n := 2 to 32
      WITH OBJECT oBrw:aCols[ n ]
         :cHeader    := LTrim( Str( n - 1 ) )
         :SetCheck( { 'c:\fwh\bitmaps\level1.bmp', 'c:\fwh\bitmaps\level2.bmp' } )
      END
   next

   WITH OBJECT oBrw
      :lHScroll      := :lVScroll := .f.
      :nStretchCol   := 1
      :nFreeze       := 1
   END

   oBrw:CreateFromCode()

   for n := 1 to NUM_TABLES
      AAdd( aTabs, 'Table-' + LTrim( Str( n ) ) )
   next

   @ 85, 05 TABS oTabs OF oDlg SIZE oBrw:nWidth, 17 PIXEL
   WITH OBJECT oTabs
      :aPrompts      := aTabs
      :bAction       := { | n  | oBrw:aArrayData := aRes[ n ], oBrw:Refresh() }
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil

//-------------------------- CREATION OF SAMPLE DATA -----------//

function CreateDBF()

   FIELD NUMTABLE

   local n, dStart
   local aCols := {  { 'NUMTABLE', 'N', 2, 0 }, ;
                     { 'DATAIN'  , 'D', 8, 0 }, ;
                     { 'DATAFIN' , 'D', 8, 0 }  }

   DbCreate( 'RESERVATION', aCols )

   USE RESERVATION
   INDEX ON NUMTABLE TAG NUMTABLE

   dStart   := AddMonth( BOY( Date() ), 2 ) // 1st March
   for n := 1 to 100 * NUM_TABLES
      APPEND BLANK
      FIELD->NUMTABLE      := HB_RandomInt( 1, NUM_TABLES )
      FIELD->DATAIN        := dStart + HB_RandomInt( 0, 200 )
      FIELD->DATAFIN       := FIELD->DATAIN + HB_RandomInt( 0, 5 )
   next n

   CLOSE RESERVATION

return nil
 
This is a self contained program that can complied and executed independently. The program creates a sample DBF.
The logic can be adopted to the actual requirements.

I have used xHarbour with FWH 10.1. CT.LIB of xHarbour needs to be linked for the date functions.




Nages ,
to insert a tooltip to each column as " August 6 2011" how I can make


:bToolTip := { | oBrw, nRow, nCol, nFlags | MyToolTip( oBrw, nRow, nCol, nFlags) }



Function MyToolTip( oBrw, nRow, nCol, nFlags,aRes)


local nMouseRow := oBrw:MouseRowPos( nRow )

if nMouseRow > 0
return oBrw:aArrayData[ oBrw:nArrayAt - oBrw:nRowSel + nMouseRow ]
endif

return ""

But i see only the mouth how I can make to have day,mouth and year ?

I need to know it to make an research on archive and see wich customer have the reservation of table
FWH .. BC582.. xharbour
User avatar
MdaSolution
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: TO NAGES : ALSO ON ARRAY XBROWSE AND TOOLTIP

Post by MdaSolution »

any solution ?
FWH .. BC582.. xharbour
hmpaquito
Posts: 1200
Joined: Thu Oct 30, 2008 2:37 pm

Re: TO NAGES : ALSO ON ARRAY XBROWSE AND TOOLTIP

Post by hmpaquito »

Mr. Mda,

Without testing

Code: Select all

Function MyToolTip( oBrw, nRow, nCol, nFlags,aRes)


local nMouseRow := oBrw:MouseRowPos( nRow )

Local nMouseCol:= oBrw:MosecolPos( nCol )
Local cDay, cMonth
Local cYear:= LTrim(Str(Year(Date()), 4))
Local cDate:= ""

if nMouseRow > 0
   IF nCol > 1
      cDay:=     oBrw:aCols[ nMouseCol ]:cHeader
   ENDIF
   cMonth:= oBrw:aArrayData[ oBrw:nArrayAt - oBrw:nRowSel + nMouseRow ]
   cDate:= cMonth+ "/"+ If(!Empty(cDay)+ cDay+ "/", "")+ cYear 
endif

return cDate



 
Regards
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TO NAGES : ALSO ON ARRAY XBROWSE AND TOOLTIP

Post by nageswaragunupudi »

Above code seems to be right.

But cell tooltips are not working satisfactorily and I do not advise using them. The user may get wrong results. Please see this post
http://forums.fivetechsupport.com/viewt ... tip#p96466
Regards

G. N. Rao.
Hyderabad, India
User avatar
MdaSolution
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: TO NAGES : ALSO ON ARRAY XBROWSE AND TOOLTIP

Post by MdaSolution »

hmpaquito wrote:Mr. Mda,

Without testing

Code: Select all

Function MyToolTip( oBrw, nRow, nCol, nFlags,aRes)


local nMouseRow := oBrw:MouseRowPos( nRow )

Local nMouseCol:= oBrw:MosecolPos( nCol )
Local cDay, cMonth
Local cYear:= LTrim(Str(Year(Date()), 4))
Local cDate:= ""

if nMouseRow > 0
   IF nCol > 1
      cDay:=     oBrw:aCols[ nMouseCol ]:cHeader
   ENDIF
   cMonth:= oBrw:aArrayData[ oBrw:nArrayAt - oBrw:nRowSel + nMouseRow ]
   cDate:= cMonth+ "/"+ If(!Empty(cDay)+ cDay+ "/", "")+ cYear 
endif

return cDate



 
Regards


make error !!!
FWH .. BC582.. xharbour
Post Reply