//-----------------------------------------------------//
Function CeldaTransparente(oBrw2)
local n1, n, uVal
For n1 := 1 to oBrw2:nLen
For n := 1 to len(oBrw2:aCols)
uVal := oBrw2:aCols[n]:Value
if Empty(uVal) .or. uVal = nil
oBrw2:aCols[n]:lColTransparent := .t.
endif
Next
Next
oBrw2:Refresh()
Return nil
//-----------------------------------------------------//
Function CeldaTransparente(oBrw2)
local n1, n
For n1 := 1 to oBrw2:nLen
For n := 1 to len(oBrw2:aCols)
oBrw2:aCols[n]:lColTransparent := TranspDeCelda( oBrw2, n )
Next
oBrw2:GoDown()
Next
Return nil
//-----------------------------------------------------//
function TranspDeCelda( oBrw, n )
local uDato := oBrw:aRow[n], lTransparent := .f.
if Empty(uDato) .or. uDato = nil
lTransparent := .t.
endif
return lTransparent
//Celdas sin valor serán transparentes. Para ello, oBrw2:lTransparent := .t., y ClrBck de celda debe ser NIL
//-----------------------------------------------------//
Function CeldaTransparente(oBrw2)
local n
For n := 1 to oBrw2:nLen
AEval( oBrw2:aCols, { |o|o:lColTransparent := if(Empty(o:Value),.t.,.f.) } )
oBrw2:GoDown()
Next
Return nil
FranciscoA wrote:Parece que encontré la solución:
- Code: Select all Expand view RUN
//Celdas sin valor serán transparentes. Para ello, oBrw2:lTransparent := .t., y ClrBck de celda debe ser NIL
//-----------------------------------------------------//
Function CeldaTransparente(oBrw2)
local n
For n := 1 to oBrw2:nLen
AEval( oBrw2:aCols, { |o|o:lColTransparent := if(Empty(o:Value),.t.,.f.) } )
oBrw2:GoDown()
Next
Return nil
Saludos.
oCol:lTransparent applies to the entire column, not to individual cells
#include "fivewin.ch"
static aM, aR, cClr := ""
static oBrw1, oBrw2
//----------------------------------------------------------------------------//
function Main()
local oDlg, oFont1
local oBrush, cBrush := "C:\FWH1204\BITMAPS\BACKGRND\BEACH.BMP"
local nWd := 240
local nHt := 600
CreaMatrices()
DEFINE FONT oFont1 NAME "CONSOLAS" SIZE 0,-16 BOLD ITALIC
DEFINE DIALOG oDlg SIZE nWd,nHt PIXEL TRUEPIXEL
DEFINE BRUSH oBrush FILE cBrush RESIZE
oDlg:SetBrush( oBrush )
oBrush:End()
PintaBrowse(oDlg)
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT CeldaTransparente(oBrw2)
RELEASE oFont1
RELEASE BRUSH oBrush
return nil
//----------------------------------------------------------------------------//
Function CreaMatrices()
local n, aNms, aClr
aNms := {'00', '27', '10', '25', '29', '12', '8', '19', '31', '18', '6', '21', '33', '16', '4', '23', '35', '14', '2', '0', '28', '9', '26', '30', '11', '7', '20', '32', '17', '5', '22', '34', '15', '3', '24', '36', '13', '1'}
aClr := { 'V', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'V', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R'}
aR := {}
For n := 1 to Len(aNms)
aadd( aR, {,,,} )
aR[n,1] := n //Posicion
aR[n,2] := if(len(aNms[n])=1, aNms[n]+" ", aNms[n]) //Numero (debe ser long 2 char)
aR[n,3] := if(upper(aClr[n]) ="V","VERDE" ,; //Color
if(upper(aClr[n]) ="R","ROJO" ,;
if(upper(aClr[n]) ="N","NEGRO",)))
Next
aM := Array(13)
aM[1] := {'0 ', '00', ' '}
aM[2] := {' ', '2 ', '3 '}
aM[3] := {' ', '5 ', '6 '}
aM[4] := {'7 ', ' ', ' '}
aM[5] := {'10', '11', '12'}
aM[6] := {' ', ' ', ' '}
aM[7] := {'16', '17', '18'}
aM[8] := {' ', '20', '21'}
aM[9] := {' ', '23', '24'}
aM[10]:= {'25', '26', '27'}
aM[11]:= {'28', '29', '30'}
aM[12]:= {'31', ' ', '33'}
aM[13]:= {'34', '35', '36'}
Return nil
//----------------------------------------------------------------------------//
Function PintaBrowse(oDlg)
local n, cCol, oFont
DEFINE FONT oFont NAME "ARIAL" SIZE 0,-24 BOLD ITALIC
@ 1,1 XBROWSE oBrw2 SIZE -1,-1 PIXEL OF oDlg DATASOURCE aM ;
COLUMNS 1,2,3 HEADERS "Col1","Col2","Col3" ;
CELL LINES NOBORDER
FOR EACH cCol IN {"COL1", "COL2", "COL3"}
WITH OBJECT oBrw2:oCol( cCol )
:nWidth := (oBrw2:nWidth/3)-1
END
NEXT
WITH OBJECT oBrw2
:nMarqueeStyle := 0
:nRowHeight := 42
:lHeader := .f.
:lFooter := .f.
:lHScroll := .f.
:lVScroll := .f.
:lRecordSelector := .f.
:nDataStrAligns := AL_CENTER
:SetFont(oFont)
:lTransparent := .t.
:CreateFromCode()
END
ColorFondoCelda(oBrw2)
RELEASE oFont
Return nil
//-----------------------------------------------------//
Function ColorFondoCelda(oBrw2)
local n
For n := 1 to len(oBrw2:aCols)
oBrw2:aCols[n]:bClrStd := ColorDeCelda( oBrw2, n )
Next
Return nil
//-----------------------------------------------------//
function ColorDeCelda( oBrw, n )
return {|| ElijeColor( oBrw:aRow[ n ] ) }
//-----------------------------------------------------//
function ElijeColor( uDato )
local n, nClrBck, nClrTxt := RGB(255,255,255)
cClr:=""
for n := 1 to len(aR)
if aR[n,2] == uDato
cClr := aR[n,3]
exit
endif
Next
if cClr == "VERDE"
nClrBck := RGB(0, 200, 0)
elseif cClr == "ROJO"
nClrBck := RGB(225, 0, 0)
elseif cClr == "NEGRO"
nClrBck := RGB(0, 0, 0)
else
nClrBck := NIL
endif
return { nClrTxt, nClrBck }
//Celdas sin valor serán transparentes. Para ello, oBrw2:lTransparent := .t., y ClrBck de celda debe ser NIL
//-----------------------------------------------------//
Function CeldaTransparente(oBrw2)
local n
For n := 1 to oBrw2:nLen
AEval( oBrw2:aCols, { |o|o:lColTransparent := if(Empty(o:Value),.t.,.f.) } )
oBrw2:GoDown()
Next
Return nil
FranciscoA wrote:He notado que si en la ultima fila hay celda sin valor, pone transparente toda esa columna.
#include "fivewin.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oFont1, oBrw2, n, cCol, oFont
local oBrush, cBrush := "C:\FWH1204\BITMAPS\BACKGRND\BEACH.BMP"
local nWd := 240, nHt := 600
local aArr := CreaMatrices(), aR := aArr[1], aM := aArr[2]
DEFINE FONT oFont NAME "ARIAL" SIZE 0,-24 BOLD ITALIC
DEFINE FONT oFont1 NAME "CONSOLAS" SIZE 0,-16 BOLD ITALIC
DEFINE DIALOG oDlg SIZE nWd,nHt PIXEL TRUEPIXEL
DEFINE BRUSH oBrush FILE cBrush RESIZE
oDlg:SetBrush( oBrush )
oBrush:End()
@ 1,1 XBROWSE oBrw2 SIZE -1,-1 PIXEL OF oDlg DATASOURCE aM ;
COLUMNS 1,2,3 HEADERS "Col1","Col2","Col3" ;
CELL LINES NOBORDER
FOR EACH cCol IN {"COL1", "COL2", "COL3"}
WITH OBJECT oBrw2:oCol( cCol )
:nWidth := (oBrw2:nWidth/3)-1
END
NEXT
WITH OBJECT oBrw2
:nMarqueeStyle := 0
:nRowHeight := 42
:lHeader := .f.
:lFooter := .f.
:lHScroll := .f.
:lVScroll := .f.
:lRecordSelector := .f.
:nDataStrAligns := AL_CENTER
:SetFont(oFont)
:lTransparent := .t.
:CreateFromCode()
END
ColorFondoCelda(oBrw2, aR)
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( CeldaTransparente(oBrw2) )
RELEASE oFont1, oFont
RELEASE BRUSH oBrush
return nil
//----------------------------------------------------------------------------//
Function CreaMatrices()
local n, aNms, aClr, aR, aM
aNms := {'00', '27', '10', '25', '29', '12', '8', '19', '31', '18', '6', '21', '33', '16', '4', '23', '35', '14', '2', '0', '28', '9', '26', '30', '11', '7', '20', '32', '17', '5', '22', '34', '15', '3', '24', '36', '13', '1'}
aClr := { 'V', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'V', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R'}
aR := {}
For n := 1 to Len(aNms)
aadd( aR, {,,,} )
aR[n,1] := n //Posicion
aR[n,2] := if(len(aNms[n])=1, aNms[n]+" ", aNms[n]) //Numero (debe ser long 2 char)
aR[n,3] := if(upper(aClr[n]) ="V","VERDE" ,; //Color
if(upper(aClr[n]) ="R","ROJO" ,;
if(upper(aClr[n]) ="N","NEGRO",)))
Next
aM := Array(14)
aM[1] := {'Rojo', 'Negro', 'Verde'}
aM[2] := {'0 ', '00', ' '}
aM[3] := {' ', '2 ', '3 '}
aM[4] := {' ', '5 ', '6 '}
aM[5] := {'7 ', ' ', ' '}
aM[6] := {'10', '11', '12'}
aM[7] := {' ', ' ', ' '}
aM[8] := {'16', '17', '18'}
aM[9] := {' ', '20', '21'}
aM[10]:= {' ', '23', '24'}
aM[11]:= {'25', '26', '27'}
aM[12]:= {'28', '29', '30'}
aM[13]:= {'31', ' ', '33'}
aM[14]:= {' ', ' ', '36'}
Return { aR, aM }
//-----------------------------------------------------//
Function ColorFondoCelda(oBrw2, aR)
local n
For n := 1 to len(oBrw2:aCols)
oBrw2:aCols[n]:bClrStd := ColorDeCelda( oBrw2, n, aR )
Next
Return nil
//-----------------------------------------------------//
function ColorDeCelda( oBrw, n, aR )
return {|| ElijeColor( oBrw:aRow[ n ], aR ) }
//-----------------------------------------------------//
function ElijeColor( uDato, aR )
local n, nClrBck, nClrTxt := RGB(255,255,255), cClr
cClr:=""
for n := 1 to len(aR)
if aR[n,2] == uDato
cClr := aR[n,3]
exit
endif
Next
if cClr == "VERDE" .or. uDato == "Verde" //Si dato es Verde,Rojo,Negro, es apuesta por color.
nClrBck := RGB(0, 200, 0)
elseif cClr == "ROJO" .or. uDato == "Rojo"
nClrBck := RGB(225, 0, 0)
elseif cClr == "NEGRO" .or. uDato == "Negro"
nClrBck := RGB(0, 0, 0)
else
nClrBck := NIL //GetSysColor( 5 )
endif
return { nClrTxt, nClrBck }
//Celdas sin valor serán transparentes. Para ello, oBrw2:lTransparent := .t., y ClrBck de celda debe ser NIL
//-----------------------------------------------------//
Function CeldaTransparente(oBrw2)
local n
For n := 1 to len(oBrw2:aCols)
oBrw2:aCols[n]:lColTransparent := if(Empty(oBrw2:aCols[n]:Value),.t.,.f.)
Next
Return nil
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 45 guests