A full working PRG that runs from inside the FWH-sample-folder without any changes and uses < customer.dbf >
Code: Select all
#include "FiveWin.ch"
STATIC oDlg
FUNCTION MAIN()
LOCAL oFontSys, oBrw, oProject, cLink := ""
LOCAL oGet, oBtnSys[9], nCol, oRadio, c_Path, c_Path1
LOCAL nGrpPos := 1, I, oSay
LOCAL oFieldget, cFieldget := SPACE(200), nColNo := 2
DEFINE FONT oFontSys NAME "Arial" SIZE 0, -14
DEFINE FONT oFontLarge NAME "Arial" SIZE 0, -24 BOLD
c_Path := cFilePath(GetModuleFileName( GetInstance() ) )
c_Path1 := c_Path + "..\BITMAPS\32x32\"
aGrad := { { 0.5, 14927760,16579318 }, { 0.5, 16579318, 14927760 } }
DEFINE BRUSH oBrush GRADIENT aGrad STRETCH
REQUEST DBFCDX
RDDSETDEFAULT ( "DBFCDX" )
// CreateIndex( cFile, cTag, cKey, lUnique, lDescend, lMemory )
oProject := TDatabase():Open( , "CUSTOMER", "DBFCDX", .T. )
oProject:CreateIndex( "CUSTOMER", "PROJ1", "State", .F. )
oProject:ORDSCOPE(0, "A" )
oProject:ORDSCOPE(1, "A" )
DEFINE DIALOG oDlg SIZE 850, 300 PIXEL TRUEPIXEL TITLE "xBrowse-test " + FWVERSION
@ 5, 50 SAY oSay PROMPT "xBrowse-celledit -> " + FWVERSION SIZE 450, 35 OF oDlg FONT oFontLarge PIXEL
oSay:SetColor( 255, )
oSay:lTransparent := .T.
// ---------- Close
@ 6, oDlg:nWidth - 40 BTNBMP oBtnSys[1] OF oDlg ;
FILE c_path1 + "Exit.bmp", "", "", ;
c_path1 + "Quit.bmp" ;
FLAT NOBORDER NOROUND ACTION oDlg:End() SIZE 30, 30
oBtnSys[1]:lTransparent := .T.
oBtnSys[1]:cToolTip := { "Exit xBrowse-edit", "EXIT", 1, CLR_BLACK, 14089979 }
// ---- 1. section -----
oProject:ORDSCOPE(0, "A" ) // set top scope
oProject:ORDSCOPE(1, "A" ) // set bottom scope
oProject:GoTop()
@ 40, 20 XBROWSE oBrw SIZE 750, 195 PIXEL OF oDlg ;
DATASOURCE oProject ;
AUTOSORT FOOTERS FASTEDIT ;
COLUMNS "State", "First", "Last", "Street", "City", "Age", "Salary" ;
HEADERS "State", "First", "Last", "Street", "City", "Age", "Salary" ;
COLSIZES 50, 150, 150, 220, 150, 100, 100 FONT oFontsys
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
WITH OBJECT oBrw
:lHeader := .T.
:nHeaderHeight := 28
:lFooter := .F.
:lHScroll := .T.
:lVScroll := .T.
:nFreeze := 1
:lAllowRowSizing := .F.
:lAllowColHiding := .F.
:lAllowColSwapping := .F.
:lColChangeNotify := .t.
I := 2 // editget from column 2 - 3
FOR I := 2 to len( oBrw:aCols )
:aCols[ I ]:nEditType := EDIT_GET
// ------- only FWh 19.09 ----------
// :aCols[ I ]:bOnPostEdit := {|oCol, xVal, nKey| IF( nKey == VK_RETURN, ;
// oProject:FieldPut( oCol:nCreationOrder, xVal ), ), ;
// oProject:Save(), oBrw:RefreshCurrent() }
// ------- only FWh 19.09 ----------
NEXT
:bClrStd := { || If( oBrw:KeyNo() % 2 == 0, ;
{ If( oProject:Deleted(), 255, 0 ), 11392685 }, ;
{ If( oProject:Deleted(), 255, 0 ), 14741472 } ) }
:bClrEdits := { || { CLR_HRED, CLR_YELLOW } }
:bChange := { || oCol := oBrw:SelectedCol(), ;
nColNo := oBrw:SelectedCol():nCreationOrder, ;
cFieldget := PADR( oCol:Value, 200, " " ), oFieldget:Refresh() }
:bLClicked := { || oCol := oBrw:SelectedCol(), ;
nColNo := oBrw:SelectedCol():nCreationOrder, ;
cFieldget := PADR( oCol:Value, 200, " " ), oFieldget:Refresh() }
:CreateFromCode()
END
AEval( oBrw:aCols, { |oCol, n| oCol:lAllowSizing := .F. } )
@ 40, 800 RADIO oRadio VAR nGrpPos OF oDlg PIXEL UPDATE ;
ITEMS "&A", "&C", "&D", "&F", "&G"_3D SIZE 30, 35 ;
HELPID 200, 201, 202, 204, 205 ;
ON CHANGE ( SET_GROUP( oProject, nGrpPos), ;
oProject:GoTop(), oBrw:Refresh() )
AEval( oRadio:aItems, { | oRad | oRad:lTransparent := .T., ;
oRad:SetFont ( oFontSys ), ;
oRad:nClrText := 0 } )
@ 258, 45 GET oFieldget VAR cFieldget SIZE 720, 22 OF oDlg PIXEL UPDATE FONT oFontSys
@ 257, 770 BTNBMP oBtnSys[8] OF oDlg ;
SIZE 30, 30 PIXEL 2007 ; // B / H
FILE c_path1 + "Save.bmp", "", "", ;
c_path1 + "Setup.bmp" ;
ACTION ( oFieldget:Refresh(), ;
cField := oProject:FieldName(nColNo), ;
oProject:FieldPut( cField, cFieldget ), ;
oProject:Save(), oBrw:RefreshCurrent() ) ;
NOBORDER LEFT
oBtnSys[8]:lTransparent := .T.
oBtnSys[8]:cToolTip := { "Save new value", "SAVE", 1, CLR_BLACK, 14089979 }
@ 257, 805 BTNBMP oBtnSys[9] OF oDlg ;
SIZE 30, 30 PIXEL 2007 ; // B / H
FILE c_path1 + "Delete.bmp", "", "", ;
c_path1 + "Cut.bmp" ;
ACTION ( cFieldget := SPACE( 200 ), oFieldget:Refresh(), ;
cField := oProject:FieldName(nColNo), ;
oProject:FieldPut( cField, cFieldget ), ;
oProject:Save(), oBrw:RefreshCurrent() ) ;
NOBORDER LEFT
oBtnSys[9]:lTransparent := .T.
oBtnSys[9]:cToolTip := { "Delete value", "DELETE", 1, CLR_BLACK, 14089979 }
ACTIVATE DIALOG oDlg CENTERED ;
ON iNIT oDlg:SetBrush( oBrush )
RELEASE BRUSH oBrush
RELEASE FONT oFontSys, oFontLarge
CLOSE DATABASE
RETURN NIL
// ---------------
STATIC FUNCTION SET_GROUP( oProject, nGrpPos)
oProject:ORDSCOPE(0, NIL )
oProject:ORDSCOPE(1, NIL )
IF nGrpPos = 1
oProject:ORDSCOPE(0, "A" )
oProject:ORDSCOPE(1, "A" )
ELSEIF nGrpPos = 2
oProject:ORDSCOPE(0, "C" )
oProject:ORDSCOPE(1, "C" )
ELSEIF nGrpPos = 3
oProject:ORDSCOPE(0, "D" )
oProject:ORDSCOPE(1, "D" )
ELSEIF nGrpPos = 4
oProject:ORDSCOPE(0, "F" )
oProject:ORDSCOPE(1, "F" )
ELSEIF nGrpPos = 5
oProject:ORDSCOPE(0, "G" )
oProject:ORDSCOPE(1, "G" )
ENDIF
RETURN NIL