Help for lgetbar on a dialog one field
Posted: Thu Nov 05, 2020 12:43 pm
I take the sample xbgetbar.prg of fwh
I need to show one Column ( 3th field), a buttonbar on dialog
When I call lgetbar I can insert only 3 cr on get and the the set filter not run ok ,also cleaR filter
I tried with customer one field (First) and I have this error
the code
the error
I need to show one Column ( 3th field), a buttonbar on dialog
When I call lgetbar I can insert only 3 cr on get and the the set filter not run ok ,also cleaR filter
Code: Select all
#include "fivewin.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
SET DATE ITALIAN
SET CENTURY ON
SET DELETED ON
RDDSETDEFAULT( "DBFCDX" )
SetGetColorFocus()
Sample2()
return nil
//----------------------------------------------------------------------------//
Function Sample2()
local oDlg, oBrowse,oBar, oFont, oBold
local n
local oBtnTab[3]
local oCursorBtn :=TCursor():New(,'HAND')
USE REPORT NEW ALIAS RP SHARED
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg SIZE 800,500 PIXEL TRUEPIXEL ;
FONT oFont TITLE "test table"
DEFINE BUTTONBAR oBar OF oDlg SIZE 64,80 2013
DEFINE BUTTON OF oBar PROMPT "Nuovo" FILE "MOD_NUOVO" ACTION NIL
DEFINE BUTTON OF oBar PROMPT "Modifica" FILE "MOD_MODIFICA" ACTION NIL
DEFINE BUTTON OF oBar PROMPT "Cancella" FILE "MOD_CANCELLA" ACTION NIL
DEFINE BUTTON OF oBar PROMPT "Duplica" FILE "MOD_DUPLICA" ACTION NIL
DEFINE BUTTON OF oBar PROMPT "Stampa" FILE "MOD_STAMPA" ACTION NIL
@ 60, 5 XBROWSE oBrowse OF oDlg ;
SIZE -5,200 PIXEL NOBORDER FONT oFont
oCol := oBrowse:AddCol()
oCol:bStrData := { || RP->DESC }
oCol:cHeader := i18n("Descrizione")
oCol:nWidth := 250
// Relevant Code
for n := 1 to Len( oBrowse:aCols )
WITH OBJECT oBrowse:aCols[ n ]
if FieldType( n ) != 'L'
:uBarGetVal := uValBlank( fieldGet( n ) )
if FieldType( n ) == 'N'
:cBarGetPic := NumPict( FieldLen( n ), FieldDec( n ) )
endif
endif
END
next
oBrowse:lGetBar := .f.
// End of Relevant Code
WITH OBJECT oBrowse
:nHeaderHeight := 40 // optional
:oHeaderFonts := oBold
:bClrEdits := { || { CLR_BLACK, CLR_YELLOW } }
:nStretchCol := -1
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS//MARQSTYLE_NOMARQUEE
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:lColDividerComplete := .t.
:lRecordSelector := .t.
:lHScroll := .f.
:lDrawBorder := .t.
:CreateFromCode()
END
@ 60, 20 BTNBMP oBtnTab[1] PROMPT { || If( oBrowse:lGetBar, "Hide GetBar", "ShowGetBar" ) } ;
SIZE 90,28 PIXEL OF oDlg FLAT ;
ACTION ( oBrowse:lGetBar := ! oBrowse:lGetBar, oBrowse:Refresh() )
@ 60,140 BTNBMP oBtnTab[2] PROMPT "Set Filter" ;
SIZE 90,28 PIXEL OF oDlg FLAT ;
ACTION ( oBrowse:cAlias )->( SetFilter( oBrowse ) ) When oBrowse:lGetBar
@ 60,250 BTNBMP oBtnTab[3] PROMPT "Clear Filter" ;
SIZE 90,28 PIXEL OF oDlg FLAT When oBrowse:lGetBar;
ACTION ( oBrowse:cAlias )->( DBCLEARFILTER(), oBrowse:Refresh(), oBrowse:SetFocus() )
For n= 1 to 3
oBtnTab[n]:bClrGrad = { | lInvert | If( ! lInvert,;
{ { 0.25, RGB( 238,236,219 ), RGB( 238,236,219 ) },;
{ 0.75, RGB( 238,236,219 ), RGB( 238,236,219 ) } },;
{ { 0.25, RGB( 238,236,219 ), RGB( 238,236,219 ) }, ;
{ 0.75, RGB( 238,236,219 ), RGB( 238,236,219 ) } } ) }
oBtnTab[n]:nClrBorder := nRgb(218,214,179)
oBtnTab[n]:oCursor:= oCursorBtn
next
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oBrowse:nTop := oRect:nTop+130
oBrowse:nWidth := oRect:nRight-10
oBrowse:nHeight := oRect:nbottom-150
oBtnTab[1]:nTop := oRect:nTop+100
oBtnTab[1]:nLeft := oRect:nWidth -300
oBtnTab[2]:nTop := oRect:nTop+100
oBtnTab[2]:nLeft := oRect:nWidth -200
oBtnTab[3]:nTop := oRect:nTop+100
oBtnTab[3]:nLeft := oRect:nWidth -100
return nil
>
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT (EVAL( oDlg:bResized))
RELEASE FONT oFont, oBold
return nil
//----------------------------------------------------------------------------//
static function SetFilter( oBrowse )
local cFilter := ""
local n, oCol, uVal, cType
for n := 1 to Len( oBrowse:aCols )
oCol := oBrowse:aCols[ n ]
if ! Empty( uVal := oCol:uBarGetVal )
if !Empty( cFilter )
cFilter += " .AND. "
endif
cType := ValType( uVal )
do case
case cType == 'C'
uVal := Upper( AllTrim( uVal ) )
cFilter += '"' + uVal + '" $ UPPER( ' + FieldName( n ) + " )"
otherwise
cFilter += FieldName( n ) + " == " + cValToChar( uVal )
endcase
endif
next
if Empty( cFilter )
if ! Empty( DBFILTER() )
DBCLEARFILTER()
oBrowse:Refresh()
endif
else
if !( DBFILTER() == cFilter )
SET FILTER TO &cFilter
GO TOP
oBrowse:Refresh()
endif
endif
oBrowse:SetFocus()
return nil
//----------------------------------------------------------------------------/
I tried with customer one field (First) and I have this error
the code
Code: Select all
#include "fivewin.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
SET DATE ITALIAN
SET CENTURY ON
SET DELETED ON
RDDSETDEFAULT( "DBFCDX" )
SetGetColorFocus()
Sample2()
return nil
//----------------------------------------------------------------------------//
Function Sample2()
local oDlg, oBrowse,oBar, oFont, oBold
local n
local oBtnTab[3]
local oCursorBtn :=TCursor():New(,'HAND')
* USE REPORT NEW ALIAS RP SHARED
USE CUSTOMER NEW SHARED
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg SIZE 800,500 PIXEL TRUEPIXEL ;
FONT oFont TITLE "test table"
DEFINE BUTTONBAR oBar OF oDlg SIZE 64,80 2013
DEFINE BUTTON OF oBar PROMPT "Nuovo" FILE "MOD_NUOVO" ACTION NIL
DEFINE BUTTON OF oBar PROMPT "Modifica" FILE "MOD_MODIFICA" ACTION NIL
DEFINE BUTTON OF oBar PROMPT "Cancella" FILE "MOD_CANCELLA" ACTION NIL
DEFINE BUTTON OF oBar PROMPT "Duplica" FILE "MOD_DUPLICA" ACTION NIL
DEFINE BUTTON OF oBar PROMPT "Stampa" FILE "MOD_STAMPA" ACTION NIL
@ 60, 5 XBROWSE oBrowse SIZE -5,200 PIXEL OF oDlg ;
COLUMNS "FIRST" ;
HEADERS "Descrizione" ;
COLSIZES 200 ;
CELL LINES NOBORDER ;
DATASOURCE "CUSTOMER"
/* // Relevant Code
for n := 1 to Len( oBrowse:aCols )
WITH OBJECT oBrowse:aCols[ n ]
if FieldType( n ) != 'L'
:uBarGetVal := uValBlank( fieldGet( n ) )
if FieldType( n ) == 'N'
:cBarGetPic := NumPict( FieldLen( n ), FieldDec( n ) )
endif
endif
END
next
*/
oBrOwSE:aCols[1]:uBarGetVal:= Space(60)
oBrOwSE:aCols[1]:cBarGetBmp:= "find.png"
oBrowse:lGetBar := .f.
// End of Relevant Code
WITH OBJECT oBrowse
:nHeaderHeight := 40 // optional
:oHeaderFonts := oBold
:bClrEdits := { || { CLR_BLACK, CLR_YELLOW } }
:AutoFit()
//
:CreateFromCode()
END
@ 60, 20 BTNBMP oBtnTab[1] PROMPT { || If( oBrowse:lGetBar, "Hide GetBar", "ShowGetBar" ) } ;
SIZE 90,28 PIXEL OF oDlg FLAT ;
ACTION ( oBrowse:lGetBar := ! oBrowse:lGetBar, oBrowse:Refresh() )
@ 60,140 BTNBMP oBtnTab[2] PROMPT "Set Filter" ;
SIZE 90,28 PIXEL OF oDlg FLAT ;
ACTION ( oBrowse:cAlias )->( SetFilter( oBrowse ) ) When oBrowse:lGetBar
@ 60,250 BTNBMP oBtnTab[3] PROMPT "Clear Filter" ;
SIZE 90,28 PIXEL OF oDlg FLAT When oBrowse:lGetBar;
ACTION ( oBrowse:cAlias )->( DBCLEARFILTER(), oBrowse:Refresh(), oBrowse:SetFocus() )
For n= 1 to 3
oBtnTab[n]:bClrGrad = { | lInvert | If( ! lInvert,;
{ { 0.25, RGB( 238,236,219 ), RGB( 238,236,219 ) },;
{ 0.75, RGB( 238,236,219 ), RGB( 238,236,219 ) } },;
{ { 0.25, RGB( 238,236,219 ), RGB( 238,236,219 ) }, ;
{ 0.75, RGB( 238,236,219 ), RGB( 238,236,219 ) } } ) }
oBtnTab[n]:nClrBorder := nRgb(218,214,179)
oBtnTab[n]:oCursor:= oCursorBtn
next
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oBrowse:nTop := oRect:nTop+130
oBrowse:nWidth := oRect:nRight-10
oBrowse:nHeight := oRect:nbottom-150
oBtnTab[1]:nTop := oRect:nTop+100
oBtnTab[1]:nLeft := oRect:nWidth -300
oBtnTab[2]:nTop := oRect:nTop+100
oBtnTab[2]:nLeft := oRect:nWidth -200
oBtnTab[3]:nTop := oRect:nTop+100
oBtnTab[3]:nLeft := oRect:nWidth -100
return nil
>
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT (EVAL( oDlg:bResized))
RELEASE FONT oFont, oBold
return nil
//----------------------------------------------------------------------------//
static function SetFilter( oBrowse )
local cFilter := ""
local n, oCol, uVal, cType
for n := 1 to Len( oBrowse:aCols )
oCol := oBrowse:aCols[ n ]
if ! Empty( uVal := oCol:uBarGetVal )
if !Empty( cFilter )
cFilter += " .AND. "
endif
cType := ValType( uVal )
do case
case cType == 'C'
uVal := Upper( AllTrim( uVal ) )
cFilter += '"' + uVal + '" $ UPPER( ' + FieldName( n ) + " )"
otherwise
cFilter += FieldName( n ) + " == " + cValToChar( uVal )
endcase
endif
next
if Empty( cFilter )
if ! Empty( DBFILTER() )
DBCLEARFILTER()
oBrowse:Refresh()
endif
else
if !( DBFILTER() == cFilter )
SET FILTER TO &cFilter
GO TOP
oBrowse:Refresh()
endif
endif
oBrowse:SetFocus()
return nil
//----------------------------------------------------------------------------/