by biro2000 » Wed Nov 22, 2006 12:10 pm
Armando,
I am using a piece of \FWH\Samples\TestTcBr.prg as example. I just changed:
ADD COLUMN TO BROWSE oBrw ;
DATA FieldWBlock("BAKIYE", Select("Stok")) ;
HEADER "Bakiye" ;
PICTURE "###,###.##" ;
EDITABLE ;
WIDTH 70 PIXELS ;
VALID {|o| MyFunction( o:varGet() ) }
My code is:
#include "fivewin.ch"
#include "TCBrowse.ch"
// always put TCBrowse.ch AFTER filewin.ch
Static MainWnd
Function Main()
Local hBWCC
Set Date Format "dd/mm/yyyy"
SET _3DLOOK ON
hBWCC := LoadLibrary( "BWCC32.DLL" )
SET RESOURCES TO "TCBR32.DLL" // Our stored screens
BWCCRegister( GetResources() )
DEFINE WINDOW MainWnd FROM 1, 1 TO 22, 75 ;
TITLE "Test SAMPLE TESTCBR.PRG 08/11/2006" ;
MENU BuildMenu()
SET MESSAGE OF MainWnd TO "Great idea by Salim Anter" CENTERED
USE Stok
IF ! ( File("StokName.NTX") .and. File("MaliYet.NTX") )
INDEX ON Stok->MaliYet TO MaliYet
INDEX ON Stok->StokName TO StokName
ELSE
SET INDEX TO StokName, MaliYet
ENDIF
ACTIVATE WINDOW MainWnd MAXIMIZED
SET RESOURCES TO
Return( NIL )
Function BuildMenu
local oMenu
MENU oMenu
MENUITEM OemToAnsi( "&Create" ) ;
ACTION NewBrowse( )
ENDMENU
Return( oMenu )
#define OBM_CLOSE 32754
#define OBM_UPARROW 32753
#define OBM_DNARROW 32752
#define OBM_CHECKBOXES 32759
#define OBM_CHECK 32760
#define OCR_NORMAL 32512
#define OCR_CROSS 32515
Function NewBrowse( )
Static aX
Local oDlg, oBrw, oCol, oFont, oSay
Local _hOn := LoadBitMap(0, OBM_CHECK) // Use OEM system resources
Local _hOff := Chr(160) // This will be treated as if it were bitmap
if aX == nil
aX := Array(3)
aX[1] := LoadBitMap( GetResources(), "Z_Green_X")
aX[2] := LoadBitMap( GetResources(), "Z_Red_X")
aX[3] := LoadBitMap( GetResources(), "Z_Blank")
endif
DEFINE FONT oFont NAME "System" SIZE 8, 16 BOLD // 6, 15
DEFINE DIALOG oDlg of MainWnd NAME "Aktivite"
REDEFINE BROWSE oBrw ID 999 OF oDlg ;
MESSAGE "You may open multi-copies, DblCkick to edit, "+ ;
"1st column frozen" FONT oFont ;
ON RIGHT CLICK MsgInfo( "RightClick" ) ;
ON CHANGE MsgBeep()
oBrw:lLogicDrop := .t. // use crazy logic dropbox
oBrw:lNoHScroll := .t. // don't use that pesky horiz scroll bar
oBrw:nAdjColumn := 3 // expand this column to flush table right
oBrw:nFreeze := 3 // 0 disables freezing 1 is leftmost
oBrw:hBmpCursor := LoadBitmap( GetResources(), "Z_Triangle" )
oBrw:bLDblClick := { | nRow, nCol | EditCell( oBrw, nRow, nCol ) }
ADD COLUMN TO oBrw DATA "" SIZE 15 // blank cursor colm
//ADD COLUMN TO oBrw NOBAR ;
// BITMAP DATA If ( Stok->FATURA > Stok->BAKIYE , aX[1] , ;
// If ( Stok -> FATURA < Stok->BAKIYE , aX[2], aX[3] ) )
//ADD COLUMN TO BROWSE oBrw ;
// DATA OemToAnsi( Stok ->STOKNAME ) TAG StokName ;
// HEADER "Stok" SIZE 100
ADD COLUMN TO BROWSE oBrw ;
DATA FieldWBlock("BAKIYE", Select("Stok")) ; // we can edit it
HEADER "Bakiye" OEM ALIGN RIGHT ;
PICTURE "###,###.##" EDITABLE WIDTH 70 PIXELS ;
COLOR If( Stok->BAKIYE < 0, CLR_RED, CLR_BLACK), {||CLR_GREEN } ;
MESSAGE "Enter a negative number" ;
VALID {|o| MyFunction( o:varGet() ) }
ERROR MESSAGE "Value must be"+CRLF+"positive or 0"
ADD COLUMN TO BROWSE oBrw ;
DATA FieldWBlock("BAKIYE", Select("Stok")) ; // we can edit it
HEADER "Bakiye" OEM ALIGN RIGHT ;
PICTURE "###,###.##" EDITABLE WIDTH 70 PIXELS ;
COLOR If( Stok->BAKIYE < 0, CLR_RED, CLR_BLACK), {||CLR_GREEN } ;
MESSAGE "Enter a negative number" ;
VALID IF ValCampo( x ) ;
ERROR MESSAGE "Value must be"+CRLF+"positive or 0"
oBrw:AddColumn( TCColumn( ):New( OemToAnsi( "Fatura" ) , ;
FieldWBlock("Fatura", Select("Stok")), ;
"###,###.##" , nil, nil, DT_RIGHT, 90 , nil, .t.) )
DEFINE COLUMN oCol ;
DATA If ( Stok->FATURA > Stok->BAKIYE , _hOn , _hOff) BITMAP;
NOHILITE SIZE 15 COLOR "N/R" CENTER
oBrw:AddColumn( oCol )
//ADD COLUMN TO oBrw ALIGN RIGHT TAG "MaliYet" SIZE 100 ;
// DATA Stok -> MALIYET PICTURE "##,###,###" ;
// HEAD "Maliyet"
//ADD COLUMN TO oBrw ALIGN RIGHT ;
// HEAD "Ciro" DATA FieldBlock("CIRO") ;
// PICT "@Z #,###,###.##" SIZE 90 ;
// EDIT VALID {|o| o:varGet() < 0} ;
// MESSAGE "Current data causes lots of errors" ;
// ERROR MESSAGE "Value Must be"+CRLF+"Less than 0"
// ADD COLUMN TO BROWSE oBrw ;
// HEADER "Devirtarih" ALIGN CENTER ;
// DATA FieldBlock("Devirtarih") PICTURE "@D" EDIT
// ADD COLUMN TO oBrw TITLE "L" PICT "Y" SIZE 15 ;
// DATA Stok->FATURA > Stok->BAKIYE EDITABLE // but not savable
REDEFINE BUTTON ID IDOK OF oDlg ACTION oDlg:End( ) ;
MESSAGE "Get outta here"
REDEFINE SAY oSay VAR oBrw:cSeek ID 211 OF oDlg ;
COLORS CLR_WHITE, CLR_CYAN
oBrw:bSeekChange := {|| oSay:Refresh() }
REDEFINE BUTTON ID 101 OF oDlg ;
ACTION oBrw:SwitchCols(5, 9):Exchange(3, 6) ;
MESSAGE "Switch columns 5 and 9, exchange columns 3 and 6"
REDEFINE BUTTON ID 102 OF oDlg ;
ACTION ( If(oBrw:oCtx != Nil, oBrw:oCtx:Display(), nil ), ;
oBrw:SetFocus() ) MESSAGE "Display Context"
REDEFINE BUTTON ID 103 OF oDlg ;
ACTION oBrw:Report() ;
MESSAGE "Print a Report"
ACTIVATE DIALOG oDlg CENTERED NOWAIT
Return( NIL )
DLL FUNCTION BWCCRegister( hInst AS LONG ) AS LONG PASCAL ;
LIB "BWCC32.DLL"
procedure AppSys // XBase++ requirement
return
////////////////////////////////////////////////////////////////////////////////////
function MyFunction( valnum )
local retorno := .t.
if valnum >= 500
retorno := .t.
else
retorno := .f.
? "return: FALSE"
endif
return( retorno )
Thank you,
Luciano