Code: Select all
#include "fivewin.ch"
#include "constant.ch"
#include "ttitle.ch"
REQUEST HB_Lang_IT
REQUEST HB_CODEPAGE_ITWIN
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO
FUNCTION Main()
local cDbf := "Cust"
local aBrowse
HB_LangSelect("IT")
HB_SetCodePage("ITWIN")
SET _3DLOOK ON
SET CENTURY ON
SET DATE ITALIAN
RDDSetDefault( 'DBFCDX' )
cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "tabledb.ini"
USE CUSTOMER ALIAS CUST
INDEX ON FIRST TAG FIRST TO TMFIRST MEMORY
INDEX ON LAST TAG LAST TO TMPLAST MEMORY
INDEX ON CITY TAG CITY TO TMPCITY MEMORY
INDEX ON STATE TAG STATE TO TMPSTATE MEMORY
cust->(dbsetorder(1))
cust->(dbgotop())
// { field, header, picture, size, justify, sortorder }
aBrowse := { { "CUST->FIRST", "Nome",, 120, },;
{ "CUST->LAST", "Cognome",, 120, },;
{ "CUST->STREET", "Indirizzo",, 180, },;
{ "CUST->CITY", "Città",, 150, },;
{ "CUST->STATE", "Stato",, 50, }}
bedit:= { || MsgInfo( "modify" ) }
TableDb(aBrowse,cDbf,"Customers table","Cust",bedit)
RETURN NIL
//------------------------------------------------------------------//
Function TableDb(aBrowse,cDbf,cTitle,cPrefix,bedit)
local oTabella
local oBrw,oSay1,oSay2
local oFont,oFontSmall,oBold
local oCursorBtn :=TCursor():New(,'HAND')
local nBottom := 28
local nRight := 99.9
local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
local nHeight := nBottom * DLG_CHARPIX_H
local aBtnBrow := array(4)
local aBtnNav := array(4)
local aHdrs := {} //Headers
local aColumns := {}
local cSeek := Space( 100 )
local oGet,oGet2
local nField := 1
// da personalizzare
local cImage:= ".\bitmaps\clienti.bmp"
local cTitle1:= "Customers"
local cTitle2:= "Insert the customer to search"
AAdd( aHdrs, "" )
AAdd( aColumns, "" )
for n= 1 to Len(aBrowse)
AAdd( aHdrs, aBrowse[n][2] )
AAdd( aColumns, aBrowse[n][1] )
next
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
DEFINE FONT oFontSmall NAME 'Tahoma' SIZE 0, -14
DEFINE FONT oBold NAME 'Tahoma' SIZE 0, -14 BOLD
DEFINE DIALOG oTabella TITLE cTitle ;
SIZE nWidth, nHeight FONT oFont ;
PIXEL TRUEPIXEL RESIZABLE COLOR CLR_BLACK, nRgb( 245,244,234)
@ 0,0 TITLE oTitle OF oTabella size oTabella:nwidth, 60 BORDER SHADOW NOSHADOW ;
GRADIENT { { 1, CLR_WHITE, CLR_WHITE } }
@ 10, 12 TITLETEXT OF oTitle TEXT cTitle1 FONT oBold COLOR CLR_GRAY
@ 28, 12 TITLETEXT OF oTitle TEXT cTitle2 FONT oFont COLOR CLR_HGRAY
@ 10, 12 TITLEIMG oImg OF oTitle BITMAP cImage SIZE 50,50 TRANSPARENT
@ 66,3 SAY oSay1 Prompt "Search " ;
FONT oBold SIZE 120,20 PIXEL OF oTabella TRANSPARENT
@ 42, 181 Say oSay2 Prompt "in" ;
FONT oBold SIZE 55, 20 PIXEL OF oTabella TRANSPARENT
DEFINE BUTTONBAR oBar OF oTabella SIZE 70,70 BOTTOM NOBORDER 2010
DEFINE BUTTON OF oBar PROMPT "New" FILENAME ".\BITMAPS\NUOVO.PNG" ACTION If( oBrw:bEdit == nil, oBrw:Edit( .t. ), oBrw:EditSource( .t. ) )
DEFINE BUTTON OF oBar PROMPT "Modify" FILENAME ".\BITMAPS\PENCIL.PNG" GROUP ACTION If( oBrw:bEdit == nil, oBrw:Edit(), oBrw:EditSource() )
DEFINE BUTTON OF oBar PROMPT "Delete" FILENAME ".\BITMAPS\CAN.PNG" ACTION ( If( MsgNoYes( "Delete Record?" ), oBrw:Delete(), nil ), oBrw:SetFocus() )
DEFINE BUTTON OF oBar PROMPT "Print" FILENAME ".\BITMAPS\print.bmp" ACTION If( Empty( oBrw:bPrint ), oBrw:Report(), oBrw:Print() )
DEFINE BUTTON OF oBar PROMPT "Exit" FILENAME ".\BITMAPS\exit.bmp" GROUP ACTION oTabella:End()
oBar:bClrGrad := { | lPressed | If( ! lPressed,;
{ { 1, nRgb(233,229,206),nRgb(233,229,206) } },;
{ { 1, nRgb( 245,244,234), nRgb( 245,244,234) } } ) }
@ 40, 65 GET oGet VAR cSeek SIZE 250, 25 PIXEL OF oTabella
oGet:bChange := <| nKey, nFlags, Self |
if ::oGet:Buffer != nil .and. !oBrw:Seek( Trim( ::oGet:buffer ) )
::cText := PadR( oBrw:cSeek, Len( ::VarGet() ) )
::SetPos( Len( oBrw:cSeek ) + 1 )
endif
return nil
>
@ 100,5 XBROWSE oBrw ;
SIZE 385,130 PIXEL;
OF oTabella ;
ALIAS cDbf COLUMNS aBrowse NOBORDER FOOTERS
WITH OBJECT oBrw
WITH OBJECT oBrw:InsCol(1)
:nwidth:= 30
:bEditValue := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
:SetCheck( nil, .t.)
:nHeadBmpNo := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
:bFooter := { || ltrim(Str( Len(oBrw:aSelected))) }
:bLClickHeader := { || oBrw:SelectRow( If( Len( oBrw:aSelected ) == oBrw:nLen, 0, 4 ) ), oBrw:Refresh() }
End
:bLClicked := { |r,c,f,oBrw| If( oBrw:MouseColPos( c ) == 1 , ;
If( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
AAdd( oBrw:aSelected, oBrw:BookMark ), ;
ADel( oBrw:aSelected, f, .t. ) ), Nil ), ;
oBrw:RefreshCurrent() }
:lIncrFilter := .t.
:cFilterFld := aColumns[nField]
:oSeek := oGet
:l2007:=.f.
:lColDividerComplete := .t.
:lRecordSelector := .t.
:lHScroll := .f.
:nHeaderHeight := 30
:nRowHeight := 30
:nFooterHeight := 30
:nStretchCol := -1
:lDrawBorder := .t.
:nRecSelColor := nRgb( 245,244,234)
:bClrHeader := {|| { ,nRgb(233,229,206) } }
:bClrFooter := {|| { ,nRgb( 245,244,234) } }
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:bChange := { |o| o:RefreshFooters() }
:bKeyChar := { |k| If( k == VK_SPACE, ( oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent(), 0 ), nil ) }
:bLDblClick := { || oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent() }
:bClrStd := { || { CLR_BLACK, If( oBrw:oCol( 1 ):Value, 0x80ffff, CLR_WHITE ) } }
:nRecSelColor := nRgb( 245,244,234)
:bClrHeader := {|| { ,nRgb(233,229,206) } }
:bClrFooter := {|| { ,nRgb( 245,244,234) } }
:CreateFromCode()
END
@ 20, 280 COMBOBOX oGet2 var oBrw:cFilterFld ;
ITEMS aHdrs ;
ON CHANGE ( nField:=::nat,;
oBrw:cFilterFld := aColumns[nField],;
msginfo( oBrw:cFilterFld ),;
oBrw:Seek( "" ), oBrw:SetFocus() ) ;
SIZE 150,400 PIXEL OF oTabella
oTabella:bResized := <||
local oRect := oTabella:GetCliRect()
oTitle:nWidth := oRect:nRight
oBrw:nWidth := oRect:nRight-10
oBrw:nHeight := oRect:nbottom-210
oImg:aImgs[2] := oRect:nRight-60
oGet:nTop := oTitle:nBottom+5
oGet:nLeft := oRect:nLeft+90
oSay1:nTop := oTitle:nBottom+7
oSay1:nLeft := oRect:nLeft+10
oSay2:nTop := oTitle:nBottom+7
oSay2:nLeft := oRect:nLeft+360
oGet2:nTop := oTitle:nBottom+5
oGet2:nLeft := oRect:nLeft+380
return nil
>
oTabella:aMinMaxInfo := { nil, nil, nil, nil, 650,350, nil, nil }
ACTIVATE DIALOG oTabella CENTERED ;
ON INIT ( nField:=1,;
oBrw:cFilterFld := aColumns[nField],;
oGet2:select(nField),;
oTabella:resize(),;
ChangeButtons( oBar ),;
EVAL( oTabella:bResized) )
RETURN NIL
//-----------------------------------------------------------------//
function ChangeButtons( oBar )
AEval( oBar:aControls, { | oCtrl | oCtrl:nTop += 4, oCtrl:nHeight -= 4 } )
return .T.
//-----------------------------------------------------------------//