tsbrowse 7.1

User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

tsbrowse 7.1

Post by fgondi »

Hola foro,

Uso la clase tsbrowse 7.1 y creo que todos conocemos sus problemas de refresco.

Yo en concreto tenía problemas al pintar una única fila y no tener el foco sobre browse, Pintaba la fila vacia.

He realizado cambios en el método lostfocus de la clases tsbrowse para corregir ese problema y ya me funciona perfectamente.

Code: Select all

METHOD LostFocus( hCtlFocus ) CLASS TSBrowse

   Local nRecNo, uTag

   Default ::aControls := {}

   If ::lEditing .and. Len( ::aControls ) > 0 .and. ;
      hCtlFocus == ::aControls[ 1 ]:hWnd

      Return 0

   EndIf

   If ::lEditing

      If ::aColumns[ ::nCell ]:oEdit != Nil
         ::aColumns[ ::nCell ]:oEdit:End()
      EndIf

      ::lEditing := ::lPostEdit := .F.

   EndIf

   ::lNoPaint := .F.

   If ::lDrag
      Return Super:LostFocus( hCtlFocus )
   EndIf

   ::lFocused = .F.

   If ! Empty( ::bLostFocus )
      Eval( ::bLostFocus, hCtlFocus )
   EndIf

   If ::nLen > 0 .and. ! EmptyAlias( ::cAlias ) .and. ! ::lIconView
     ::DrawSelect()
      If ::lIsDbf .and. ( ::cAlias )->( RecNo() ) != ::nLastPos
        ::nLastPos := ( ::cAlias )->( RecNo() )
        ::nLastnAt := ::nAt
        If ::bTagOrder != Nil .and. ! ::lNoResetPos .and. ::bLastTag != Nil
           ::uLastTag := Eval( ::bLastTag )
        EndIf
      EndIf
   EndIf

   If ::oCtx != Nil
      ::oCtx:Save()
   EndIf
   ::lHasFocus := .F.
Return 0
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
User avatar
Baxajaun
Posts: 853
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Post by Baxajaun »

Eskerrik asko !! Muchas gracias !!

Félix
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Post by fgondi »

Hola,

Se que hay mas gente que ha variado la clase, si disponemos de _ mejoraremos la clase entre todos.

Mas cambios que he realizado (aparecen bajo el comentario fgondi)

Code: Select all

METHOD Edit( uVar, nCell, nKey, nKeyFlags, cPicture, bValid, nClrFore, ;
             nClrBack ) CLASS TSBrowse

   Local nRow, nHeight, oFont, cType, uValue, nI, aGet, oCol, cMsg, aRct, ;
         cError, bChange, lSpinner, bUp, bDown, bMin, bMax, nStartX, ;
         nWidth, lCombo, lMulti, nCol, lLogicDrop, nTxtHeight, ;
         nFireKey := ::nFireKey

   Default nCell       := ::nCell, ;
           ::lPostEdit := .F., ;
           ::lNoPaint  := .F.

   oCol := ::aColumns[ nCell ]

   Default ::nHeightSuper := 0, ;
           nKey           := VK_RETURN, ;
           nKeyFlags      := 0, ;
           nFireKey       := VK_F2, ;
           uVar           := Eval( oCol:bData ), ;
           cPicture       := oCol:cPicture, ;
           bValid         := oCol:bValid, ;
           nClrFore       := oCol:nClrEditFore, ;
           nClrBack       := oCol:nClrEditBack

   uValue   := uVar
   cType    := If( Empty( oCol:cDataType ), ValType( uValue ), oCol:cDataType )
   cMsg     := oCol:cMsgEdit
   cError   := oCol:cError
   bChange  := oCol:bChange
   lSpinner := oCol:lSpinner
   bUp      := oCol:bUp
   bDown    := oCol:bDown
   bMin     := oCol:bMin
   bMax     := oCol:bMax
   nStartX  := 0
   lCombo   := lMulti := .F.
   ::oGet   := ::oWnd:bValid
   ::oWnd:bValid := { || ! ::lEditing }

   If oCol:bPassWord != Nil

      If ! Eval( oCol:bPassWord, uValue, nCell, ::nAt, Self )
         Return Nil
      EndIf

   EndIf

   ::lEditing   := .T.
   ::lHitBottom := .F.

   If ::nLen > 0
      ::lNoPaint := .T.
   EndIf

   If oCol:bPrevEdit != Nil
      Eval( oCol:bPrevEdit, uValue, Self )
   EndIf

   cMsg := If( ValType( cMsg ) == "B", Eval( cMsg, Self, nCell ), cMsg )

   If cType == "L" .and. oCol:lCheckBox

      If nKey != VK_RETURN

         If Upper( Chr( nKey ) ) $ "YCST1"
            ::lChanged := uVar == .F.
            uVar := .T.
         ElseIf Upper( Chr( nKey ) ) $ "FN0"
            ::lChanged := uVar == .T.
            uVar := .F.
         ElseIf nKey == VK_SPACE
            uVar := ! uVar
            ::lChanged := .T.
         Else
            Return 0
         EndIf

         ::lHasChanged := If( ::lChanged, .T., ::lHasChanged )
         ::oWnd:nLastKey := VK_RETURN
         ::PostEdit( uVar, nCell, bValid )        //... fgondi. Añadido parametro bValid
         ::lPostEdit := .F.
         Return 0

      Else

         ::lPostEdit := .T.
         ::lChanged := .F.
         ::oWnd:nLastKey := nKey
         ::PostEdit( uVar, nCell, bValid )        //... fgondi. Añadido parametro bValid
         ::lPostEdit := .F.
         Return 0

      EndIf

   EndIf

   If oCol:bExtEdit != Nil  // external edition

      ::lNoPaint := ::lEditing := .F.
      uVar := Eval( oCol:bExtEdit, uValue, Self )
      ::lChanged := ValType( uVar ) != ValType( uValue ) .or. uVar != uValue
      ::lPostEdit := .T.
      ::oWnd:nLastKey := VK_RETURN
      ::PostEdit( uVar, nCell, bValid )
      Return Nil

   EndIf

   oFont := If( oCol:oFontEdit != Nil, oCol:oFontEdit, ;
                If( oCol:oFont != Nil, oCol:oFont, ::oFont ) )

   If oCol:oEdit != Nil
      oCol:oEdit:End()
	Endif

   If ::nFreeze > 0
      For nI := 1 To Min( ::nFreeze , nCell - 1 )
         nStartX += ::GetColSizes()[ nI ]
      Next
   EndIf

   For nI := ::nColPos To nCell - 1
      nStartX += ::GetColSizes()[ nI ]
   Next

   nClrFore := If( ValType( nClrFore ) == "B", ;
                   Eval( nClrFore, ::nAt, nCell, Self ), nClrFore )

   nClrBack := If( ValType( nClrBack ) == "B", ;
                   Eval( nClrBack, ::nAt, nCell, Self ), nClrBack )

   nRow    := ::nRowPos - 1
   nRow    := ( nRow * ::nHeightCell ) + ::nHeightHead + ;
              ::nHeightSuper + If( oCol:l3DLook, 2, 0 )
   nCol    := nStartX + If( oCol:l3DLook, 2, 0 )
   nWidth  := ::GetColSizes()[ nCell ] - If( oCol:l3DLook, 4, 2 )
   nHeight := ::nHeightCell - If( oCol:l3DLook, 3, 1 )


   If oCol:cResName != Nil

      oCol:oEdit := TSBtnGet():New( 0, 0, bSETGET( uValue ), Self, 0, 0, ;
                                 cPicture,, nClrFore, nClrBack, oFont,,,, ;
                                 cMsg,,,,, bChange,,, .T.,, ;
                                 oCol:cResName, oCol:bAction, ;
                                 lSpinner .and. cType $ "ND", bUp, bDown, ;
                                 bMin, bMax, oCol:nBmpWidth )

      oCol:oEdit:Hide()
      oCol:oEdit:nFireKey := nFireKey
      oCol:oEdit:aFill := oCol:aFill
      oCol:oEdit:lFixCaret := ::lFixCaret

   ElseIf ( cType == "C" .and. Chr( 13 ) $ uValue ) .or. cType == "M"

      Default uValue := ""

      If ::nMemoHE == Nil

         If ! Empty( uValue )
            nHeight := Max( 4, StrCharCount( uValue, Chr( 10 ) ) )
         Else
            nHeight := 4
         EndIf

      Else
         nHeight := ::nMemoHE
      EndIf

      aRct := GetClientRect( ::hWnd )

      If ::nMemoWE == Nil .or. Empty( ::nMemoWE )
         nWidth := Max( nWidth, GetTextWidth( 0, SubStr( uValue, 1, ;
                                              At( Chr( 13 ), uValue ) - 1 ), ;
                                              If( oFont != Nil, oFont:hFont, 0 ) ) )
         nWidth := Min( nWidth, Int( aRct[ 4 ] * .8 ) )
      Else
         nWidth := ::nMemoWE
      EndIf

      nTxtHeight := SBGetHeight( ::hWnd, If( oFont != Nil, oFont:hFont, 0 ), 0 )

      While ( nRow + ( nTxtHeight * nHeight ) ) > aRct[ 3 ]
         nRow -= nTxtHeight
      EndDo

      nI := nCol + nWidth - aRct[ 4 ]
      nCol -= If( nI < 0, 0, nI )
      nCol := Max( 10, nCol )
      nHeight *= nTxtHeight

      If SubStr( uValue, 1, 4 ) == GTF5
         oCol:oEdit := TSFGet():New( 0, 0, bSETGET( uValue ), Self, 0, 0, oFont )
         oCol:oEdit:OnResize := {||oCol:oEdit:VScrAdjust()}
      Else
         oCol:oEdit := TSMulti():New( 0, 0, bSETGET( uValue ), Self, 0, 0, ;
                                      oFont,,nClrFore, nClrBack )
         oCol:oEdit:bGotFocus := { || oCol:oEdit:HideSel(), oCol:oEdit:SetPos( 0 ) }
      EndIf

      lMulti := .T.
      oCol:oEdit:Hide()
      SetWindowLong( oCol:oEdit:hWnd, GWL_STYLE, nOr( oCol:oEdit:nStyle, WS_THICKFRAME ) )

   ElseIf ( cType == "L" .and. ::lLogicDrop ) .or. oCol:lComboBox

      lCombo := .T.

      If oCol:lComboBox

         aGet := oCol:aItems

         If Empty( aGet )
            Return Nil
         EndIf

         If nKey == VK_RETURN
            If oCol:cDataType != Nil .and. oCol:cDataType == "N"
               uValue := Max( 1, AScan( aGet, AllTrim( uValue ) ) )
            Else
               uValue := aGet[ Max( 1, AScan( aGet, AllTrim( uValue ) ) ) ]
            EndIf
         Else
            If oCol:cDataType != Nil .and. oCol:cDataType == "N"
               uValue := Max( 1, AScan( aGet, Upper( Chr( nKey ) ) ) )
            Else
               uValue := aGet[ Max( 1, AScan( aGet, Upper( Chr( nKey ) ) ) ) ]
            EndIf
         EndIf

         nHeight := Max( 10, Min( 10, Len( aGet ) ) ) * ::nHeightCell

      Else

         aGet := { ::aMsg[ 1 ], ::aMsg[  2 ] }

         If nKey == VK_RETURN
            uValue := If( uValue, 1,  2 )
         EndIf

         nHeight := ::nHeightCell * 2

      EndIf

      nRow -= 4
      oCol:oEdit := TSCombo():New( 1000, 0, bSETGET( uValue ), aGet, ;
                                   0, 0, Self,,bChange,, nClrFore, ;
                                   nClrBack, .T., oFont, cMsg )

      oCol:oEdit:bCloseUp := {|o|o:PostMsg( WM_KEYDOWN, VK_RETURN, 0 )}
      oCol:oEdit:lAppend := ::lAppendMode
      oCol:oEdit:Hide()

   Else

      oCol:oEdit := TSGet():New( 0, 0, bSETGET( uValue ), Self, 0, 0, ;
                                 cPicture,, nClrFore, nClrBack, oFont,,,, ;
                                 cMsg,,,,, bChange,,, .T.,, ;
                                 lSpinner .and. cType $ "ND", bUp, bDown, ;
                                 bMin, bMax )

      oCol:oEdit:Hide()
      oCol:oEdit:aFill := oCol:aFill
      oCol:oEdit:lFixCaret := ::lFixCaret

   EndIf

   oCol:oEdit:bLostFocus := { | nKey | ::EditExit( nCell, nKey, uValue, ;
                                                  bValid, .T. ) }
   oCol:oEdit:bKeyDown   := { | nKey, nFlags, lExit | ;
                              If( lExit != Nil .and. lExit, ;
                                  ::EditExit( nCell, nKey, uValue, bValid ), ;
                                  Nil ) }

   oCol:oEdit:oJump := Self
   oCol:oEdit:Move( nRow, nCol, nWidth, nHeight, ! lCombo )

   If oCol:cResName != Nil
      oCol:oEdit:Default()
   EndIf

   oCol:oEdit:SetFocus()
   if oCol:oEdit=NIL
     return NIL
   endif

   If nKey != Nil .and. nKey > 31

      If ! lCombo .and. ! lMulti
         oCol:oEdit:lRightLeftExit := .T.
         oCol:oEdit:KeyChar( nKey, nKeyFlags )
      EndIf

   Endif

   oCol:oEdit:Show()
   ::SetMsg( oCol:cMsgEdit )

   If oCol:bEditing != Nil
      Eval( oCol:bEditing, uVar, Self )
   EndIf

Return Nil

Code: Select all

#ifdef __OLE__
METHOD ExcelOle( cXlsFile, lActivate, oMeter, cTitle, ;
                 oFont, lSave ) CLASS TSBrowse

   Local oExcel, oBook, oSheet, nRow, nCol, uData, nEvery, oRange, cRange, cCell, ;
         bError, cText, oClip, nStart, ;
         nLine  := 1, ;
         nCount := 0, ;
         nRecNo := ( ::cAlias )->( RecNo() ), ;
         nAt    := ::nAt

   Default lActivate := Empty( cXlsFile ), ;
           cTitle    := "", ;
           lSave     := .F.

   CursorWait()

   ::lNoPaint := .F.

   If oMeter != Nil
      oMeter:nTotal := ( ::nLen + 1 ) * Len( ::aColumns ) + 30
      oMeter:Set( 0 )
      oMeter:Refresh()
      nEvery := Max( 1, Int( oMeter:nTotal * .02 ) ) // refresh ometer every 2 %
   EndIf

   cXlsFile := AllTrim( StrTran( Upper( cXlsFile ), ".XLS" ) )
   cTitle   := AllTrim( cTitle )
   bError   := ErrorBlock( { | x | Break( x ) } )

   Begin Sequence
      oExcel := TOleAuto():New("Excel.Application")
   Recover
      ErrorBlock( bError )
      CursorArrow()
      MsgStop( "No Ole.lib searched", "Error" )
      Return Nil
   End Sequence

   ErrorBlock( bError )

   If oMeter != Nil
      nCount -= 15
      oMeter:Set( nCount )
   EndIf

   oExcel:WorkBooks:Add()
   oBook  := oExcel:Get( "ActiveWorkBook")
   oSheet := oExcel:Get( "ActiveSheet" )

   If oMeter != Nil
      nCount -= 15
      oMeter:Set( nCount )
   EndIf

   ( ::cAlias )->( Eval( ::bGoTop ) )

   cText := ""

   For nRow := 1 To ::nLen

      If nRow == 1

         If ! Empty( cTitle )
            oSheet:Cells( nLine++, 1 ):Value := AllTrim( cTitle )
            oSheet:Range( "A1:" + Chr( 64 + Len( ::aColumns ) ) + ;
                          "1" ):Set( "HorizontalAlignment", 7 )
            ++nLine
            nStart := nLine
         Else
            nStart := 1
         EndIf

         For nCol := 1 To Len( ::aColumns )
            If ::aColumns[ nCol ]:lBitMap .or. (nCol=1 .and. !Empty(::hBmpCursor))
               Loop
            EndIf
            uData := If( ValType( ::aColumns[ nCol ]:cHeading ) == "B", ;
                         Eval( ::aColumns[ nCol ]:cHeading ), ;
                         ::aColumns[ nCol ]:cHeading )

            If ValType( uData ) != "C"
               Loop
            EndIf

            uData := StrTran( uData, CRLF, ' ' )             // fgondi. Cambio chr(10) por ' '

            cText += uData + Chr( 9 )

            If oMeter != Nil

               If nCount % nEvery == 0
                  oMeter:Set( nCount )
               EndIf

               nCount ++

            EndIf

         Next

         cText += Chr( 13 )

      EndIf

      For nCol := 1 To Len( ::aColumns )

         If ::aColumns[ nCol ]:lBitMap .or. (nCol=1 .and. !Empty(::hBmpCursor))
            Loop
         EndIf

         uData := Eval( ::aColumns[ nCol ]:bData )

         If ValType( uData ) == "C"
            uData := StrTran( uData, CRLF, ' ' )             // fgondi. Cambio chr(10) por ' '
         EndIf

         If ::aColumns[ nCol ]:cPicture != Nil
            uData := Transform( uData, ::aColumns[ nCol ]:cPicture )
         EndIf
         if nRow == 1 .and. ValType( uData )=="C"    // fgondi. Formatear las columnas con texto para poder ver textos como '192492456'
           oRange := cMakeRange( 2, nCol, 65536, nCol )
           oRange := oSheet:Range( oRange )
           oRange:Set("NumberFormat", '@'  )
         endif

         uData  :=  IIF( ValType( uData )=="D", DtoC( uData ), ;
                    IIF( ValType( uData )=="N", Str( uData ) , ;
                    IIF( ValType( uData )=="L", IIF( uData ,".T." ,".F." ), uData  ) ) )

         cText+=alltrim( uData ) + Chr( 9 )

         If oMeter != Nil

            If nCount % nEvery == 0
               oMeter:Set( nCount )
            EndIf

            nCount ++

         EndIf

      Next

      ::Skip( 1 )
      cText += Chr( 13 )

      ++nLine
      /*
         Cada 20k volcamos el texto a la hoja de Excel , usando el portapapeles , algo muy rapido y facil ;-)
         Every 20k set text into excel sheet , using Clipboard , very easy and faster.
      */

      IF Len( cText ) > 20000

         oClip := TClipBoard():New()
         oClip:Clear()
         oClip:SetText( cText )
         cCell := "A" + Alltrim( Str( nStart ) )
         oRange := oSheet:Range( cCell )
         oRange:Select()
         oSheet:Paste()
         oClip:End()
         cText := ""
         nStart := nLine + 1

      EndIf

   Next

   If ::lIsDbf
      ( ::cAlias )->( DbGoTo( nRecNo ) )
   EndIf

   ::nAt := nAt

   If Len( cText ) > 0
      oClip := TClipBoard():New()
      oClip:Clear()
      oClip:SetText( cText )
      cCell := "A" + Alltrim( Str( nStart ) )
      oRange := oSheet:Range( cCell )
      oRange:Select()
      oSheet:Paste()
      oClip:End()
      cText := ""
   EndIf

   cRange := "A3:" + Chr( 64 + Len( ::aColumns ) ) + ;
             Alltrim( Str( oSheet:UsedRange:Rows:Count() ) )
   oRange := oSheet:Range( cRange )

   If oFont != Nil // let the programmer to decide the font he wants, otherwise use Excel's default
      oRange:Font:Name := oFont:cFaceName
      oRange:Font:Size := oFont:nSize()
      oRange:Font:Bold := oFont:lBold
   EndIf

   oRange:Borders():LineStyle := 1
   oRange:Columns:AutoFit()

   If oMeter != Nil
      oMeter:Set( oMeter:nTotal )
   EndIf

   If cXlsFile != Nil .and. lSave
      oBook:SaveAs( cXlsFile, -4143 )   // -4143 = Normal
   EndIf

   oSheet:Range( "A1" ):Select()
   CursorArrow()

   If lActivate
      oExcel:Visible := .T.
   EndIf

   OleUninitialize()

Return Nil

#endif // __OLE__

Code: Select all

METHOD GoLeft()  CLASS TSBrowse

   Local nCell, nSkip, ;
         lLock := ::nFreeze > 0 .and. ::lLockFreeze, ;
         lDraw := .F.

   ::nOldCell := ::nCell

   If ::lIsTxt
      If ::nOffset > 5
         ::nOffset -= 5
      Else
         ::nOffset := 1
      EndIf
      ::Refresh( .F. )

      If ::oHScroll != Nil
         ::oHScroll:SetPos( ::nOffset )
      EndIf
      Return Self
   EndIf

   ::ResetSeek()

   If ::lCellBrw

      nCell := ::nCell
      nSkip := 0

      While nCell > ( If( lLock, ::nFreeze + 1, 1 ) )

         nCell --
         nSkip ++

         If ! ::aColumns[ nCell ]:lNoHilite
            Exit
         EndIf

      EndDo

      If nSkip == 0
         Return Self
      EndIf

      While ::nColPos > ( ::nFreeze + 1 ) .and. ! ::IsColVisible( nCell )
         lDraw := .T.
         ::nColPos --
      EndDo

      ::nCell := nCell

      If lDraw
         ::Refresh( .F. )
      EndIf

                // fgondi. Añadido comprobación  ::nCell<=len(::aColumns)
      If ::nCell<=len(::aColumns) .and. ::aColumns[ ::nCell ]:bGotFocus != Nil .and. ::nOldCell != ::nCell
         Eval( ::aColumns[ ::nCell ]:bGotFocus, ::nOldCell, ::nCell, Self )
      EndIf
                // fgondi. Añadido comprobación  ::nOldCell<=len(::aColumns)
      If ::nOldCell<=len(::aColumns) .and. ::aColumns[ ::nOldCell ]:bLostFocus != Nil .and.;  
         ::nOldCell != ::nCell
        Eval( ::aColumns[ ::nOldCell ]:bLostFocus, ::nCell, ::nOldCell, Self )
      EndIf

      If( ::oHScroll != Nil, ::oHScroll:SetPos( ::nCell ), Nil )
      ::nOldCell := ::nCell
      ::HiliteCell( ::nCell )
      ::DrawSelect()

	Else

      If ::nCell > ( ::nFreeze + 1 )

         ::nColPos := ::nCell := ::nFreeze + 1
         ::Refresh( .F. )

         If ::oHScroll != Nil
            ::oHScroll:GoTop()
         EndIf

      EndIf

   EndIf
Return Self

Code: Select all

METHOD LDblClick( nRowPix, nColPix, nKeyFlags ) CLASS TSBrowse

   Local uTemp, uVal, nBParam, ;
         nLines    := ::nRowCount(), ;
         nClickRow := ::GetTxtRow( nRowPix ), ;
         nCol      := ::nAtCol( nColPix ), ;
         uPar1     := nRowPix, ;
         uPar2     := nColPix, ;
         aMoveCell := { {|| ::GoRight() }, {|| ::GoDown() }, ;
                        {|| ::goLeft() }, {|| ::GoUp() }, ;
                        {|| ::GoNext() } }, ;
         bRecLock  := If( ! Empty( ::bRecLock ), ::bRecLock, ;
                         {|| ( ::cAlias )->( RLock() ) } ), ;
         bAddRec   := If( ! Empty( ::bAddRec ), ::bAddRec, ;
                        {|| ( ::cAlias )->( dbAppend() ), ! NetErr() } )

   If ::lDrag
      Return Super:LDblClick( nRowPix, nColPix, nKeyFlags )
   EndIf

   nBParam := ::aColumns[ nCol ]:nBParam
   ::oWnd:nLastKey := 0
   uPar1 := If( nBParam == 2, TSPoint():New( uPar1, uPar2 ), ;
            If( nBParam == 1, nClickRow, uPar1 ) )
   uPar2 := If( nBParam == 2, TSPoint():New( nClickRow, nCol ), ;
            If( nBParam == 1, nCol, uPar2 ) )


   If ( nClickRow == ::nRowPos .and. nClickRow > 0 ) .or. ;
      ( nClickRow == ::nRowPos .and. ! ::lDrawHeaders )

      If ::lCellBrw .and. ::IsEditable( nCol )

            If ValType( Eval( ::aColumns[ nCol ]:bData ) ) == "L" .and. ;
               ::aColumns[ nCol ]:lCheckBox  // virtual checkbox
               ::PostMsg( WM_CHAR, VK_SPACE, 0 )
            Else
               ::PostMsg( WM_KEYDOWN, VK_RETURN, 0 )
            EndIf

            Return 0

      ElseIf ::lCanSelect

         uVal := If( ::lIsDbf, ( ::cAlias )->( RecNo() ), ::nAt )

         If ( uTemp := AScan( ::aSelected, uVal ) ) > 0

            ADel( ::aSelected, uTemp )
            ASize( ::aSelected, ( Len( ::aSelected ) - 1 ) )
            ::DrawSelect()

            If ::bSelected != Nil
               Eval( ::bSelected, Self, uVal, .F. )
            EndIf

         Else

            AAdd( ::aSelected, uVal )
            ::DrawSelect()

            If ::bSelected != Nil
               Eval( ::bSelected, Self, uVal, .T. )
            EndIf

         EndIf

         If ::bLDblClick != Nil
            Eval( ::bLDblClick, uPar1, uPar2, nKeyFlags )
         EndIf

      ElseIf ::bLDblClick != nil
         Eval( ::bLDblClick, uPar1, uPar2, nKeyFlags )
      EndIf

   ElseIf nClickRow == 0 .and. ::lDrawHeaders
      ::SetOrder( nCol ) // fgondi. ::SetOrder( ::nAtCol( nColPix, .T. ) )   
   EndIf

Return Self
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Post by fgondi »

Hola grupo,

Mas cambios en la tsbrowse 7.1

En mis browse's muestro datos mezclados de varias tablas y bChange siempre me ha dado problemas.

He incluido 2 datas nuevos para ello, bDrawIni y bDrawFin.

Code: Select all

METHOD DrawLine( xRow ) CLASS TSBrowse
local... //definición de las variables
if ::bDrawIni<>NIL
  Eval( ::bDrawIni, Self )
endif
...
if ::bDrawFin<>NIL
  Eval( ::bDrawFin, Self )
endif
return self

Code: Select all

METHOD DrawSelect() CLASS TSBrowse
local... //definición de las variables
if ::bDrawIni<>NIL
  Eval( ::bDrawIni, Self )
endif
...
if ::bDrawFin<>NIL
  Eval( ::bDrawFin, Self )
endif
return Self

Code: Select all

METHOD Edit( uVar, nCell, nKey, nKeyFlags, cPicture, bValid, nClrFore, nClrBack ) CLASS TSBrowse
local... //definición de las variables
if ::bDrawIni<>NIL
  Eval( ::bDrawIni, Self )
endif
...
if ::bDrawFin<>NIL
  Eval( ::bDrawFin, Self )
endif
return 0

Code: Select all

METHOD ExcelOle( cXlsFile, lActivate, oMeter, cTitle, oFont, lSave ) CLASS TSBrowse
...
if ::bDrawIni<>NIL
  Eval( ::bDrawIni, Self )
endif
uData := Eval( ::aColumns[ nCol ]:bData )
if ::bDrawFin<>NIL
  Eval( ::bDrawFin, Self )
endif
....
return nil
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
daniel
Posts: 6
Joined: Fri Oct 21, 2005 10:03 pm
Location: El Salvador
Contact:

Post by daniel »

Hola, serias tan amable de poner el archivo fuente, no pude hacerlo funcionar
Gracias por tu acto de buena fe
FWH 2.4 xHarbour 99.3 Compatible con FWH 2.4 de PuertoSur
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Post by fgondi »

Hola,

Aqui tienes toda la tsbrowse 7.1 con _ que he realizado.

http://www.ghe-soft.com/fivewin/tsbrowse.rar
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
daniel
Posts: 6
Joined: Fri Oct 21, 2005 10:03 pm
Location: El Salvador
Contact:

Post by daniel »

Gracias, sabes esta EXCELENTE :P :P
FWH 2.4 xHarbour 99.3 Compatible con FWH 2.4 de PuertoSur
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Post by fgondi »

Hola Daniel.

de nada y gracias a ti por usarlo.
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
User avatar
AngelSalom
Posts: 664
Joined: Fri Oct 07, 2005 7:38 am
Location: Vinaros (Castellón ) - España
Contact:

Post by AngelSalom »

A proposito de tsbrowse.
Habeis observado que si se muestra un browse que no está lleno de datos (es decir que todos los registros que hay se muestran en pantalla) al hacer Ctrl+AvPag para ir al final del browse, este se vuelve tarumba?
En cambio si hay más registros de los que caben en pantalla, realiza el proceso perfectamente?

Habeis encontrado solución para eso?
Yo probe a poner :

Case GetKeyState( VK_CONTROL )

If nKey == VK_HOME // Ctrl+Home
::GoTop()
::PanHome()
ElseIf nKey == VK_END // Ctrl+End
If ::lHitBottom
::PanEnd()
Else
::GoBottom()
::Reset()
EndIf
ElseIf nKey == VK_PRIOR // Ctrl+PgUp
::GoTop()
ElseIf nKey == VK_NEXT // Ctrl+PgDn
::GoBottom()
::Reset() // Sigev

ElseIf nKey == VK_LEFT // Ctrl+Left
::PanLeft()
ElseIf nKey == VK_RIGHT // Ctrl+Right
::PanRight()
Else
Super:KeyDown( nKey, nFlags )
EndIf

... un reset() despues del gobottom y entonces si que pinta, pero el efecto pierde mucho ya que solo muestra en pantalla la última línea.

Gracias.
Angel Salom
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Post by fgondi »

Hola Angel,

El problema viene porque no dectecta correctamente el final de browse si este no cubre toda la presentación.

Tambien se soluciona en la definición de los codeblock ::bGoTop y ::bGoBottom. Que si son definidos si usas oDbf, aArray, TxtFile

Yo las asigno valor en el método ResetBarPos()

Code: Select all

::bGoTop    := {|| ( ::cAlias )->( DbGoTop() ) }
::bGoBottom := {|| ( ::cAlias )->( DbGoBottom() ) }
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
carlosmora
Posts: 16
Joined: Thu Dec 01, 2005 4:15 pm

Post by carlosmora »

Me he bajado la version que tan amablemente posteaste, pero continúa el problema de refresco cuando no hay suficientes registros.
Alguien ha resuleto el problema?
Saludos.
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Post by fgondi »

Hola,

El refresco en la versión 7.1 cambia a las versiones anteriores
Ahora hay que realizar lo siguiente:

Code: Select all

oBrw:ResetBarPos() 
  // Actualiza cuantos registros tienen que mostrar para scroll, ctrl-Inicio, etc
oBrw:UpStable()    
  // Posiciona el puntero al principio y estabiliza el browse con los nuevos datos
oBrw:Reset()          
  // Quita los posibles filtros aplicados y si no tienes inicializa los valores con los nuevos datos
oBrw:Refresh()       
  // Repinta los datos correctamente, porque conoce ya los límites que tienen que alcanzar
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
User avatar
AngelSalom
Posts: 664
Joined: Fri Oct 07, 2005 7:38 am
Location: Vinaros (Castellón ) - España
Contact:

Post by AngelSalom »

Después de mucho probar y rodar al final he descubierto que cuando el tsbrowse trabaja mal en los repintados es cuando de pocos registros es cuando la base de datos tiene registros borrados (no físicamente, sino marcados). Por lo visto tiene en cuenta estos registros para el cálculo de la posición seleccionada y es cuando se vuelve tarumba.
He probado con una base de datos recíén compactada y va perfecto.

Alguien sabe como se puede arreglar esto?
graciasss
Angel Salom
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
fsandoval
Posts: 71
Joined: Mon Oct 10, 2005 9:24 pm
Location: aguascalientes

al ligar la aplicacion marca este error _HB_FUN_CMAKERANGE

Post by fsandoval »

Hola FGONDI , he generado el tsbrowse un excelenete trabajo apliado por ti pero al ligar mi aplicacion me marca este error y no le entrado la funcion por ningun rango.


saludos.
fernando sandoval ruiz
fernando sandoval ruiz
fsandoval@hotmail.com
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Post by fgondi »

Hola tocayo,

Esa función aparace en la clase TExcelScript del maestro Vikthor

Code: Select all

FUNCTION cMakeRange( nRowIni, nColIni, nRowFin, nColFin )
local cRange := cColumn2Letter(nColIni) + AllTrim(Str(Int(nRowIni)))

if nRowFin != NIL .and. nColFin != NIL
  cRange  += ":" + cColumn2Letter(nColFin) + AllTrim(Str(Int(nRowFin)))
endif
RETURN cRange


FUNCTION cColumn2Letter( n )
local r := ""

if n > 26
  r := Chr( 64 + Int( n / 26 ) )
  n := n % 26
endif
r += Chr( 64 + n )
RETURN r
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
Post Reply