How to show OemToAnsi in xBrw. (when no Col's defined) ?

How to show OemToAnsi in xBrw. (when no Col's defined) ?

Postby ukoenig » Sun Feb 17, 2008 1:40 pm

Hello, from Germany

In the Quickbrowse-Modul i want to show C- Fields
in OemToAnsi-Look, if the user selects : OemAnsi = .T.,
to show Dbf's, created in old times with Clipper.
There are no Col's defined.

IF OemAnsi = .T. then ........
Gets and Edits in oBrw5 and oBrw6 must change
--------------------------------------------------------

oBrw5 := TXBrowse():New( oDlg )

oBrw5:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw5:nColDividerStyle := LINESTYLE_BLACK
oBrw5:nRowDividerStyle := LINESTYLE_BLACK
oBrw5:lColDividerComplete := .t.
oBrw5:nHeaderLines := 1
oBrw5:nDataLines := 1
oBrw5:lAllowColSwapping := .t.
oBrw5:SetRDD()

lClrFlag:=.f.
for nFor := 1 to len( oBrw5:aCols )
oCol := oBrw5:aCols[ nFor ]
oBrw5:bSkip:={| nRecs | ( if(nRecs == nil, nRecs := 1,), ;
nRecs:= (1)->(dbskipper( nRecs )), ;
lClrFlag:= if( nRecs % 2 = 0, lClrFlag,!lClrFlag), nRecs) }
// Define alternating row colors
oBrw5:bClrStd := { || Colors() }
oCol:nEditType := 1
oCol:bOnPostEdit := ;
{|o, v, n| IIF( n != VK_ESCAPE, ;
( IIF( NET_RLOCK(), FieldPut( o:nCreationOrder, v ), ;
NET_ULOCK() ), NIL ), ) }
next
for nFor := 1 to Fcount()
oBrw5:aCols[ nFor ]:bRClickHeader := ;
{|r,c,f,o| cFELD := o:cHeader, ; // = oCol:cHeader
nOrder := o:nCreationOrder, ; // = Header-Click-Col
cFilter := SET_INDEX(oBrw5,cFELD,cFILTER), ;
IIF(DBFTYP = "CDX", ;
cINDKEY := ORDKEY( "NEUINDEX" ), ;
cINDKEY := INDEXKEY( 0 ) ), ;
oBrw5:SetFocus(), ;
oBrw5:GoTop(), oBrw5:VGoTop(), oBrw5:Refresh(), ;
l_INDEX := .T., oINDKEY:Refresh(), ;
oFilter:Refresh(), ;
oBrw5:SwapCols( 1, nOrder ), ; // Bring selected col to 1
oBrw5:GoLeftMost(), ; // Go to 1. Col ( indexed )
oBrw5:nFreeze := 1 } // Freeze 1. Col
next
oBrw5:bChange := { || oDlg:Update() }
oBrw5:CreateFromResource( 110 )

// -------------- ARRAY ------------------------------------------

oBrw6 := TXBrowse():New( oDlg )
oBrw6 :SetArray( (1)->( dbStruct() ), .f. )
oBrw6:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw6:nColDividerStyle := LINESTYLE_BLACK
oBrw6:nRowDividerStyle := LINESTYLE_BLACK
oBrw6:lColDividerComplete := .t.
oBrw6:nHeaderLines := 1
oBrw6:nDataLines := 1
oBrw6:lAllowColSwapping := .t.
oBrw6:SetRDD()
ASIZE( oBrw6:aCols, 4 )
AEVAL( oBrw6:aArrayData, {|a|nMaxWidth := Max(nMaxWidth, a[3])})
WITH OBJECT oBrw6:AddCol()
:bStrData := ;
:bEditvalue := {||PADR(cValToChar((1)->(FieldGet ;(oBrw6:nArrayAt))),nMaxWidth)}
:nEditType := EDIT_GET
:bOnPostEdit:= {|oCol,xValue,nLastKey|OnEdit(obrw6,oCol,xValue, ;
nLastKey, lOemAnsi ), oDlg:Update() }
END
AEval( oBrw6:aCols, { |oCol, nCol| oCol:cHeader := ;
{ "FieldName", "Typ", "Len", "Dec","Value" }[ nCol ] } )
oBrw6:aCols[ 1 ]:nWidth := 100
oBrw6:aCols[ 3 ]:nDataStrAlign := AL_RIGHT
oBrw6:aCols[ 4 ]:nDataStrAlign := AL_RIGHT
oBrw6:nColSel := 5
oBrw6:lUpdate := .t.
oBrw6:Cargo := oBrw5
oBrw6:bChange := { || oDlg:Update() }
oBrw6:CreateFromResource( 115 )
....
.....

//----------------------------------------------------------------------------//

FUNCTION OnEdit( oBrw6, oCol, xValue, nLastKey, lOemAnsi )

IF nLastKey == 13
SWITCH Eval( oBrw6:aCols[2]:bStrData )
CASE 'N'
xValue := Val( xValue )
EXIT
CASE 'D'
xValue := CTOD( ALLTRIM( xValue ) )
EXIT
CASE 'L'
xValue := ( Upper( Left ( LTrim( xValue ), 1 ) ) $ "YT" )
EXIT
DEFAULT
END
NET_RLOCK()
(1)->( FieldPut( oBrw6:nArrayAt, xValue ) )
NET_ULOCK()
oBrw6:DrawLine( .t. )
oBrw6:Cargo:DrawLine( .t. )
ENDIF

RETURN NIL

Regards
Uwe
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests