- wants to select the record (aselected)
- he doesn't want to use lgetbar I showed it to him and he doesn't like it,
- Code: Select all Expand view RUN
#include "fivewin.ch"
#include "constant.ch"
REQUEST DBFCDX
Function Main()
local aColumns := { "FIRST","LAST","STREET","CITY","STATE" }
local aHdrs := {"Cognome","Nome","Indirizzo","Città", "State"}
local cdbf := "CUST"
local cTitle := "Searching on customer"
USE CUSTOMER ALIAS CUST
INDEX ON FIRST TAG FIRST TO CUSTOMER
INDEX ON LAST TAG LAST TO CUSTOMER
INDEX ON CITY TAG CITY TO CUSTOMER
INDEX ON STATE TAG STATE TO CUSTOMER
CUST->(dbsetorder(1))
CUST->(dbgotop())
SetGetColorFocus(nRGB( 203, 225, 252 ))
TableDb(aColumns,aHdrs,cDbf,cTitle)
Return nil
//----------------------------------------------------------//
Function TableDb(aColumns,aHdrs,cDbf,cTitle)
local oDlg,oBrw
local oFont,oBold
local aBtnBrow := array(4)
local cField:=""
local oSayCounter,cCounter
local nField :=1
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
DEFINE FONT oBold NAME 'Tahoma' SIZE 0, -14 BOLD
DEFINE DIALOG oDlg SIZE 820, 450 PIXEL FONT oFont ;
TITLE cTitle
@ 30, 05 XBROWSE oBrw SIZE 385,160 PIXEL OF oDlg ;
DATASOURCE cDbf ;
COLUMNS aColumns ;
HEADERS aHdrs;
CELL LINES NOBORDER FOOTERS
WITH OBJECT oBrw
WITH OBJECT oBrw:InsCol(1)
:bEditValue := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
:SetCheck( nil, .t.)
:nHeadBmpNo := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
:bFooter := { || Str( Len(oBrw:aSelected)) }
End
*:bOnChange := { |o| o:RefreshFooter() }
: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() }
: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 ) } }
:lIncrFilter := .t.
:lSeekWild := .t.
:cFilterFld := "Cognome"
:nStretchCol := STRETCHCOL_WIDEST
:bChange := { || RefreshCont(oSayCounter,"CUST") }
:lDrawBorder := .t.
:lHScroll := .f.
:nHeaderHeight := 30
:nRowHeight := 30
:lColDividerComplete := .t.
:lRecordSelector := .t.
:nStretchCol := -1
:CreateFromCode()
END
@ 12, 11 SAY "Search:" SIZE 55, 12 PIXEL OF oDlg COLOR 0, 14215660 FONT oFont
@ 10, 45 GET oBrw:oSeek VAR oBrw:cSeek SIZE 100,12 PIXEL ;
OF oDlg COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!' ;
ON CHANGE ( oBrw:lSeekWild :=.t., ;
oBrw:Seek( If( oBrw:lSeekWild, oBrw:cSeek, "" ) ), ;
oBrw:SetFocus() ) FONT oFont
@ 12, 181 SAY "in" SIZE 55, 12 PIXEL OF oDlg COLOR 0, 14215660 FONT oFont
@ 10, 195 COMBOBOX oBrw:cFilterFld ;
ITEMS aHdrs ;
ON CHANGE ( oBrw:Seek( "" ), oBrw:SetFocus() ) ;
SIZE 50,400 PIXEL OF oDlg STYLE CBS_DROPDOWN FONT oFont
@ 10, oBrw:nWidth-20 BTNBMP aBtnBrow[1] ;
FLAT SIZE 15, 14 OF oDlg PIXEL ;
COLOR nRgb(203, 225, 252),nRgb(238,236,219) ;
BITMAP "REP_CLEAR" NOROUND;
tooltip "Clear" ;
ACTION (cSearch:=Space(60),aGet[1]:ctext:=cSearch,;
aGet[1]:refresh(), Clear(oBrw,nField),RefreshCont(oSayCounter,"CUST"))
cCounter:=lTrim(tran( ( oBrw:cAlias )->(ordKeyNo()),'@E 999,999'))+" / "+lTrim(tran(( oBrw:cAlias )->(ordKeyCount()),'@E 999,999'))
@ oBrw:nBottom+5, oBrw:nWidth-90 SAY oSayCounter ;
PROMPT cCounter ;
SIZE 35, 10 OF oDlg PIXEL ;
FONT oFont ;
COLOR CLR_BLACK ,nRgb(218,214,179)
oDlg:bPainted := < |hDC|
RoundBox( hDC, 580,383,668,410,0,0,nRgb(218,214,179), 2 )
Return nil
>
oBrw:bSeek := nil
oDlg:lHelpIcon := .f.
ACTIVATE DIALOG oDlg CENTER
//-------------------------------------------------------------------------------------------//
Function RefreshCont(oCont,cAlias)
if oCont != NIL
cStringa:=ltrim(tran( (cAlias)->(ordKeyNo()),'@E 999,999'))+" / "+lTrim(tran((cAlias)->(ordKeyCount()),'@E 999,999'))
oCont:settext(cStringa )
* oCont:refresh()
endif
return nil
//-------------------------------------------------------------------------------------------//
Function Clear(oBrw,nField)
SET FILTER TO !DELETED()
( oBrw:cAlias )->(Dbsetorder(nField))
GO TOP
oBrw:Refresh()
return nil