#include 'fivewin.ch'
#include 'xbrowse.ch'
#include "constant.ch"
request dbfcdx
request dbffpt
function Main()
local oDlg, oBrw, oFont,obold
local oSay:=array(2)
local cSeek:=Space(100)
local oGet
local oBtn
local aCooDlg := aParamDialog(1)
local nWd := aCooDlg[1]
local nHt := aCooDlg[2]
local aBtnBrow:=array(4)
local oDbf
local aCols := { ;
{ "FIRST", "First" ,, 120, },;
{ "LAST", "Last" ,, 120, },;
{ "STREET", "Address" ,, 150, },;
{ "CITY", "City" ,, 100, },;
{ "STATE", "State" ,, 80, } }
local cTitle :="Customers"
local cPrefix:="Cli"
local cSection:="Cli"
RddSetDefault( "DBFCDX" )
SetHandleCount( 100 )
FWNumFormat( "E", .t. )
oDbf :=TDatabase():Open( , "Customer", "DBFCDX", .T. )
oDbf:setorder(1)
oDbf:Gotop()
oFont := TFont():New( "TAHOMA", 0, 14,, )
oBold := TFont():New( "TAHOMA", 0, 14,,.t. )
DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
FONT oFont COLOR CLR_BLACK, CLR_WHITE ;
STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
WS_MINIMIZEBOX)
DEFINE BUTTONBAR oBar OF oDlg SIZE 80,70 TOP NOBORDER 2015
@ 12,15 say oSay[1] Prompt "Cerca" SIZE 46,24 PIXEL OF oDlg FONT oBold TRANSPARENT
@ 12,450 say oSay[2] Prompt "in" SIZE 20,24 PIXEL OF oDlg FONT oBold TRANSPARENT
@ 10, 165 GET oGet VAR cSeek SIZE 200,19 PIXEL OF oDlg PICTURE "@!"
@ 103,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE oDbf COLUMNS aCols ;
AUTOSORT FONT oFont;
NOBORDER CELL LINES
WITH OBJECT oBrw
:SetMultiSelectCol()
:bLClicked := { |r,c,f,oBrw| if( oBrw:Mousecolpos( c ) == 1, ;
( if( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
( AAdd( oBrw:aSelected, oBrw:BookMark ), ;
if( Len( oBrw:aSelected ) = 1, Btnbar(2,oDlg:oBar,oDlg,oDbf,oBrw), ) ), ;
( ADel( oBrw:aSelected, f, .t. ), ;
if( LEN(oBrw:aSelected)==0, Btnbar(1,oDlg:oBar,oDlg,oDbf,oBrw), )) ), ;
Refresh_title(oBrw,oDlg,oDbf,cTitle),;
oBrw:RefreshCurrent() ), ) }
:bKeyChar := {| k | (If( k == VK_SPACE,;
(if( oBrw:IsSelectedRow(), ;
ADel( oBrw:aSelected, oBrw:BookMark,.t. ), ;
AAdd( oBrw:aSelected, oBrw:BookMark ) ), ;
if( Len( oBrw:aSelected ) == 0, ;
Btnbar(1,oDlg:oBar,oDlg,oDbf,oBrw,aBtnBrow[4]), ;
Btnbar(2,oDlg:oBar,oDlg,oDbf,oBrw,aBtnBrow[4]) ) ), nil),;
Refresh_title(oBrw,oDlg,oDbf,cSection))}
:lHScroll := .f.
:lIncrFilter := .t.
:bOnSort := { |b,oCol| oBrw:Seek( "" ), ;
oBrw:cFilterFld := oCol:cExpr, ;
oBrw:SetFocus() }
:oSeek := oGet
:CreateFromCode()
END
@ 10, 550 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder;
SIZE 150,400 PIXEL OF oDlg HEIGHTGET 18 STYLE CBS_DROPDOWN
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oBrw:nHeight:= oRect:nBottom - 20
oSay[1]:setsize(90, 24.2)
oSay[1]:nTop := oRect:ntop+78
oSay[1]:nLeft := oRect:nLeft+10
oSay[2]:nTop := oRect:ntop+78
oSay[2]:nLeft := oRect:nLeft+270
oGet:nTop := oRect:ntop+74
oGet:nLeft := oRect:nLeft+60
oGet:setsize(200, 24.2)
oBrw:oSortCbx:nTop := oRect:ntop+74.9
oBrw:oSortCbx:nLeft := oRect:nLeft+290
oBrw:refresh()
RETURN nil
>
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( Btnbar(1,oDlg:oBar,oDlg,oDbf,oBrw,aBtnBrow[4]),;
oDlg:resize())
RELEASE FONT oFont
return nil
Static Function Btnbar(nBar,oBar,oDlg,oDbf,oBrw,oCont) // ,aBtnBar
local aBtnBar
local x
if Valtype( oBar ) = "O"
For x := Len( oBar:aControls ) to 1 step - 1
oBar:Del( x,.f. )
Next x
endif
Do case
case nbar = 0
* DEFINE BUTTONBAR oBar OF oDlg SIZE 80,70 TOP NOBORDER 2015
case nbar = 1
aBtnBar := array(6)
DEFINE BUTTON aBtnBar[1] OF oBar PROMPT "Nuovo" RESOURCE "NEW_REC" ;
ACTION NIL
DEFINE BUTTON aBtnBar[2] OF oBar PROMPT "Modifica" RESOURCE "MOD_REC" ;
ACTION NIL GROUP
DEFINE BUTTON aBtnBar[3] OF oBar PROMPT "Duplica" RESOURCE "DUP_REC" ;
ACTION NIL
DEFINE BUTTON aBtnBar[4] OF oBar PROMPT "Cancella" RESOURCE "DEL_REC" ;
ACTION NIL
DEFINE BUTTON aBtnBar[5] OF oBar PROMPT "Stampa" RESOURCE "PRN_REC" ;
ACTION NIL
DEFINE BUTTON aBtnBar[6] OF oBar PROMPT "Aiuto" RESOURCE "HLP_DLG" ;
ACTION NIL BTNRIGHT
case nbar = 2
aBtnBar := array(3)
DEFINE BUTTON aBtnBar[1] OF oBar PROMPT "Cancella" RESOURCE "DEL_REC" ;
ACTION NIL
DEFINE BUTTON aBtnBar[2] OF oBar PROMPT "Stampa" RESOURCE "PRN_REC" ;
ACTION NIL
DEFINE BUTTON aBtnBar[3] OF oBar PROMPT "Aiuto" RESOURCE "HLP_DLG" ;
ACTION NIL BTNRIGHT
endcase
return oBar
//--------------------------------------------------------------------------//
Function Refresh_title();RETURN NIL
Function aParamDialog(n)
local nBottom,nRight,nWd,nHt
local aTmp :={0,0}
Do Case
Case n=1
nBottom:= 32.4
nRight := 95
Endcase
nHt := nBottom * DLG_CHARPIX_H
nWd := Max( nRight * DLG_CHARPIX_W, 180 )
aTmp[1]:=nWd
aTmp[2]:=nHt
return aTmp
//--------------------------------------------------------------------------//