Tengo un pequeño programa de muestra. Así básicamente uso la xBrowe con la TDatabase:
- Code: Select all Expand view
- #INCLUDE "FIVEWIN.Ch"
#include "xbrowse.ch"
#define renglon chr(13) + chr(10)
//----------------------------------------------------------------------------//
Function HojearService()
local oBrw , oLbx , lSalir:=.f. , oDbf , oDlg , nAregi , oCol , oRichService , cRichService , oBrush , oFont
local cService:=cGetNewAlias('Servic') , oBtnAgregar , oBtnGuardar , oBtnBorrar , oBtnSalir , oCur1 , nRecno ,;
oBtnProveedor , oBtnFalta , oBtnVAP , oBtnPrint , oBrush2 , oBtnTop , oBtnBot , nOrden , oBtnBorrado ,;
cBuscar:="" , oBtnBuscar , oBtnBuscaSele , aDBF:={} , cDato , oClp , cText , Clp , oSayStockNO , oFont2
local nRecnoInicial:=1 , aArrayPaso , lcBusco:=.f. , nColSele:=0
REQUEST HB_LANG_ES
RddSetDefault("DBFCDX")
REQUEST ordkeyno, ordkeycount, ordkeygoto
REQUEST DBFCDX, DBFFPT
use "customer" shared new alias (cService)
DATABASE oDbf
oDbf:SetOrder( 3, "customer.CDX" ) // ordeno por APARATO
nRecnoInicial:=oDbf:RECNO()
#define fondo1 nrgb(255,255,0)
define font oFont NAME "Arial" SIZE 6,16 bold
define font oFont1 NAME "Arial" SIZE 25,45 bold
define font oFont2 NAME "Arial" SIZE 15,35 bold
define cursor oCur1 resource 222
define brush oBrush resource "BEIGE2"
define brush oBrush2 resource "fondo9" // "azul"
define dialog oDlg resource "SERVICE"
oDlg:lHelpIcon := .f.
oDlg:cTitle:="LISTANDO CUSTOMER FWH1307"
oBrw := TXBrowse():New( oDlg )
oBrw:nHeaderLines := 1
oBrw:lFastEdit := .f.
oBrw:SetoDbf( oDbf )
oBrw:SetBackGround(oBrush2)
oBrw:setfont(oFont)
oBrw:lContrastClr := .f. // para evitar que los caracteres salgan aleatoriamente con otra tinta
oBrw:bClrSel := {|| { nRGB( 255, 255,255), nRGB(144,196,205) } } // para barra de linea selecc cuando el control no tiene el foco
oBrw:oCursor:=oCur1
oBrw:nHeaderHeight:=21.90
oBrw:bGotFocus:={||dbSelectArea(cService) }
oCol := oBrw:AddCol()
oCol:cHeader := "NOMBRE"
oCol:bStrData := { || oDbf:FIRST }
oCol:nHeadStrAlign := AL_CENTER
oCol:nDataStrAlign := AL_LEFT
oCol:nWidth := 130
oCol:cSortOrder := "FIRST"
oBrw:aCols[ 1 ]:nEditType := EDIT_GET
oBrw:aCols[ 1 ]:bOnPostEdit := {|oCol, xVal, nKey| iif( nKey != VK_ESCAPE, ;
(oDbf:FIRST:=upper(xVal) , oDbf:save() , oBrw:refresh() ) , ) }
oBrw:aCols[1]:cEditPicture := "@!"
oBrw:aCols[1]:cTooltip:="Clickear una vez con el izquierdo para ordenar por NOMBRE"
//-----------------------------------------//
oCol := oBrw:AddCol()
oCol:cHeader := "APELLIDO"
oCol:bStrData := { || oDbf:LAST }
oCol:nHeadStrAlign := AL_CENTER
oCol:nDataStrAlign := AL_LEFT
oCol:nWidth := 160
oCol:cSortOrder := "LAST"
oBrw:aCols[ 2 ]:nEditType := EDIT_GET
oBrw:aCols[ 2 ]:bOnPostEdit := {|oCol, xVal, nKey| iif( nKey != VK_ESCAPE, ;
(oDbf:LAST:=xVal , oDbf:save() , oBrw:refresh() ) , ) }
oBrw:aCols[2]:cEditPicture := "@!"
oBrw:aCols[2]:cTooltip:="Clickear una vez con el izquierdo para ordenar por APELLIDO"
//-----------------------------------------//
//-----------------------------------------//
oCol := oBrw:AddCol()
oCol:cHeader := "CALLE"
oCol:bStrData := { || oDbf:STREET }
oCol:nHeadStrAlign := AL_CENTER
oCol:nDataStrAlign := AL_LEFT
oCol:nWidth := 230
oCol:cSortOrder := "STREET"
oBrw:aCols[ 3 ]:nEditType := EDIT_GET
oBrw:aCols[ 3 ]:bOnPostEdit := {|oCol, xVal, nKey| iif( nKey != VK_ESCAPE, ;
(oDbf:STREET:=xVal , oDbf:save() , oBrw:refresh() ) , ) }
oBrw:aCols[3]:cEditPicture := "@!"
oBrw:aCols[3]:cTooltip:="Clickear una vez con el izquierdo para ordenar por CALLE"
//-----------------------------------------//
oBrw:nStretchCol:=STRETCHCOL_LAST
oBrw:nRowHeight:=20.90 // alto de linea, variarlo para dejar que encaje casi casi en el listbox
oBrw:nRowDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:nColDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL //MARQSTYLE_HIGHLROW
oBrw:lHScroll:=.t.
oBrw:lAllowRowSizing := .F. // no permite que agrande las líneas
oBrw:bClrSel:={||{nRGB(255,255,255), nRGB(144,196,205)}}
oBrw:CreateFromResource( 4001 )
oDlg:bPainted:={ ||dbSelectArea(cService) }
oDlg:bStart:={|| oDlg:setfocus() }
ACTIVATE DIALOG oDlg on init (oDbf:GOTO(nRecnoInicial));
valid (oDbf:close() , .t.)
oFont:end()
oFont1:end()
oFont2:end()
oBrush:end()
return nil
Siempre compiló y funcionó bien, pero ahora con la versión 1307 hace un problema que puede verse en la imagen que adjunto y es que agrega una columna vacía al xBrowse con el dato "EMPTY COL". Obviamente que busqué en la clase y tiene bastante reforma para esto pero se me ocurre que ESTOY HACIENDO ALGO MAL Y DEBIERA USAR LA XBROWSE DE OTRA MANERA Y DE AHÍ VENGA LA FALLA.
También subí un video en el que puede verse el mismo prg compilado con la 1302 y después compilado con la 1307. Con la 1302 no presenta falla, ordena al presionar sobre cabeceras y NO AGREGA UNA COLUMNA.
Luego puede verse el mismo PRG pero compilado con la 1307 y ahí el problema.
http://youtu.be/v5GRh4FGxdE
¿Alguna ayuda?. Gracias.
Rolando