FiveDBU para 32/64 bits
Posted: Wed May 30, 2012 12:02 am
En desarrollo...
FiveDBU.prg
FiveDBU.prg
Code: Select all
#include "FiveWin.ch"
#include "xbrowse.ch"
REQUEST DBFCDX
static oWnd
//----------------------------------------------------------------------------//
function Main()
local oBar
DEFINE WINDOW oWnd TITLE "FiveDBU" MDI MENU BuildMenu()
DEFINE BUTTONBAR oBar OF oWnd 2010 SIZE 70, 70
DEFINE BUTTON OF oBar PROMPT "New" FILENAME "../bitmaps/32x32/new.bmp"
DEFINE BUTTON OF oBar PROMPT "Open" FILENAME "../bitmaps/32x32/open.bmp" ACTION Open()
DEFINE BUTTON OF oBar PROMPT "Exit" FILENAME "../bitmaps/32x32/exit.bmp" ACTION oWnd:End()
DEFINE MSGBAR PROMPT "FiveDBU 32/64 bits" OF oWnd 2010 KEYBOARD DATE
ACTIVATE WINDOW oWnd MAXIMIZED ;
VALID MsgYesNo( "Want to end ?" )
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Files"
MENU
MENUITEM "New..."
MENUITEM "Open..." ACTION Open()
SEPARATOR
MENUITEM "Exit" ACTION oWnd:End()
ENDMENU
// oMenu:AddEdit()
oMenu:AddMdi()
oMenu:AddHelp( "FiveDBU", "(c) FiveTech Software 2012" )
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
function Open()
local oWnd, cFileName := cGetFile( "*.dbf", "Please select a DBF" )
local oBar, oBrw, oMsgBar
if ! File( cFileName )
return nil
endif
if File( cFileNoExt( cFileName ) + ".ntx" )
USE ( cFileName ) VIA "DBFNTX" NEW
else
USE ( cFileName ) VIA "DBFCDX" NEW
endif
DEFINE WINDOW oWnd TITLE cFileName MDICHILD
DEFINE BUTTONBAR oBar OF oWnd 2010 SIZE 70, 70
DEFINE BUTTON OF oBar PROMPT "Add" FILENAME "../bitmaps/32x32/plus.bmp" ;
ACTION ( ( oBrw:cAlias )->( DbAppend() ), oBrw:Refresh(), oBrw:SetFocus() )
DEFINE BUTTON OF oBar PROMPT "Edit" FILENAME "../bitmaps/32x32/edit.bmp" ACTION ( oBrw:cAlias )->( Edit() )
DEFINE BUTTON OF oBar PROMPT "Del" FILENAME "../bitmaps/32x32/minus.bmp" ACTION oWnd:End()
DEFINE BUTTON OF oBar PROMPT "Struct" FILENAME "../bitmaps/32x32/setup.bmp" ;
ACTION ( oBrw:cAlias )->( Struct() ) GROUP
DEFINE BUTTON OF oBar PROMPT "Exit" FILENAME "../bitmaps/32x32/exit.bmp" ACTION oWnd:End() GROUP
@ 0, 0 XBROWSE oBrw OF oWnd LINES ;
ON CHANGE oMsgBar:SetText( "Alias: " + Alias() + ;
" RecNo: " + AllTrim( Str( RecNo() ) ) + "/" + ;
AllTrim( Str( RecCount() ) ) )
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:bClrStd = { || If( oBrw:KeyNo() % 2 == 0, ;
{ CLR_BLACK, RGB( 198, 255, 198 ) }, ;
{ CLR_BLACK, RGB( 232, 255, 232 ) } ) }
oBrw:bClrSel = { || { CLR_WHITE, RGB( 0x33, 0x66, 0xCC ) } }
oBrw:CreateFromCode()
oBrw:SetFocus()
oBrw:bLDblClick = { || ( oBrw:cAlias )->( Edit() ) }
oWnd:oClient = oBrw
DEFINE MSGBAR oMsgBar PROMPT "Alias: " + Alias() + " RecNo: " + ;
AllTrim( Str( RecNo() ) ) + "/" + ;
AllTrim( Str( RecCount() ) ) OF oWnd 2010
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
function Edit()
local oWnd, aRecord := ( Alias() )->( LoadRecord() ), oBar, oBrw, oMsgBar
local cAlias := Alias(), oBtnSave
DEFINE WINDOW oWnd TITLE "Edit " + Alias() MDICHILD
DEFINE BUTTONBAR oBar OF oWnd 2010 SIZE 70, 70
DEFINE BUTTON oBtnSave OF oBar PROMPT "Save" FILENAME "../bitmaps/32x32/floppy.bmp"
oBtnSave:Disable()
DEFINE BUTTON OF oBar PROMPT "Prev" FILENAME "../bitmaps/32x32/prev.bmp" ACTION ( cAlias )->( DbSkip( -1 ) ) GROUP
DEFINE BUTTON OF oBar PROMPT "Next" FILENAME "../bitmaps/32x32/next.bmp" ACTION ( cAlias )->( DbSkip( 1 ) )
DEFINE BUTTON OF oBar PROMPT "Exit" FILENAME "../bitmaps/32x32/exit.bmp" ACTION oWnd:End() GROUP
@ 0, 0 XBROWSE oBrw OF oWnd ARRAY aRecord AUTOCOLS LINES ;
HEADERS "FieldName", "Value" COLSIZES 150, 400 FASTEDIT
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:bClrStd = { || If( oBrw:KeyNo() % 2 == 0, ;
{ CLR_BLACK, RGB( 198, 255, 198 ) }, ;
{ CLR_BLACK, RGB( 232, 255, 232 ) } ) }
oBrw:bClrSel = { || { CLR_WHITE, RGB( 0x33, 0x66, 0xCC ) } }
oBrw:CreateFromCode()
oBrw:SetFocus()
oWnd:oClient = oBrw
DEFINE MSGBAR oMsgBar PROMPT " RecNo: " + AllTrim( Str( RecNo() ) ) + "/" + ;
AllTrim( Str( RecCount() ) ) OF oWnd 2010
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
function LoadRecord()
local aRecord := {}, n
for n = 1 to FCount()
AAdd( aRecord, { FieldName( n ), cValToChar( FieldGet( n ) ) } )
next
return aRecord
//----------------------------------------------------------------------------//
function Struct()
local oDlg, oBrw, aFields := DbStruct()
DEFINE DIALOG oDlg TITLE Alias() + " fields" SIZE 400, 400
@ 0, 0 XBROWSE oBrw ARRAY aFields AUTOCOLS LINES ;
HEADERS "Name", "Type", "Len", "Dec" ;
COLSIZES 150, 50, 80, 80
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:bClrStd = { || If( oBrw:KeyNo() % 2 == 0, ;
{ CLR_BLACK, RGB( 198, 255, 198 ) }, ;
{ CLR_BLACK, RGB( 232, 255, 232 ) } ) }
oBrw:bClrSel = { || { CLR_WHITE, RGB( 0x33, 0x66, 0xCC ) } }
oBrw:CreateFromCode()
oDlg:oClient = oBrw
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( BuildStructBar( oDlg, oBrw ), oDlg:Resize(), oBrw:SetFocus() )
return nil
//----------------------------------------------------------------------------//
function BuildStructBar( oDlg, oBrw )
local oBar
DEFINE BUTTONBAR oBar OF oDlg 2010 SIZE 70, 70
DEFINE BUTTON OF oBar PROMPT "Code" FILENAME "../bitmaps/32x32/source.bmp" ;
ACTION ( TxtStruct(), oBrw:SetFocus() )
DEFINE BUTTON OF oBar PROMPT "Exit" FILENAME "../bitmaps/32x32/exit.bmp" ;
ACTION oDlg:End() GROUP
return nil
//----------------------------------------------------------------------------//
function TxtStruct()
local cCode := "local aFields := { ", n
for n = 1 to FCount()
if n > 1
cCode += Space( 27 )
endif
cCode += '{ "' + FieldName( n ) + '", "' + ;
FieldType( n ) + '", ' + ;
AllTrim( Str( FieldLen( n ) ) ) + ", " + ;
AllTrim( Str( FieldDec( n ) ) ) + " },;" + CRLF
next
cCode = SubStr( cCode, 1, Len( cCode ) - 4 ) + " }"
MemoEdit( cCode, "Code" )
return nil
//----------------------------------------------------------------------------//