Maybe someone has time and can help me.
Unfortunately, ACTION does not work with the switches.
I would like to make the switch clickable and then change the width.
call test program:
sorting.exe mydbf.dbf
Best regards,
Otto
- Code: Select all Expand view
#include "FiveWin.ch"
REQUEST DBFCDX
REQUEST DBFFPT
static oBtn[ 200 ]
static nColNext := 0
static oFont, oFontBold
static cABC := " "
static aFields
static aStructAlt
static databaseName
//----------------------------------------------------------------------------//
function main(cAufruf)
local cRet := ""
local oDlg
local lSave := .f.
local oBtnEnde, oBtnSave
local oBtnOK
local nReihe := 0
local nCount := 0
local I := 0
local nColOffset := 3
local nWidth := GetSysMetrics( 0 )/2
local nHeight := GetSysMetrics( 1 )/4*3
local x := 0
local nAbstand := 0
local y := 0
local maxItems := 0
Local hPen := CreatePen( 1, 3, 4144959 ) //Rot
local cDbf := ""
local aStruct :={}
local aTemp := {}
local nSpalten
local cBinData
*----------------------------------------------------------
if valtype( cAufruf ) <> "U"
databaseName := caufruf
use(caufruf) new
aStruct := dbstruct()
xbrowse(aStruct)
cBinData := ASave( aStruct ) // Converts Array Data and to Binary and stores in cStr
memowrit( "struktur.txt", cBinData )
else
databaseName := ""
endif
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14 BOLD
DEFINE FONT oFontBold NAME "TAHOMA" SIZE 0,-20 BOLD
aFields := {}
aTemp := ARead ( memoread( "struktur.txt" ) )
xbrowse(aTemp)
aStructAlt := aTemp
AEval( aTemp, { |a| AADD( afields,{ a[1], I += 1 }) } )
asort( afields,,, { |x, y | x[1] < y[1] } )
maxItems := len(aFields)
AADD( afields, {"ROW", maxItems + 1} )
AADD( afields, {"ROW", maxItems + 2} )
AADD( afields, {"ROW", maxItems + 3} )
AADD( afields, {"ROW", maxItems + 4} )
AADD( afields, {"ROW", maxItems + 5} )
maxItems += 5
DEFINE DIALOG oDlg ;
TITLE "Auswahl" ;
FROM 0, 0 ;
TO nHeight, nWidth ;
PIXEL
nWidth := nWidth/6*4
@ 02,300 ;
SAY "database fields" ;
OF oDlg ;
PIXEL ;
FONT oFontBold
@ ( nHeight/3*2+25 ) / 2.05,0 ;
SAY "new database" ;
OF oDlg ;
PIXEL ;
FONT oFontBold
nSpalten := INT( nWidth/105 )-1
x := nSpalten //3//10
y := 18 //35 // 15
nAbstand := nWidth/5 * 4 / 5
nColOffset := 20
FOR nReihe = 0 to maxItems / 5
nColNext := 5
FOR I = 1 To x
nCount := nCount + 1
if nCount > maxItems
exit
endif
//nRow, nCol, aVar, n, oWnd
oBtn[ nCount ] := MakeGet( ( 3 + y * nReihe ),;
nColOffset/2.05 + ( nWidth - 20 * 2 )/ x /2.05 * ( I - 1 ),;
aFields,;
nCount,;
oDlg )
NEXT
NEXT
@ ( nHeight-90) /2.05,nWidth/2/2.05 - 50 ;
FLATBTN oBtnSave ;
PROMPT "Save" ;
SIZE 50 /2.05 + 5, 27 /2.05 ;
OF oDlg ;
ACTION Save(oDlg, nHeight) ;
COLOR CLR_BLACK, CLR_YELLOW
@ ( nHeight-90) /2.05,nWidth/2/2.05 ;
FLATBTN oBtnEnde ;
PROMPT "Abbruch" ;
SIZE 50 /2.05 + 5, 27 /2.05 ;
OF oDlg ;
ACTION oDlg:END() ;
COLOR CLR_BLACK, CLR_YELLOW
SelectObject( oDlg:hDc, hPen )
ACTIVATE DIALOG oDlg ;
CENTERED ;
ON INIT ( dragModus( oBtn, nCount ) ) ;
ON PAINT ( oDlg:line( nHeight/3*2, 0 ,nHeight/3*2, nWidth +300 ) )
if lsave = .t.
endif
return nil
//----------------------------------------------------------------------------//
function dragModus( oBtn, nCount )
local I := 0
FOR I := 1 to nCount -1
// oBtn[ I ]:lDrag := .t.
next
return nil
//----------------------------------------------------------------------------//
static function MakeGet( nRow, nCol, aVar, n, oWnd )
local oget
if cABC <> left( aVar[ n, 1 ], 1 )
@ nRow +20,nColNext ;
BTNBMP oGet ;
PROMPT aVar[ n, 1 ] ;
OF oWnd PIXEL ;
ACTION xbrowse(oGet);
FONT oFontBold;
SIZE 70, 14 FLAT
cABC := left( aVar[ n, 1 ], 1 )
else
@ nRow +20,nColNext ;
BTNBMP oGet ;
PROMPT aVar[ n, 1 ] ;
OF oWnd PIXEL ;
ACTION xbrowse(oGet);
FONT oFont;
SIZE 70, 14 FLAT
endif
oGet:cargo := aVar[ n, 2 ]
oGet:bPostDrag := { |oSay| osay:ntop := INT( osay:ntop/20)*20 }
nColNext := nColNext + oGet:nWidth + 5
oGet:lDrag := .t.
return oGet
//----------------------------------------------------------------------------//
function save( oWnd, nHeight)
local I := 0
local oCtrl
local aSortiert := {}
for each oCtrl in oWnd:aControls
I += 1
if oCtrl:cTitle = "Abbruch" .or.;
oCtrl:cTitle = "Save" .or.;
oCtrl:cTitle = "database fields" .or.;
oCtrl:cTitle = "new database"
else
AAdd( aSortiert, { oCtrl:cTitle, oCtrl:nTop, oCtrl:nLeft, "Auswahl", oCtrl:Cargo } )
endif
next
f_xbrowse( aSortiert )
return nil
//----------------------------------------------------------------------------//
function f_xbrowse( aSortiert )
local oDlg, oBrw, oFont
local oBTNSpeichern
local oBTNWeiter
local lOK := .f.
local cBuchungsNr := ""
local aGaeste := {}
*----------------------------------------------------------
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14
DEFINE DIALOG oDlg ;
TITLE "Liste aller Einstellungen" ;
SIZE 800, 540 ;
PIXEL ;
FONT oFont
@ 10,10 ;
XBROWSE oBrw ;
OF oDlg ;
PIXEL ;
SIZE 500, 200 ;
DATASOURCE aSortiert ;
AUTOSORT ;
NOBORDER
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLWIN7
oBrw:CreateFromCode()
@ ( oDlg:nHeight - 40 ) / 2.05, oDlg:nWidth/5/2.05 ;
FLATBTN oBTNSpeichern ;
PROMPT "DBF erstellen" ;
SIZE 2, ( 32 ) /2.05 ;
OF oDlg ;
ACTION ( dbf_erstellen( aSortiert ) )
@ ( oDlg:nHeight - 40 ) / 2.05,oDlg:nWidth/2/2.05 + oBTNSpeichern:nWidth + 10;
FLATBTN oBTNWeiter ;
PROMPT "Abbruch" ;
SIZE 2, ( 32 ) /2.05 ;
OF oDlg ;
ACTION ( oDlg:End() ) ;
CANCEL
//----------------------------------------------------------------------------//
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//----------------------------------------------------------------------------//
function dbf_erstellen( aSortiert )
local aTemp := {}
local I := 1
local aStructNeu := {}
local cCode := ""
local aTemp1 := {}
local cBinData
*----------------------------------------------------------
FOR I:= 1 to len(aSortiert)
if aSortiert[I, 2 ] > 560
aadd( atemp, aSortiert[I] )
endif
next
asort( atemp,,, { |x, y | x[3] < y[3] } )
asort( atemp,,, { |x, y | x[2] < y[2] } )
//xbrowse(aTemp)
cBinData := ASave( aTemp ) // Converts Array Data and to Binary and stores in cStr
memowrit( "structurfilter.txt", cBinData )
return nil
//----------------------------------------------------------------------------//