WDBU clone - xbrDBU

WDBU clone - xbrDBU

Postby Otto » Sat Aug 27, 2011 3:58 pm

I started copying from the FWH samples code to a new sample xbrDBU.prg.

xbrDBU.prg should become a clone of WDBU.

At the moment “Open” and “New” is working.
All the menu items WDBU has are there.
At the moment this items are only dummy functions.
I hope many of you will help to build this clone.

Best regards,
Otto

Image

xbrDBU.prg

Code: Select all  Expand view

#include 'fivewin.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX
#DEFINE EXENAME "xWDBU"
//----------------------------------------------------------------------------//

function Main()

   local oWnd, oBrw, oFont

   SetBalloon( .t. )
   xbrNumformat( ,.t. )

   SET XBROWSE TO TXBrCode()

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12

   DEFINE WINDOW oWnd MDI ;
      TITLE 'XBrowse Designer' ;
      MENU MainMenu()
   oWnd:SetFont( oFont )
    // MakeBar( oWnd )
    // oWnd:oBar:cToolTip := { || "My Color" }

   SET MESSAGE OF oWnd TO '' 2007

   ACTIVATE WINDOW oWnd ;
      ON DROPFILES Files2Brw( nRow, nCol, aFiles )

return nil

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

INIT PROCEDURE PrgInit

   SET DELETED ON
   SET EXCLUSIVE OFF

   SET DATE ITALIAN
   SET CENTURY ON

   RDDSetDefault( 'DBFCDX' )

return

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

static function MakeBar( oWnd )

   local oBar

   DEFINE BUTTONBAR oBar OF oWnd SIZE 56,64 2007

   DEFINE BUTTON OF oBar PROMPT 'Open Data' ;
      RESOURCE 'Open' ;
      ACTION NewFile()

    DEFINE BUTTON OF oBar PROMPT 'dbfbuild' ;
      RESOURCE 'Open' ;
      ACTION dbfbuild()



return oBar

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

static function MainMenu()

   local oMenu,URLNAME := "http://www.fivetech.com"

   MENU oMenu 2007
     
          MENUITEM "File"
 
          MENU
               MENUITEM "&New"+chr(9)+"Ctrl+U" ;
                    RESOURCE "NEW" ;
                    ACTION  NewFile(dbfbuild()) ;  //MsgInfo( "Fbrowse(DbfBuild(),.t.) ") ;
                    MESSAGE "Create new file" ;
                    ACCELERATOR ACC_CONTROL, asc("U") ;
                    ENABLED
               MENUITEM "&Open"+chr(9)+"Ctrl+A" ;
                    RESOURCE "OPEN" ;
                    ACTION NewFile() ;
                    MESSAGE "Open file" ;
                    ACCELERATOR ACC_CONTROL, asc("A") ;
                    ENABLED
               MENUITEM "C&lose"+chr(9)+"Ctrl+E" ;
                    RESOURCE "SAVE" ;
                    ACTION WndMain():oWnd:End() ;
                    MESSAGE "Close file" ;
                    ACCELERATOR ACC_CONTROL, asc("E") ;
                    ENABLED
               MENUITEM "&Print"+chr(9)+"Ctrl+T" ;
                    RESOURCE "PRINTER" ;
                    ACTION MsgInfo( " oDbfWnd:Report() ") ;
                    MESSAGE "Print file" ;
                    ACCELERATOR ACC_CONTROL, asc("T") ;
                    ENABLED
               MENUITEM "Command &Interpreter" ;
                    RESOURCE "DOT" ;
                    ACTION MsgInfo( " DotNew()  ");
                    MESSAGE "Invokes the command interpreter" ;
                    ENABLED
               MENUITEM "&Modify structure"+chr(9)+"Ctrl+M" ;
                    RESOURCE "DESIGN" ;
                    ACTION  NewFile(dbfbuild()) ;
                    MESSAGE "Modify file structure" ;
                    ACCELERATOR ACC_CONTROL, asc("M") ;
                    ENABLED
               MENUITEM "Multi-&file operation" ;
                    RESOURCE "MULTFILE" ;
                    ACTION MsgInfo( " MultiFile()  ");
                    MESSAGE "&Multi-file operation" ;
                    ENABLED
               MENUITEM "Import from ODBC database" ;
                    RESOURCE "IMPORT" ;
                    ACTION MsgInfo( " ImportODBC(oWnd)  ");
                    MESSAGE "Import data from a ODBC database" ;
                    ENABLED
               MENUITEM "&Configuration" ;
                    RESOURCE "CONFIG" ;
                    ACTION MsgInfo( " AppConfig() ");
                    MESSAGE "Program configuration" ;
                    ENABLED
               SEPARATOR
               MENUITEM "Specif&y printer" ;
                    RESOURCE "PROPERTY" ;
                    ACTION  PrinterSetup()  ;
                    MESSAGE "Printer configuration" ;
                    ENABLED
               MENUITEM "&Map Network Drive" ;
                    RESOURCE "NETCONNE" ;
                    ACTION  MsgInfo(" WNetConnectDialog() ") ;
                    MESSAGE "Connect to a network drive" ;
                    ENABLED
               MENUITEM "&Disconnect Network Drive" ;
                    RESOURCE "NETDISCO" ;
                    ACTION  MsgInfo(" WNetDisconnect() ") ;
                    MESSAGE "Disconnect from a network drive" ;
                    ENABLED
               MENUITEM "&Exit"+chr(9)+"Alt+F4" ;
                    RESOURCE "EXIT" ;
                    ACTION WndMain():End() ;
                    MESSAGE "Exit from the application" ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Edit"
          MENU
               MENUITEM "&Copy record"+chr(9)+"Ctrl+C" ;
                    RESOURCE "COPY" ;
                    ACTION MsgInfo( " oDbfWnd:CopyRec() ") ;
                    MESSAGE "Copy record to the Clipboard" ;
                    ACCELERATOR ACC_CONTROL, asc("C") ;
                    ENABLED
               MENUITEM "&Paste record"+chr(9)+"Ctrl+V" ;
                    RESOURCE "PASTE" ;
                    ACTION MsgInfo( " oDbfWnd:PasteRec() ");
                    MESSAGE "Paste record from the Clipboard" ;
                    ACCELERATOR ACC_CONTROL, asc("V")
               SEPARATOR
               MENUITEM "&Insert record"+chr(9)+"Ctrl+Insert" ;
                    RESOURCE "NEW" ;
                    ACTION MsgInfo( " oDbfWnd:AppRec() ");
                    MESSAGE "Append record" ;
                    ACCELERATOR ACC_CONTROL, VK_INSERT ;
                    ENABLED
               MENUITEM "&Del/Recall record"+chr(9)+"Ctrl+Del" ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DelRec() ");
                    MESSAGE "Del actual record" ;
                    ACCELERATOR ACC_CONTROL, VK_DELETE ;
                    ENABLED
               MENUITEM "&Edit field"+chr(9)+"Enter" ;
                    RESOURCE "TEXTBOX" ;
                    ACTION MsgInfo( " oDbfWnd:EditFld() ");
                    MESSAGE "Edit actual record field" ;
                    ENABLED
                    //ACCELERATOR ACC_SHIFT, VK_RETURN ;

               MENUITEM "&Edit record"+chr(9)+"CTRL+Enter" ;
                    RESOURCE "EDIT" ;
                    ACTION MsgInfo( " oDbfWnd:EditRec() ");
                    MESSAGE "Edit actual record (all fields)" ;
                    ENABLED
                    //ACCELERATOR ACC_CONTROL, VK_RETURN ;

          ENDMENU
         
          MENUITEM "&Navigation"
          MENU
               MENUITEM "&Search"+chr(9)+"Ctrl+S" ;
                    RESOURCE "SEARCH" ;
                    ACTION MsgInfo( " oDbfWnd:Seek() ");
                    MESSAGE "Search records using the active index" ;
                    ACCELERATOR ACC_CONTROL, asc("S") ;
                    ENABLED
               MENUITEM "&Go to"+chr(9)+"Ctrl+G" ;
                    ACTION MsgInfo( " oDbfWnd:Ira() ");
                    MESSAGE "Jump to a record by its Recno()" ;
                    ACCELERATOR ACC_CONTROL, asc("G") ;
                    ENABLED
               MENUITEM "S&kip"+chr(9)+"Ctrl+K" ;
                    ACTION MsgInfo( " oDbfWnd:Skip() ");
                    MESSAGE "Skip records" ;
                    ACCELERATOR ACC_CONTROL, asc("K") ;
                    ENABLED
               SEPARATOR
               MENUITEM "&Locate"+chr(9)+"F3" ;
                    ACTION MsgInfo( " oDbfWnd:Locate() ");
                    MESSAGE "Locate record" ;
                    ACCELERATOR ACC_NORMAL, VK_F3 ;
                    ENABLED
               MENUITEM "&Continue"+chr(9)+"F4" ;
                    ACTION MsgInfo( " oDbfWnd:Locate(.T.)") ;
                    MESSAGE "Locate next record" ;
                    ACCELERATOR ACC_NORMAL, VK_F4 ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Indexes"
          MENU
               MENUITEM OemtoAnsi("&Open Index"+chr(9)+"Ctrl+X") ;
                    RESOURCE "OPEN" ;
                    ACTION MsgInfo( " oDbfWnd:OpenIndex() ");
                    MESSAGE "Select an index file" ;
                    ACCELERATOR ACC_CONTROL, asc("X") ;
                    ENABLED
               MENUITEM OemtoAnsi("&Close Index"+chr(9)+"Ctrl+L") ;
                    RESOURCE "SAVE" ;
                    ACTION MsgInfo( " oDbfWnd:CloseIndex()") ;
                    MESSAGE "Close current index file" ;
                    ACCELERATOR ACC_CONTROL, asc("L") ;
                    ENABLED
               MENUITEM "&Previous order"+chr(9)+"Ctrl+P" ;
                    RESOURCE "PREV" ;
                    ACTION MsgInfo( " oDbfWnd:PrevOrder()");
                    MESSAGE "Go to previous order" ;
                    ACCELERATOR ACC_CONTROL, asc("P") ;
                    ENABLED
               MENUITEM "&Next order"+chr(9)+"Ctrl+N" ;
                    RESOURCE "NEXT" ;
                    ACTION MsgInfo( " oDbfWnd:NextOrder() ");
                    MESSAGE "Go to next order" ;
                    ACCELERATOR ACC_CONTROL, asc("N") ;
                    ENABLED
               MENUITEM OemtoAnsi("&Filter by scope"+chr(9)+"Ctrl+F") ;
                    RESOURCE "FILTER" ;
                    ACTION MsgInfo( " oDbfWnd:Scope() ");
                    MESSAGE "Set a scope to filter records, based on the active index" ;
                    ACCELERATOR ACC_CONTROL, asc("F") ;
                    ENABLED
               MENUITEM OemtoAnsi("&Create new index"+chr(9)+"Ctrl+W") ;
                    RESOURCE "INDEX" ;
                    ACTION MsgInfo( " oDbfWnd:BuildIndex() ");
                    MESSAGE "Create a new index file or Tag" ;
                    ACCELERATOR ACC_CONTROL, asc("W") ;
                    ENABLED
               SEPARATOR
               MENUITEM "&Delete Order" ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DelTag() ");
                    MESSAGE "Delete current Order (Tag)" ;
                    ENABLED
               MENUITEM "&Reindex"+chr(9)+"Ctrl+R" ;
                    RESOURCE "REPEAT" ;
                    ACTION MsgInfo( " oDbfWnd:Reindex() ");
                    MESSAGE "Reindex all the open indexes" ;
                    ACCELERATOR ACC_CONTROL, asc("R") ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Utilities"
          MENU
               MENUITEM "&More information"+chr(9)+"Ctrl+I" ;
                    RESOURCE "PROPERTY" ;
                    ACTION MsgInfo( " oDbfWnd:Info() ");
                    MESSAGE "Show additional information about the current file" ;
                    ACCELERATOR ACC_CONTROL, asc("I") ;
                    ENABLED
               MENUITEM "&Browse Columns"+chr(9)+"Ctrl+B" ;
                    RESOURCE "TBROWSE" ;
                    ACTION MsgInfo( " oDbfWnd:SetColumn() ");
                    MESSAGE "Columns configuration" ;
                    ACCELERATOR ACC_CONTROL, asc("B") ;
                    ENABLED
               MENUITEM "&Relations" ;
                    RESOURCE "CHAIN" ;
                    ACTION MsgInfo( " oDbfWnd:Relations() ");
                    MESSAGE "Establish relations with other databases" ;
                    ENABLED
               MENUITEM "Establish &Filter" ;
                    RESOURCE "FILTER" ;
                    ACTION MsgInfo( " oDbfWnd:Filter() ");
                    MESSAGE "Set the criteria by which to filter records" ;
                    ENABLED
               MENUITEM "Coun&t" ;
                    ACTION MsgInfo( " oDbfWnd:Count() ");
                    MESSAGE "Count the number of records meeting a certain criteria" ;
                    ENABLED
               MENUITEM "&Statistics" ;
                    RESOURCE "STATICS" ;
                    ACTION MsgInfo( " oDbfWnd:Sum() ");
                    MESSAGE "Statistics calculations of all numeric fields" ;
                    ENABLED
               MENUITEM "&Graphics" ;
                    RESOURCE "GRAPH" ;
                    ACTION MsgInfo( " oDbfWnd:Graphics() ");
                    MESSAGE "Graphics based on current data file" ;
                    ENABLED
               SEPARATOR
               MENUITEM "&Append from..." ;
                    RESOURCE "IMPORT" ;
                    ACTION MsgInfo( " oDbfWnd:AppendFrom() ");
                    MESSAGE "Append records from another file" ;
                    ENABLED
               MENUITEM "&Copy to..." ;
                    RESOURCE "COPY" ;
                    ACTION MsgInfo( " oDbfWnd:CopyTo() ");
                    MESSAGE "Copy records to another file" ;
                    ENABLED
               MENUITEM "&Delete..." ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DeleteFor() ");
                    MESSAGE "Delete all records matching a certain criteria" ;
                    ENABLED
               MENUITEM "Reca&ll..." ;
                    ACTION MsgInfo( " oDbfWnd:RecallFor() ");
                    MESSAGE "Recall all records matching a certain criteria" ;
                    ENABLED
               MENUITEM "R&eplace..." ;
                    ACTION MsgInfo( " oDbfWnd:ReplaceFor() ");
                    MESSAGE "Replace all records matching a certain criteria" ;
                    ENABLED
               MENUITEM "S&cript process..." ;
                    RESOURCE "SCRIPT" ;
                    ACTION MsgInfo( " oDbfWnd:Script()  ");
                    MESSAGE "Process a script file to all records matching a certain criteria" ;
                    ENABLED
               MENUITEM "Pac&k" ;
                    ACTION MsgInfo( " oDbfWnd:Pack()  ");
                    MESSAGE "Eliminate phisically deleted records" ;
                    ENABLED
               MENUITEM "&Zap" ;
                    ACTION MsgInfo( " oDbfWnd:Zap()  ");
                    MESSAGE "Delete every record in the database" ;
                    ENABLED
               SEPARATOR
               MENUITEM "&Oem to Ansi" ;
                    ACTION MsgInfo( " oDbfWnd:OtoA(.F.)  ");
                    MESSAGE "Translate from OEM to ANSI" ;
                    ENABLED
               MENUITEM "A&nsi to Oem" ;
                    ACTION MsgInfo( " oDbfWnd:OtoA(.T.)  ");
                    MESSAGE "Translate from ANSI to OEM" ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Windows"
          MENU
          MENUITEM "&Cascade" ;
               RESOURCE "CASCAWND" ;
               MESSAGE OemToAnsi( "Organize windows on cascade" ) ;
               ACTION WndMain():Cascade()
          MENUITEM "&Vertical mosaic" ;
               RESOURCE "MOSVRWND" ;
               MESSAGE OemToAnsi( "Organize windows on vertical mosaic" ) ;
               ACTION WndMain():Tile()
          MENUITEM "&Horizontal mosaic" ;
               RESOURCE "MOSHRWND" ;
               ACTION WndMain():Tile( .t. );
               MESSAGE OemToAnsi( "Organize windows on horizontal mosaic" )
          MENUITEM "&Minimize Windows" ;
               RESOURCE "MINIMWND" ;
               ACTION WndMain():IconizeAll() ;
               MESSAGE "Minimize all Windows"
          MENUITEM "&Restore all windows" ;
               RESOURCE "MAXIMWND" ;
               ACTION Asend(WndMain():oWndClient:aWnd,'NORMAL') ;
               MESSAGE "Restore all windows"
          MENUITEM "C&lose windows" ;
               RESOURCE "CLOSEWND" ;
               ACTION WndMain():CloseAll() ;
               MESSAGE "Close all windows"
          MENUITEM "&Organize Icons" ;
               MESSAGE OemToAnsi( "Organize minimized windows" ) ;
               ACTION WndMain():ArrangeIcons()
          ENDMENU
         
          MENUITEM "&Help"
          MENU
               MENUITEM "&Index"+chr(9)+"F1" ;
                    RESOURCE "HELP" ;
                    ACTION MsgInfo( " HelpIndex()  ");
                    MESSAGE "Shows the Help contents" ;
                    ENABLED
               MENUITEM "&Using Help" ;
                    ACTION MsgInfo( " Winhelp.hlp") ;
                    MESSAGE "More information about using help" ;
                    ENABLED
               MENUITEM "&Readme text file" ;
                    RESOURCE "NOTEPAD" ;
                    ACTION  WinExec("Notepad readme.txt") ;
                    MESSAGE "Modifications and enhancements not present on the help file" ;
                    ENABLED
               SEPARATOR
               MENUITEM "Register Dbu for Windows" ;
                    ACTION MsgInfo( " (SetShare(SerialRegister(GetSetEmpresa())))  ");
                    MESSAGE "Register Dbu for Windows" ;
                    ENABLED
               MENUITEM "OZ &Web page (Internet)" ;
                    RESOURCE "INTERNET" ;
                    ACTION ShellExecute(oWnd:hWnd, "open", URLNAME) ;
                    MESSAGE "OZ Web page on the Internet" ;
                    ENABLED
               
               MENUITEM "&Send mail" ;
                    RESOURCE "MAIL" ;
                    ACTION  MsgInfo(" SendMail() ") ;
                    MESSAGE "Contact with us via eMail" ;
                    ENABLED
               MENUITEM "&Calculator" ;
                    RESOURCE "CALC" ;
                    ACTION  WinExec("Calc.exe") ;
                    MESSAGE "Windows calculator" ;
                    ENABLED
               SEPARATOR
               MENUITEM "&About "+EXENAME ;
                    RESOURCE "INFO" ;
                    ACTION MsgInfo( " MsgLogo(GetSetEmpresa(),10000) ");
                    MESSAGE "More information about the program" ;
                    ENABLED
          ENDMENU

ENDMENU

return oMenu

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

static function files2brw( nRow, nCol, aFiles )

   local cFile

   for each cFile in aFiles
      if Upper( cFileExt( cFile ) ) == 'DBF'
         File2Brw( cFile )
      else
         CheckBrwDrop( ClientToScreen( WndMain():hWnd, { nRow, nCol } ), cFile)
      endif
   next

return nil

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

static function file2brw( cFile )

   local oWnd, oBrw, cAlias, cFileNoExt

   if !OpenFile( cFile, @cAlias, @cFileNoExt )
      return nil
   endif

   DEFINE WINDOW oWnd MDICHILD OF WndMain() ;
      TITLE cFileNoExt

   @ 0,0 XBROWSE oBrw OF oWnd ;
      ALIAS cAlias ;
      AUTOCOLS AUTOSORT FOOTERS LINES CELL NOBORDER

   AEval( oBrw:aCols, { |oCol| oCol:cCol := oCol:cHeader } )
   AEval( oBrw:aCols, { |oCol| oCol:cHeader := Upper( Left( oCol:cHeader, 1 ) ) + Lower( Substr( oCol:cHeader, 2 ) ) } )
   oBrw:bPopUp       := { |o| ColMenu( o ) }

   oBrw:CreateFromCode()
   oWnd:oClient   := oBrw

   BrwBtnBar( oBrw )
   SET MESSAGE OF oWnd TO cFile 2007
   ACTIVATE WINDOW oWnd

return nil

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

static function CheckBrwDrop( aPoint, cFile )

   local ownd, oBrw, nRow, nCol
   local nColPos, nRowPos

   if ( oWnd := WndMain():oWndActive ) != nil
      oBrw  := oWnd:oClient
      if oBrw != nil .and. oBrw:IsKindOf( TXBrowse() )
         aPoint   := ScreenToClient( oBrw:hWnd, aPoint )
         nRow     := aPoint[ 1 ]
         nCol     := aPoint[ 2 ]
         if oBrw:DropFile( nRow, nCol, cFile )
//            MsgInfo( 'handled' )
         else
            msginfo( 'Not Valid File' )
         endif
      endif
   endif

return nil

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

static function OpenFile( cFile, cAlias, cFileNoExt )

   local lOpen    := .f.
   local cDriver  := 'DBFCDX'

   if Upper( cFileExt( cFile ) ) == 'DBF'
      cFileNoExt  := cFileNoExt( cFile )
      cAlias   := cGetNewAlias( Left( cFileNoExt, 4 ) )
      TRY
         dbUseArea( .t., cDriver, cFile, cAlias, .t., .f. )
      CATCH
         MsgInfo( cFile + CRLF + 'can not be opened' )
         return .f.
      END
      lOpen := .t.
   else
      MsgInfo( 'Not a DBF File' )
   endif

return lOpen

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

static function NewFile()

   local cFile

   if ! Empty( cFile := cGetFile(   "DataFile (*.DBF)|*.dbf|",          ;
                                    "Select Data File to Browse",1,     ;
                                    "\fwh\samples" ) )
      File2Brw( cFile )
   endif


return nil

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


static function BrwbtnBar( oBrw )

   local oBar, oBtn

   DEFINE BUTTONBAR oBar OF oBrw:oWnd SIZE 56,64 3D 2007

   DEFINE BUTTON OF oBar ;
      RESOURCE "REPORT" TOP ;
      PROMPT "Report" ;
      MENU ReportMenu( oBrw ) ;
      ACTION This:ShowPopUp() ;
      MESSAGE "Print the browse contents" ;
      TOOLTIP { "Print Report", "Report" }

   DEFINE BUTTON OF oBar ;
      RESOURCE "EXCEL" TOP ;
      PROMPT "Excel" ;
      ACTION This:ShowPopUp() ;
      MENU ExcelMenu( oBrw ) ;
      MESSAGE "Export browse contents to Excel" ;
      TOOLTIP { "Export to Excel", "Excel" }

   DEFINE BUTTON oBtn OF oBar ;
      RESOURCE "CONFIG" TOP ;
      PROMPT "Config" ;
      MENU ConfigMenu( oBrw )  ;
      ACTION This:ShowPopUp() ;
      MESSAGE "Change background, Style2007, FastEdit option, etc" ;
      TOOLTIP { "Configure", "SetUp",,CLR_BLUE,nRGB(220,230,247) }

   DEFINE BUTTON OF oBar ;
      RESOURCE 'CODE' TOP ;
      PROMPT 'Source' ;
      ACTION ViewCode( oBrw ) ; //MemoEdit( oBrw:PrgCode() ) ;
      TOOLTIP 'Generate program source'

   DEFINE BUTTON OF oBar ;
      RESOURCE 'DLG' TOP ;
      PROMPT 'Dialog' ;
      ACTION SetBrwInDlg( oBrw ) ;
      TOOLTIP 'View Browse in Dialog'

return oBar

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

static function SetBrwInDlg( oBrw )

   local oWnd, oDlg

   oWnd  := oBrw:oWnd

   DEFINE DIALOG oDlg SIZE 800,600 PIXEL TITLE oWnd:cTitle


   ACTIVATE DIALOG oDlg ;
      ON INIT InitBrwDlg( oBrw, oDlg ) ;
      VALID ExitBrwDlg( oBrw, oWnd ) ;
      ON RIGHT CLICK ( SetWindowLong( oBrw:hWnd, -20, ;
         nXor( GetWindowLong( oBrw:hWnd, -20 ), 0x200 ) ) )


return nil

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

static function InitBrwDlg( oBrw, oDlg )

   local oWnd  := oBrw:oWnd
   local nColsWidth  := oBrw:GetDisplayColsWidth() + 24

   oBrw:oWnd   := oDlg
   SetParent( oBrw:hWnd, oDlg:hWnd )
   oBrw:nTop      := 20
   oBrw:nLeft     := 20
   oBrw:nHeight   := oDlg:nHeight - 80
   oBrw:nWidth    := oDlg:nWidth - 40
   if oBrw:nWidth > nColsWidth
      oBrw:nWidth       := nColsWidth
      oDlg:nWidth       := oBrw:nWidth + 40
   endif
   oBrw:Resize()
   oDlg:Center()
   oWnd:Hide()

return .f.

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

static function ExitBrwDlg( oBrw, oWnd )

   oBrw:oWnd   := oWnd
   SetParent( oBrw:hWnd, oWnd:hWnd )
   oWnd:oClient := oBrw
   oWnd:Show()
   oWnd:ReSize()

return .t.

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

static function ExcelMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Export to Excel" ACTION oBrw:ToExcel()
      MENUITEM "Export to Excel with Group Totals" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:ToExcel(,1)
   ENDMENU

return oPop

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

static function ReportMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Simple Report" ACTION oBrw:Report()
      MENUITEM "Report with Grouping" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:Report( nil, .t., .t., nil, 1 )
   ENDMENU

return oPop

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

static function ColMenu( ocol )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Align"
      MENU
         MENUITEM "Left Align" WHEN oCol:nDataStrAlign > 0 ;
            ACTION ( oCol:SetAlign( AL_LEFT ), oCol:oBrw:SetFocus() )
         MENUITEM "Center Align" WHEN oCol:nDataStrAlign != AL_CENTER ;
            ACTION ( oCol:SetAlign( AL_CENTER ), oCol:oBrw:SetFocus() )
         MENUITEM "Right Align" WHEN oCol:nDataStrAlign != AL_RIGHT ;
            ACTION ( oCol:SetAlign( AL_RIGHT ), oCol:oBrw:SetFocus() )
      ENDMENU
      MENUITEM "Freeze" ACTION ( oCol:oBrw:nFreeze := oCol:nPos, oCol:oBrw:Refresh(), oCol:oBrw:SetFocus() )
      MENUITEM "Stretch" ACTION ( oCol:oBrw:nStretchCol := oCol:nCreationOrder, oCol:oBrw:ReSize(), ;
                        oCol:oBrw:Refresh(), ;
                        oCol:oBrw:SetFocus() )


      MENUITEM "Edit" ACTION (   oCol:nEditType := If( oCol:nEditType > 0, 0, 1 ), ;
                                 oMenuItem:SetCheck( oCol:nEditType > 0 ) )

      MENUITEM 'Inspect' ACTION XBrowse( oCol )
      MENUITEM 'Rptcode' ACTION MsgInfo( oCol:RptCode() )

   ENDMENU

return oPop

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

static function ConfigMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "2007" CHECKED ;
         ACTION ( oBrw:l2007 := !oBrw:l2007, oMenuItem:SetCheck( oBrw:l2007 ), ;
                  oBrw:Refresh(), oBrw:SetFocus() )
      MENUITEM "FastEdit" ;
         ACTION ( oBrw:lFastEdit := !oBrw:lFastEdit, oMenuItem:SetCheck( oBrw:lFastEdit ), ;
                  oBrw:SetFocus() )
      MENUITEM "RecordSelector" CHECKED ;
         ACTION ( oBrw:lRecordSelector := !oBrw:lRecordSelector, ;
                  oMenuItem:SetCheck( oBrw:lRecordSelector ),    ;
                  oBrw:Refresh(), oBrw:SetFocus() )
      MENUITEM "HScroll" CHECKED ;
         ACTION ( oMenuItem:SetCheck( oBrw:SetHScroll( ! oBrw:lHScroll ) ) )

      MENUITEM "Marquee"
      MENU
         MENUITEM "NoMarquee"   ACTION ( oBrw:nMarqueeStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "DottedCell"  ACTION ( oBrw:nMarqueeStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "SolidCell"   ACTION ( oBrw:nMarqueeStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL cell"  ACTION ( oBrw:nMarqueeStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL RowRC" ACTION ( oBrw:nMarqueeStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL Row"   ACTION ( oBrw:nMarqueeStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL RowMS" ACTION ( oBrw:nMarqueeStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "Row LineStyle"
      MENU
         MENUITEM "No Lines"    ACTION ( oBrw:nRowDividerStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Black"       ACTION ( oBrw:nRowDividerStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Dark Gray"   ACTION ( oBrw:nRowDividerStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "ForeColor"   ACTION ( oBrw:nRowDividerStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Light Gray"  ACTION ( oBrw:nRowDividerStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Inset"       ACTION ( oBrw:nRowDividerStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Raised"      ACTION ( oBrw:nRowDividerStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "Col LineStyle"
      MENU
         MENUITEM "No Lines"    ACTION ( oBrw:nColDividerStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Black"       ACTION ( oBrw:nColDividerStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Dark Gray"   ACTION ( oBrw:nColDividerStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "ForeColor"   ACTION ( oBrw:nColDividerStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Light Gray"  ACTION ( oBrw:nColDividerStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Inset"       ACTION ( oBrw:nColDividerStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Raised"      ACTION ( oBrw:nColDividerStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "ColDividerComplete" CHECKED ACTION ( ;
            oBrw:lColDividerComplete   := ! oBrw:lColDividerComplete,   ;
            oMenuItem:SetCheck( oBrw:lColDividerComplete ),             ;
            oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "BackGround"
      MENU
         MENUITEM "None"     ACTION ( oBrw:SetBackGround(), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "Paper"    ACTION ( oBrw:SetBackGround( "PAPER" ), oBrw:SetFocus() )
         MENUITEM "Stone"    ACTION ( oBrw:SetBackGround( "STONE" ), oBrw:SetFocus() )
         MENUITEM "FiveBack" ACTION ( oBrw:SetBackGround( "FIVEBACK" ), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "Select Image" ACTION SetBmpBack( oBrw )
         MENUITEM "ImageMode"
         MENU
            MENUITEM "Tiled"    WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_TILED ) )
            MENUITEM "Stretch"  WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_STRETCH ) )
            MENUITEM "Fill"     WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_FILL ) )
         ENDMENU
      ENDMENU

      MENUITEM "Font"        ACTION ( oBrw:SelFont(), oBrw:SetFocus() )
      MENUITEM "Stretch"
      MENU
         MENUITEM "None"     ACTION ( oBrw:nStretchCol := STRETCHCOL_NONE, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Last"     ACTION ( oBrw:nStretchCol := STRETCHCOL_LAST, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Widest"   ACTION ( oBrw:nStretchCol := STRETCHCOL_WIDEST, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU
      MENUITEM "NoFreeze"    WHEN ( oBrw:nFreeze > 0 ) ;
                             ACTION ( oBrw:nFreeze := 0, oBrw:Refresh(), oBrw:SetFocus() )

   ENDMENU

return oPop
//----------------------------------------------------------------------------//

static function SetBmpBack( oBrw )

   local cImage

   if ! Empty( cImage := cGetFile( "Image File (*.bmp,jpg,png)|*.bmp;*.png;*.jpg|", ;
                                 "Select Image file ", 1, ;
                                 "\fwh\bitmaps" ) )
      oBrw:SetBackGround( cImage )
   endif
   oBrw:SetFocus()

return nil

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

static function ViewCode( oBrw )

   local aCode    := Array( 4 )
   local aGet     := Array( 4 )
   local oDlg, oFolder
   local oFont

#define DLGWD  350 //250
#define DLGHT  250

   aCode := oBrw:PrgCode()

   DEFINE FONT oFont NAME 'LUCIDA CONSOLE' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE DLGWD*2, DLGHT*2 PIXEL ;
      TITLE oBrw:oWnd:cTitle + " ( Source)" ;
      FONT WndMain():oFont

   @ 05,05 FOLDER oFolder ;
      PROMPTS 'ListBox Style', 'CommandStyle', 'Oops Style', 'Report Code' ;
      SIZE DLGWD - 10, DLGHT - 27 PIXEL ;
      OF oDlg ; // ADJUST
      FONT WndMain():oFont

   @ 10,10 GET aGet[ 1 ] VAR aCode[ 1 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 1 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 2 ] VAR aCode[ 2 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 2 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 3 ] VAR aCode[ 3 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 3 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 4 ] VAR aCode[ 4 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 4 ] ;
      FONT oFont


   @ DLGHT-20,05 BUTTONBMP BITMAP 'COPY3' SIZE 16,16 PIXEL OF oDlg ;
      ACTION CopyToClip( aCode[ oFolder:nOption ] )
   @ DLGHT-20,23 BUTTONBMP BITMAP 'SAVE2' SIZE 16,16 PIXEL OF oDlg ;
      ACTION SaveCode( aCode[ oFolder:nOption ] )
   @ DLGHT-20,41 BUTTONBMP BITMAP 'RUN'   SIZE 16,16 PIXEL OF oDlg ;
      ACTION CompileAndRun( aCode[ oFolder:nOption ] )

   @ DLGHT-20,DLGWD-21 BUTTONBMP BITMAP 'CLOSE2' ;
      SIZE 16,16 PIXEL OF oDlg ;
      ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//
static function CopyToClip( cText )

   local oClip

   oClip := TClipBoard():New()
   if oClip:Open()
      oClip:SetText( cText )
      oClip:Close()
   endif
   oClip:End()

return nil
//----------------------------------------------------------------------------//

static function SaveCode( cText )

   local cFile

   if ! Empty( cFile := cGetFile(   "Prg File (*.PRG)|*.PRG|",          ;
                                    "Select PRG File to Save",       ;
                                    CurDir(), .t. ) )


      if ! MemoWrit( cFile, cText )
         MsgInfo( 'Write Failure' )
      endif

   endif

return nil
//----------------------------------------------------------------------------//

static function CompileAndRun( cText )

#ifdef __XHARBOUR__
   MemoWrit( 'test_x.prg', cText )
   WinExec( 'buildx.bat test_x' )
#else
   MemoWrit( 'test_x.prg', cText )
   WinExec( 'buildh.bat test_x' )
#endif

return nil

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


function dbfbuild()

   local oDlg, oGet, oGet1, oType, oLen, oDec, oLbx, oBtnAdd, oBtnEdit
   local cName    := Space( 9 ) // Limit to 9 instead of 10 for TDatabase
   local cType    := "C"
   local nLen     := 10
   local nDec     :=  0
   local cField   := Space( 20 )
   local cTypes   := "CNLDM"
   local aLens    := { 10, 10, 1, 8, 8 }
   local cDbfName := Space( 12 )
   local lEditing := .f.

   cDbfName:= padr("TEST",12)

   DEFINE DIALOG oDlg RESOURCE "DbfBuild" TITLE "FiveWin - DbfBuilder"

   REDEFINE GET oGet VAR cName ID 110 OF oDlg picture "@!XXXXXXXXX"

   REDEFINE COMBOBOX oType VAR cType  ITEMS { "C", "N", "L", "D", "M" } ;
      ON CHANGE ( nLen := aLens[ At( cType, cTypes ) ], oLen:Refresh() );
      ID 120 OF oDlg

   REDEFINE GET oLen VAR nLen PICTURE "9999" ID 130 OF oDlg

   REDEFINE GET oDec VAR nDec PICTURE "9"    ID 140 OF oDlg

   REDEFINE BUTTON oBtnAdd ID 150 OF oDlg ;
      ACTION (AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
                       @cName, cType, nLen, nDec, @lEditing ), oBtnAdd:oJump:= oGet, oDlg:refresh() )

   REDEFINE BUTTON ID 160 OF oDlg ACTION oDlg:End()

   REDEFINE LISTBOX oLbx VAR cField ID 170 OF oDlg

   oLbx:blDblClick:={|| EditField( oBtnAdd, oBtnEdit,;
                        cField, @cName, @cType, @nLen, @nDec, @lEditing,;
                        oGet, oType, oLen, oDec )}

   REDEFINE BUTTON oBtnEdit ID 180 OF oDlg ;
      ACTION EditField( oBtnAdd, oBtnEdit,;
                        cField, @cName, @cType, @nLen, @nDec, @lEditing,;
                        oGet, oType, oLen, oDec )

   REDEFINE BUTTON ID 190 OF oDlg ACTION oLbx:Del()

   REDEFINE BUTTON ID 112 OF oDlg ACTION oLbx:swapUp()

   REDEFINE BUTTON ID 113 OF oDlg action oLbx:swapDown()

   REDEFINE BUTTON ID 111 OF oDlg ;
      ACTION (cDbfName:=padr(cFileNoPath(OPEN(oLbx, cName)),12), oGet1:refresh() )

   REDEFINE GET oGet1 var cDbfName ID 210 OF oDlg

   REDEFINE BUTTON ID 220 OF oDlg ;
      ACTION BuildDbf( trim(cDbfName), oLbx )

   ACTIVATE DIALOG oDlg CENTERED ;
      //on init  import( cDbfName, oLbx )


return nil

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

static function AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
                          cName, cType, nLen, nDec, lEditing )

   if Empty( cName )
      MsgInfo( "I need a field name", "Sorry" )
   else
      if ! lEditing
         oLbx:Add( xPadR( cName, 100 )  + cType + ;
                   xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
                   oLbx:GetPos() )
            else
         oLbx:Modify( xPadR( cName, 100 ) + cType + ;
                      xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ) )
         oBtnAdd:SetText( "&Add" )
         oBtnEdit:Enable()
         lEditing = .f.
      endif
      cName = Space( 10 )
      oGet:Refresh()
      oGet:SetFocus( .t. )
   endif

return nil

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

static function BuildDbf( cDbfName, oLbx )

   local aFields := {}
   local n
   local cTempFile:=""

   if Empty( cDbfName )
      MsgAlert( "I need a DBF name", "Sorry" )
      return nil
   endif

   if Len( oLbx:aItems ) == 0
      MsgAlert( "No fields defined", "Sorry" )
      return nil
   endif

   if At( ".", cDbfName ) == 0
      cDbfName += ".dbf"
   endif

   for n = 1 to Len( oLbx:aItems )
      AAdd( aFields, _FieldInfo( AllTrim( oLbx:aItems[ n ] ) ) )
   next

   if File( cDbfName )
      if MsgYesNo( "DBF already exists, update structure?", "Info" )
         cTempFile:= tempFile("dbf")
         DbCreate( cTempFile, aFields )
         use (cTempFile)
         append from (cDbfName)
         use
         ferase( cDbfName )
         rename ( cTempFile ) to (cDbfName)

         // Handle memo field(s)
         // There is a problem when this file already exists--it doesn't get renamed for some reason.
         if file( cFileNoExt( cTempFile ) +".dbt" )
         //msgInfo( "memo file found")
         //cOld := cFileNoExt(cTempFile)+".dbt"
         //cNew := cFileNoExt( cDbfName )+".dbt"
         //msgInfo( cOld, "cOld")
         //msgInfo( cNew, "cNew")
            rename ( cFileNoExt(cTempFile)+".dbt") to ( cFileNoExt( cDbfName )+".dbt")
            //rename (cOld) to (cNew)
         endif

         return nil
      endif
   endif

   DbCreate( cDbfName, aFields )
   MsgInfo( "DBF created!", "AllRight" )

return nil

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

// Fixed function in dbfbuild.prg
static function _FieldInfo( cItem )

return { AllTrim( StrToken( cItem, 1 ) ),;
         AllTrim( StrToken( cItem, 2 ) ),;
         Val( StrToken( cItem, 3 ) ),;
         Val( StrToken( cItem, 4 ) ) }

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

static function EditField( oBtnAdd, oBtnEdit, cField,;
                           cName, cType, nLen, nDec, lEditing,;
                           oName, oType, oLen, oDec )

   if ! Empty( cField )
      oBtnAdd:SetText( "&Replace" )
      oBtnEdit:Disable()
      lEditing = .t.

      cName = padr(StrToken( cField, 1 ),9)

      cType = StrToken( cField, 2 )
      nLen  = Val( StrToken( cField, 3 ) )
      nDec  = Val( StrToken( cField, 4 ) )

      oName:Refresh()
      oType:Refresh()
      oLen:Refresh()
      oDec:Refresh()
   else
      MsgInfo( "Select a field to edit", "Please" )
   endif

return nil

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

static function import( cFile, oLbx )

   local aStruct,i:=0
   local cName,cType,nLen,nDec
   cFile:= trim(cFile)
   use (cFile)
   aStruct := dbstruct()

   for i:=1 to len( aStruct )

      cName := aStruct[i,1]
      cType := aStruct[i,2]
      nLen  := aStruct[i,3]
      nDec  := aStruct[i,4]

      oLbx:Add( xPadR( cName, 100 ) + cType + ;
              xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
              oLbx:GetPos() )

    next

    use

return cName

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

STATIC FUNCTION OPEN(oLbx)
   local cFile
   local cFileMask := "Database (DBF) | *.dbf |"
   local cInitialDirectory
   local lSave:= .f.
   local lLongNames:= .t.


   cFile:= cGetFile32( cFileMask, , , cInitialDirectory, lSave, lLongNames )

   if ! empty(cFile)
       import( cFile, oLbx )
   endif

return cFile

// Returns an unused filename with cExtension.
// cPath is optional. Defaults to current directory.
FUNCTION tempFile(cExtension,cPath)
   local cFile
   default cPath:=""
   cExtension:= strtran(cExtension,".","")
   // loop until you find a name that doesn't exist
   do while .t.
      cFile:="AAA"+trim(str(seconds(),5,0))+"."+upper(cExtension)
      cFile:=strtran(cFile," ","0") // fix for hours between 00:00 & 01:00
      cFile:= cPath + cFile
      if .not. file( cFile )
         exit
      endif
   enddo
return cPath + cFile


// eof
 



xbrDBU.rc

Code: Select all  Expand view

1 24 ".\WinXP\WindowsXP.Manifest"

TEST DIALOG 6, 15, 306, 227
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "TXBrowse demo"
FONT 8, "MS Sans Serif"
{
 DEFPUSHBUTTON "OK", IDOK, 252, 211, 50, 14
 CONTROL "", 101, "TXBrowse", 0 | WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 4, 5, 297, 202
}

STAR     BITMAP "c:\fwh\bitmaps\16x16\favorite.bmp"
GREEN    BITMAP "c:\fwh\bitmaps\level1.bmp"
RED      BITMAP "c:\fwh\bitmaps\level2.bmp"
FIVEBACK BITMAP "c:\fwh\bitmaps\fiveback.bmp"
STONE    BITMAP "c:\fwh\bitmaps\backgrnd\stone.bmp"
PAPER    BITMAP "c:\fwh\bitmaps\backgrnd\paper.bmp"
ON       BITMAP "c:\fwh\bitmaps\checkon.bmp"
OFF      BITMAP "c:\fwh\bitmaps\checkoff.bmp"
EXCEL    BITMAP "c:\fwh\bitmaps\excel.bmp"
REPORT   BITMAP "c:\fwh\bitmaps\32x32\print.bmp"
ATTACH   BITMAP "c:\fwh\bitmaps\32x32\attach.bmp"
CALC     BITMAP "c:\fwh\bitmaps\32x32\calc.bmp"
OPEN     BITMAP "c:\fwh\bitmaps\16x16\folder3.bmp"
CLOSE    BITMAP "c:\fwh\bitmaps\16x16\folder.bmp"
BLUBRICK BITMAP "c:\fwh\bitmaps\backgrnd\blubrick.bmp"
CONFIG   BITMAP "c:\fwh\bitmaps\config.bmp"
EXPAND   BITMAP "c:\fwh\bitmaps\expand.bmp"
COLLAPS  BITMAP "c:\fwh\bitmaps\collaps.bmp"
TREE     BITMAP "c:\fwh\bitmaps\tree.bmp"
SOURCE   BITMAP "c:\fwh\bitmaps\prg.bmp"
COPY2    BITMAP "c:\fwh\bitmaps\copy2.bmp"
COPY3    BITMAP "c:\fwh\bitmaps\copy3.bmp"
COMPILE  BITMAP "c:\fwh\bitmaps\compile.bmp"
SAVE     BITMAP "c:\fwh\bitmaps\save.bmp"
SAVE2    BITMAP "c:\fwh\bitmaps\save2.bmp"
RUN      BITMAP "c:\fwh\bitmaps\run.bmp"
CLOSE2   BITMAP "c:\fwh\bitmaps\close.bmp"
CODE     BITMAP "c:\fwh\bitmaps\code.bmp"
DLG      BITMAP "c:\fwh\bitmaps\dlg.bmp"

#define IDC_PUSHBUTTON1 112
#define IDC_PUSHBUTTON2 113
DBFBUILD DIALOG 20, 22, 203, 222
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "FiveWin 1.4 - Dbf Builder"
FONT 8, "Tahoma"
{
 LTEXT "Field Na&me           Type     Len     Dec", -1, 15, 13, 123, 8
 EDITTEXT 110, 12, 25, 54, 12, WS_BORDER | WS_TABSTOP
 COMBOBOX 120, 70, 25, 22, 50, CBS_DROPDOWNLIST | WS_TABSTOP
 EDITTEXT 130, 94, 25, 23, 12, WS_BORDER | WS_TABSTOP
 EDITTEXT 140, 120, 25, 14, 12, WS_BORDER | WS_TABSTOP
 PUSHBUTTON "&Add", 150, 143, 24, 50, 14
 LTEXT "&Fields:", -1, 18, 39, 25, 8
 LISTBOX 170, 15, 50, 118, 140, LBS_NOTIFY | WS_BORDER | LBS_USETABSTOPS | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
 PUSHBUTTON "&Edit", 180, 145, 50, 50, 14
 PUSHBUTTON "&Delete", 190, 145, 69, 50, 14
 PUSHBUTTON "E&xit", 160, 145, 170, 50, 14
 LTEXT "Dbf &Name:", -1, 18, 202, 34, 9
 EDITTEXT 210, 56, 200, 79, 13, WS_BORDER | WS_TABSTOP
 PUSHBUTTON "&Create", 220, 143, 200, 50, 14
 PUSHBUTTON "Open", 111, 145, 143, 50, 14
 PUSHBUTTON "Move Up", IDC_PUSHBUTTON1, 145, 88, 50, 14
 PUSHBUTTON "Move Down", IDC_PUSHBUTTON2, 145, 107, 50, 14
}


ACCELERATORS_1 ACCELERATORS
{
 0, 101, VIRTKEY
}




 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: WDBU colone - xbrDBU

Postby MdaSolution » Sat Aug 27, 2011 5:39 pm

Good ....
Propose : if you take OurXdbu Source Code , perhaps you can compiled and have a Good app dbu in 5 minutes!!!!
just an idea !!!
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: WDBU colone - xbrDBU

Postby Antonio Linares » Sat Aug 27, 2011 6:13 pm

Otto,

very good! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WDBU colone - xbrDBU

Postby Bayron » Sat Aug 27, 2011 6:21 pm

Looking good....

:)
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: WDBU colone - xbrDBU

Postby Andrés González » Sun Aug 28, 2011 10:32 am

Otto, where is SET XBROWSE TO TXBrCode(), compiler give me:

Code: Select all  Expand view
--------------------Configuración: WDBU - Debug--------------------
Harbour 2.0.0 (Rev. 13372)
Copyright (c) 1999-2010, http://www.harbour-project.org/
G:\POLICIA\winpol\DBU\Src\xDbu.prg(419) Warning W0001  Ambiguous reference 'OWND'
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
xDbu.c:
Borland Resource Compiler  Version 5.40
Copyright (c) 1990, 1999 Inprise Corporation.  All rights reserved.
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_HB_FUN_TXBRCODE' referenced from G:\POLICIA\WINPOL\DBU\DEBUG\XDBU.OBJ
WDBU.EXE - 1 error(es), 1 advertencia(s)

 


If I comment "//SET XBROWSE TO TXBrCode()" compiling with no error.
Saludos

Andrés González desde Mallorca
User avatar
Andrés González
 
Posts: 627
Joined: Thu Jan 19, 2006 10:45 am
Location: Mallorca

Re: WDBU colone - xbrDBU

Postby Andrés González » Sun Aug 28, 2011 12:11 pm

Solved added XbrCode.Prg from classes source.
Saludos

Andrés González desde Mallorca
User avatar
Andrés González
 
Posts: 627
Joined: Thu Jan 19, 2006 10:45 am
Location: Mallorca

Re: WDBU colone - xbrDBU

Postby Antonio Linares » Tue Aug 30, 2011 6:44 am

Some little changes to Otto's xbrDBU :-)

xbrdbu.prg
Code: Select all  Expand view
#include 'fivewin.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

#DEFINE EXENAME "xWDBU"

static oWnd

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

function Main()

   local oBrw, oFont

   SetBalloon( .t. )
   xbrNumformat( ,.t. )

   SET XBROWSE TO TXBrCode()

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12

   DEFINE WINDOW oWnd MDI ;
      TITLE 'DBU for Windows' ;
      MENU MainMenu()
   
   oWnd:SetFont( oFont )
    // MakeBar( oWnd )
    // oWnd:oBar:cToolTip := { || "My Color" }

   SET MESSAGE OF oWnd TO '' 2007

   ACTIVATE WINDOW oWnd ;
      ON DROPFILES Files2Brw( nRow, nCol, aFiles )

return nil

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

INIT PROCEDURE PrgInit

   SET DELETED ON
   SET EXCLUSIVE OFF

   SET DATE ITALIAN
   SET CENTURY ON

   RDDSetDefault( 'DBFCDX' )

return

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

static function MakeBar( oWnd )

   local oBar

   DEFINE BUTTONBAR oBar OF oWnd SIZE 56,64 2007

   DEFINE BUTTON OF oBar PROMPT 'Open Data' ;
      RESOURCE 'Open' ;
      ACTION NewFile()

    DEFINE BUTTON OF oBar PROMPT 'dbfbuild' ;
      RESOURCE 'Open' ;
      ACTION dbfbuild()

return oBar

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

static function MainMenu()

   local oMenu, URLNAME := "http://www.fivetechsoft.com"

   MENU oMenu 2007
     
          MENUITEM "File"
 
          MENU
               MENUITEM "&New"+chr(9)+"Ctrl+U" ;
                    RESOURCE "NEW" ;
                    ACTION  NewFile(dbfbuild()) ;  //MsgInfo( "Fbrowse(DbfBuild(),.t.) ") ;
                    MESSAGE "Create new file" ;
                    ACCELERATOR ACC_CONTROL, asc("U") ;
                    ENABLED
                   
               MENUITEM "&Open"+chr(9)+"Ctrl+A" ;
                    RESOURCE "OPEN" ;
                    ACTION NewFile() ;
                    MESSAGE "Open file" ;
                    ACCELERATOR ACC_CONTROL, asc("A") ;
                    ENABLED
                   
               MENUITEM "C&lose"+chr(9)+"Ctrl+E" ;
                    RESOURCE "SAVE" ;
                    ACTION WndMain():oWnd:End() ;
                    MESSAGE "Close file" ;
                    ACCELERATOR ACC_CONTROL, asc("E") ;
                    ENABLED
                   
               MENUITEM "&Print"+chr(9)+"Ctrl+T" ;
                    RESOURCE "PRINTER" ;
                    ACTION MsgInfo( " oDbfWnd:Report() ") ;
                    MESSAGE "Print file" ;
                    ACCELERATOR ACC_CONTROL, asc("T") ;
                    ENABLED
                   
               MENUITEM "Command &Interpreter" ;
                    RESOURCE "DOT" ;
                    ACTION MsgInfo( " DotNew()  ");
                    MESSAGE "Invokes the command interpreter" ;
                    ENABLED
                   
               MENUITEM "&Modify structure"+chr(9)+"Ctrl+M" ;
                    RESOURCE "DESIGN" ;
                    ACTION  NewFile(dbfbuild()) ;
                    MESSAGE "Modify file structure" ;
                    ACCELERATOR ACC_CONTROL, asc("M") ;
                    ENABLED
                   
               MENUITEM "Multi-&file operation" ;
                    RESOURCE "MULTFILE" ;
                    ACTION MsgInfo( " MultiFile()  ");
                    MESSAGE "&Multi-file operation" ;
                    ENABLED
                   
               MENUITEM "Import from ODBC database" ;
                    RESOURCE "IMPORT" ;
                    ACTION MsgInfo( " ImportODBC(oWnd)  ");
                    MESSAGE "Import data from a ODBC database" ;
                    ENABLED
                   
               MENUITEM "&Configuration" ;
                    RESOURCE "CONFIG" ;
                    ACTION MsgInfo( " AppConfig() ");
                    MESSAGE "Program configuration" ;
                    ENABLED
                   
               SEPARATOR
               
               MENUITEM "Specif&y printer" ;
                    RESOURCE "PROPERTY" ;
                    ACTION  PrinterSetup()  ;
                    MESSAGE "Printer configuration" ;
                    ENABLED
               
               MENUITEM "&Map Network Drive" ;
                    RESOURCE "NETCONNE" ;
                    ACTION  MsgInfo(" WNetConnectDialog() ") ;
                    MESSAGE "Connect to a network drive" ;
                    ENABLED
               
               MENUITEM "&Disconnect Network Drive" ;
                    RESOURCE "NETDISCO" ;
                    ACTION  MsgInfo(" WNetDisconnect() ") ;
                    MESSAGE "Disconnect from a network drive" ;
                    ENABLED
               
               MENUITEM "&Exit"+chr(9)+"Alt+F4" ;
                    RESOURCE "EXIT" ;
                    ACTION WndMain():End() ;
                    MESSAGE "Exit from the application" ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Edit"
          MENU
               MENUITEM "&Copy record"+chr(9)+"Ctrl+C" ;
                    RESOURCE "COPY" ;
                    ACTION MsgInfo( " oDbfWnd:CopyRec() ") ;
                    MESSAGE "Copy record to the Clipboard" ;
                    ACCELERATOR ACC_CONTROL, asc("C") ;
                    ENABLED
               
               MENUITEM "&Paste record"+chr(9)+"Ctrl+V" ;
                    RESOURCE "PASTE" ;
                    ACTION MsgInfo( " oDbfWnd:PasteRec() ");
                    MESSAGE "Paste record from the Clipboard" ;
                    ACCELERATOR ACC_CONTROL, asc("V")
               
               SEPARATOR
               
               MENUITEM "&Insert record"+chr(9)+"Ctrl+Insert" ;
                    RESOURCE "NEW" ;
                    ACTION MsgInfo( " oDbfWnd:AppRec() ");
                    MESSAGE "Append record" ;
                    ACCELERATOR ACC_CONTROL, VK_INSERT ;
                    ENABLED
               
               MENUITEM "&Del/Recall record"+chr(9)+"Ctrl+Del" ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DelRec() ");
                    MESSAGE "Del actual record" ;
                    ACCELERATOR ACC_CONTROL, VK_DELETE ;
                    ENABLED
               
               MENUITEM "&Edit field"+chr(9)+"Enter" ;
                    RESOURCE "TEXTBOX" ;
                    ACTION MsgInfo( " oDbfWnd:EditFld() ");
                    MESSAGE "Edit actual record field" ;
                    ENABLED
                    //ACCELERATOR ACC_SHIFT, VK_RETURN ;

               MENUITEM "&Edit record"+chr(9)+"CTRL+Enter" ;
                    RESOURCE "EDIT" ;
                    ACTION MsgInfo( " oDbfWnd:EditRec() ");
                    MESSAGE "Edit actual record (all fields)" ;
                    ENABLED
                    //ACCELERATOR ACC_CONTROL, VK_RETURN ;

          ENDMENU
         
          MENUITEM "&Navigation"
          MENU
               MENUITEM "&Search"+chr(9)+"Ctrl+S" ;
                    RESOURCE "SEARCH" ;
                    ACTION MsgInfo( " oDbfWnd:Seek() ");
                    MESSAGE "Search records using the active index" ;
                    ACCELERATOR ACC_CONTROL, asc("S") ;
                    ENABLED
               
               MENUITEM "&Go to"+chr(9)+"Ctrl+G" ;
                    ACTION MsgInfo( " oDbfWnd:Ira() ");
                    MESSAGE "Jump to a record by its Recno()" ;
                    ACCELERATOR ACC_CONTROL, asc("G") ;
                    ENABLED
               
               MENUITEM "S&kip"+chr(9)+"Ctrl+K" ;
                    ACTION MsgInfo( " oDbfWnd:Skip() ");
                    MESSAGE "Skip records" ;
                    ACCELERATOR ACC_CONTROL, asc("K") ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Locate"+chr(9)+"F3" ;
                    ACTION MsgInfo( " oDbfWnd:Locate() ");
                    MESSAGE "Locate record" ;
                    ACCELERATOR ACC_NORMAL, VK_F3 ;
                    ENABLED
               
               MENUITEM "&Continue"+chr(9)+"F4" ;
                    ACTION MsgInfo( " oDbfWnd:Locate(.T.)") ;
                    MESSAGE "Locate next record" ;
                    ACCELERATOR ACC_NORMAL, VK_F4 ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Indexes"
          MENU
               MENUITEM OemtoAnsi("&Open Index"+chr(9)+"Ctrl+X") ;
                    RESOURCE "OPEN" ;
                    ACTION MsgInfo( " oDbfWnd:OpenIndex() ");
                    MESSAGE "Select an index file" ;
                    ACCELERATOR ACC_CONTROL, asc("X") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Close Index"+chr(9)+"Ctrl+L") ;
                    RESOURCE "SAVE" ;
                    ACTION MsgInfo( " oDbfWnd:CloseIndex()") ;
                    MESSAGE "Close current index file" ;
                    ACCELERATOR ACC_CONTROL, asc("L") ;
                    ENABLED
               
               MENUITEM "&Previous order"+chr(9)+"Ctrl+P" ;
                    RESOURCE "PREV" ;
                    ACTION MsgInfo( " oDbfWnd:PrevOrder()");
                    MESSAGE "Go to previous order" ;
                    ACCELERATOR ACC_CONTROL, asc("P") ;
                    ENABLED
               
               MENUITEM "&Next order"+chr(9)+"Ctrl+N" ;
                    RESOURCE "NEXT" ;
                    ACTION MsgInfo( " oDbfWnd:NextOrder() ");
                    MESSAGE "Go to next order" ;
                    ACCELERATOR ACC_CONTROL, asc("N") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Filter by scope"+chr(9)+"Ctrl+F") ;
                    RESOURCE "FILTER" ;
                    ACTION MsgInfo( " oDbfWnd:Scope() ");
                    MESSAGE "Set a scope to filter records, based on the active index" ;
                    ACCELERATOR ACC_CONTROL, asc("F") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Create new index"+chr(9)+"Ctrl+W") ;
                    RESOURCE "INDEX" ;
                    ACTION MsgInfo( " oDbfWnd:BuildIndex() ");
                    MESSAGE "Create a new index file or Tag" ;
                    ACCELERATOR ACC_CONTROL, asc("W") ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Delete Order" ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DelTag() ");
                    MESSAGE "Delete current Order (Tag)" ;
                    ENABLED
               
               MENUITEM "&Reindex"+chr(9)+"Ctrl+R" ;
                    RESOURCE "REPEAT" ;
                    ACTION MsgInfo( " oDbfWnd:Reindex() ");
                    MESSAGE "Reindex all the open indexes" ;
                    ACCELERATOR ACC_CONTROL, asc("R") ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Utilities"
          MENU
               MENUITEM "&More information"+chr(9)+"Ctrl+I" ;
                    RESOURCE "PROPERTY" ;
                    ACTION MsgInfo( " oDbfWnd:Info() ");
                    MESSAGE "Show additional information about the current file" ;
                    ACCELERATOR ACC_CONTROL, asc("I") ;
                    ENABLED
               
               MENUITEM "&Browse Columns"+chr(9)+"Ctrl+B" ;
                    RESOURCE "TBROWSE" ;
                    ACTION MsgInfo( " oDbfWnd:SetColumn() ");
                    MESSAGE "Columns configuration" ;
                    ACCELERATOR ACC_CONTROL, asc("B") ;
                    ENABLED
               
               MENUITEM "&Relations" ;
                    RESOURCE "CHAIN" ;
                    ACTION MsgInfo( " oDbfWnd:Relations() ");
                    MESSAGE "Establish relations with other databases" ;
                    ENABLED
               
               MENUITEM "Establish &Filter" ;
                    RESOURCE "FILTER" ;
                    ACTION MsgInfo( " oDbfWnd:Filter() ");
                    MESSAGE "Set the criteria by which to filter records" ;
                    ENABLED
               
               MENUITEM "Coun&t" ;
                    ACTION MsgInfo( " oDbfWnd:Count() ");
                    MESSAGE "Count the number of records meeting a certain criteria" ;
                    ENABLED
               
               MENUITEM "&Statistics" ;
                    RESOURCE "STATICS" ;
                    ACTION MsgInfo( " oDbfWnd:Sum() ");
                    MESSAGE "Statistics calculations of all numeric fields" ;
                    ENABLED
               
               MENUITEM "&Graphics" ;
                    RESOURCE "GRAPH" ;
                    ACTION MsgInfo( " oDbfWnd:Graphics() ");
                    MESSAGE "Graphics based on current data file" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Append from..." ;
                    RESOURCE "IMPORT" ;
                    ACTION MsgInfo( " oDbfWnd:AppendFrom() ");
                    MESSAGE "Append records from another file" ;
                    ENABLED
               
               MENUITEM "&Copy to..." ;
                    RESOURCE "COPY" ;
                    ACTION MsgInfo( " oDbfWnd:CopyTo() ");
                    MESSAGE "Copy records to another file" ;
                    ENABLED
               
               MENUITEM "&Delete..." ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DeleteFor() ");
                    MESSAGE "Delete all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "Reca&ll..." ;
                    ACTION MsgInfo( " oDbfWnd:RecallFor() ");
                    MESSAGE "Recall all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "R&eplace..." ;
                    ACTION MsgInfo( " oDbfWnd:ReplaceFor() ");
                    MESSAGE "Replace all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "S&cript process..." ;
                    RESOURCE "SCRIPT" ;
                    ACTION MsgInfo( " oDbfWnd:Script()  ");
                    MESSAGE "Process a script file to all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "Pac&k" ;
                    ACTION MsgInfo( " oDbfWnd:Pack()  ");
                    MESSAGE "Eliminate phisically deleted records" ;
                    ENABLED
               
               MENUITEM "&Zap" ;
                    ACTION MsgInfo( " oDbfWnd:Zap()  ");
                    MESSAGE "Delete every record in the database" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Oem to Ansi" ;
                    ACTION MsgInfo( " oDbfWnd:OtoA(.F.)  ");
                    MESSAGE "Translate from OEM to ANSI" ;
                    ENABLED
               
               MENUITEM "A&nsi to Oem" ;
                    ACTION MsgInfo( " oDbfWnd:OtoA(.T.)  ");
                    MESSAGE "Translate from ANSI to OEM" ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Windows"
          MENU
          MENUITEM "&Cascade" ;
               RESOURCE "CASCAWND" ;
               MESSAGE OemToAnsi( "Organize windows on cascade" ) ;
               ACTION WndMain():Cascade()
         
          MENUITEM "&Vertical mosaic" ;
               RESOURCE "MOSVRWND" ;
               MESSAGE OemToAnsi( "Organize windows on vertical mosaic" ) ;
               ACTION WndMain():Tile()
         
          MENUITEM "&Horizontal mosaic" ;
               RESOURCE "MOSHRWND" ;
               ACTION WndMain():Tile( .t. );
               MESSAGE OemToAnsi( "Organize windows on horizontal mosaic" )
         
          MENUITEM "&Minimize Windows" ;
               RESOURCE "MINIMWND" ;
               ACTION WndMain():IconizeAll() ;
               MESSAGE "Minimize all Windows"
         
          MENUITEM "&Restore all windows" ;
               RESOURCE "MAXIMWND" ;
               ACTION Asend(WndMain():oWndClient:aWnd,'NORMAL') ;
               MESSAGE "Restore all windows"
         
          MENUITEM "C&lose windows" ;
               RESOURCE "CLOSEWND" ;
               ACTION WndMain():CloseAll() ;
               MESSAGE "Close all windows"
         
          MENUITEM "&Organize Icons" ;
               MESSAGE OemToAnsi( "Organize minimized windows" ) ;
               ACTION WndMain():ArrangeIcons()
         
          ENDMENU
         
          MENUITEM "&Help"
          MENU
               MENUITEM "&Index"+chr(9)+"F1" ;
                    RESOURCE "HELP" ;
                    ACTION MsgInfo( " HelpIndex()  ");
                    MESSAGE "Shows the Help contents" ;
                    ENABLED
               
               MENUITEM "&Using Help" ;
                    ACTION MsgInfo( " Winhelp.hlp") ;
                    MESSAGE "More information about using help" ;
                    ENABLED
               
               MENUITEM "&Readme text file" ;
                    RESOURCE "NOTEPAD" ;
                    ACTION  WinExec("Notepad readme.txt") ;
                    MESSAGE "Modifications and enhancements not present on the help file" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Web page (Internet)" ;
                    RESOURCE "INTERNET" ;
                    ACTION ShellExecute(oWnd:hWnd, "open", URLNAME) ;
                    MESSAGE "Web page on the Internet" ;
                    ENABLED
               
               MENUITEM "&Send mail" ;
                    RESOURCE "MAIL" ;
                    ACTION  MsgInfo(" SendMail() ") ;
                    MESSAGE "Contact with us via eMail" ;
                    ENABLED
               
               MENUITEM "&Calculator" ;
                    RESOURCE "CALC" ;
                    ACTION  WinExec("Calc.exe") ;
                    MESSAGE "Windows calculator" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&About "+EXENAME ;
                    RESOURCE "INFO" ;
                    ACTION MsgAbout( "DBU for Windows", "(c) FiveTech Software 2011" ) ;
                    MESSAGE "More information about the program" ;
                    ENABLED
          ENDMENU

ENDMENU

return oMenu

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

static function files2brw( nRow, nCol, aFiles )

   local cFile

   for each cFile in aFiles
      if Upper( cFileExt( cFile ) ) == 'DBF'
         File2Brw( cFile )
      else
         CheckBrwDrop( ClientToScreen( WndMain():hWnd, { nRow, nCol } ), cFile)
      endif
   next

return nil

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

static function file2brw( cFile )

   local oWnd, oBrw, cAlias, cFileNoExt

   if !OpenFile( cFile, @cAlias, @cFileNoExt )
      return nil
   endif

   DEFINE WINDOW oWnd MDICHILD OF WndMain() ;
      TITLE cFileNoExt

   @ 0,0 XBROWSE oBrw OF oWnd ;
      ALIAS cAlias ;
      AUTOCOLS AUTOSORT FOOTERS LINES CELL NOBORDER

   AEval( oBrw:aCols, { |oCol| oCol:cCol := oCol:cHeader } )
   AEval( oBrw:aCols, { |oCol| oCol:cHeader := Upper( Left( oCol:cHeader, 1 ) ) + Lower( Substr( oCol:cHeader, 2 ) ) } )
   oBrw:bPopUp       := { |o| ColMenu( o ) }

   oBrw:CreateFromCode()
   oWnd:oClient   := oBrw

   BrwBtnBar( oBrw )
   SET MESSAGE OF oWnd TO cFile 2007
   ACTIVATE WINDOW oWnd

return nil

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

static function CheckBrwDrop( aPoint, cFile )

   local ownd, oBrw, nRow, nCol
   local nColPos, nRowPos

   if ( oWnd := WndMain():oWndActive ) != nil
      oBrw  := oWnd:oClient
      if oBrw != nil .and. oBrw:IsKindOf( TXBrowse() )
         aPoint   := ScreenToClient( oBrw:hWnd, aPoint )
         nRow     := aPoint[ 1 ]
         nCol     := aPoint[ 2 ]
         if oBrw:DropFile( nRow, nCol, cFile )
//            MsgInfo( 'handled' )
         else
            msginfo( 'Not Valid File' )
         endif
      endif
   endif

return nil

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

static function OpenFile( cFile, cAlias, cFileNoExt )

   local lOpen    := .f.
   local cDriver  := 'DBFCDX'

   if Upper( cFileExt( cFile ) ) == 'DBF'
      cFileNoExt  := cFileNoExt( cFile )
      cAlias   := cGetNewAlias( Left( cFileNoExt, 4 ) )
      TRY
         dbUseArea( .t., cDriver, cFile, cAlias, .t., .f. )
      CATCH
         MsgInfo( cFile + CRLF + 'can not be opened' )
         return .f.
      END
      lOpen := .t.
   else
      MsgInfo( 'Not a DBF File' )
   endif

return lOpen

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

static function NewFile()

   local cFile

   if ! Empty( cFile := cGetFile(   "DataFile (*.DBF)|*.dbf|",          ;
                                    "Select Data File to Browse",1,     ;
                                    "\fwh\samples" ) )
      File2Brw( cFile )
   endif


return nil

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


static function BrwbtnBar( oBrw )

   local oBar, oBtn

   DEFINE BUTTONBAR oBar OF oBrw:oWnd SIZE 56,64 3D 2007

   DEFINE BUTTON OF oBar ;
      RESOURCE "REPORT" TOP ;
      PROMPT "Report" ;
      MENU ReportMenu( oBrw ) ;
      ACTION This:ShowPopUp() ;
      MESSAGE "Print the browse contents" ;
      TOOLTIP { "Print Report", "Report" }

   DEFINE BUTTON OF oBar ;
      RESOURCE "EXCEL" TOP ;
      PROMPT "Excel" ;
      ACTION This:ShowPopUp() ;
      MENU ExcelMenu( oBrw ) ;
      MESSAGE "Export browse contents to Excel" ;
      TOOLTIP { "Export to Excel", "Excel" }

   DEFINE BUTTON oBtn OF oBar ;
      RESOURCE "CONFIG" TOP ;
      PROMPT "Config" ;
      MENU ConfigMenu( oBrw )  ;
      ACTION This:ShowPopUp() ;
      MESSAGE "Change background, Style2007, FastEdit option, etc" ;
      TOOLTIP { "Configure", "SetUp",,CLR_BLUE,nRGB(220,230,247) }

   DEFINE BUTTON OF oBar ;
      RESOURCE 'CODE' TOP ;
      PROMPT 'Source' ;
      ACTION ViewCode( oBrw ) ; //MemoEdit( oBrw:PrgCode() ) ;
      TOOLTIP 'Generate program source'

   DEFINE BUTTON OF oBar ;
      RESOURCE 'DLG' TOP ;
      PROMPT 'Dialog' ;
      ACTION SetBrwInDlg( oBrw ) ;
      TOOLTIP 'View Browse in Dialog'

return oBar

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

static function SetBrwInDlg( oBrw )

   local oWnd, oDlg

   oWnd  := oBrw:oWnd

   DEFINE DIALOG oDlg SIZE 800,600 PIXEL TITLE oWnd:cTitle


   ACTIVATE DIALOG oDlg ;
      ON INIT InitBrwDlg( oBrw, oDlg ) ;
      VALID ExitBrwDlg( oBrw, oWnd ) ;
      ON RIGHT CLICK ( SetWindowLong( oBrw:hWnd, -20, ;
         nXor( GetWindowLong( oBrw:hWnd, -20 ), 0x200 ) ) )


return nil

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

static function InitBrwDlg( oBrw, oDlg )

   local oWnd  := oBrw:oWnd
   local nColsWidth  := oBrw:GetDisplayColsWidth() + 24

   oBrw:oWnd   := oDlg
   SetParent( oBrw:hWnd, oDlg:hWnd )
   oBrw:nTop      := 20
   oBrw:nLeft     := 20
   oBrw:nHeight   := oDlg:nHeight - 80
   oBrw:nWidth    := oDlg:nWidth - 40
   if oBrw:nWidth > nColsWidth
      oBrw:nWidth       := nColsWidth
      oDlg:nWidth       := oBrw:nWidth + 40
   endif
   oBrw:Resize()
   oDlg:Center()
   oWnd:Hide()

return .f.

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

static function ExitBrwDlg( oBrw, oWnd )

   oBrw:oWnd   := oWnd
   SetParent( oBrw:hWnd, oWnd:hWnd )
   oWnd:oClient := oBrw
   oWnd:Show()
   oWnd:ReSize()

return .t.

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

static function ExcelMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Export to Excel" ACTION oBrw:ToExcel()
      MENUITEM "Export to Excel with Group Totals" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:ToExcel(,1)
   ENDMENU

return oPop

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

static function ReportMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Simple Report" ACTION oBrw:Report()
      MENUITEM "Report with Grouping" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:Report( nil, .t., .t., nil, 1 )
   ENDMENU

return oPop

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

static function ColMenu( ocol )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Align"
      MENU
         MENUITEM "Left Align" WHEN oCol:nDataStrAlign > 0 ;
            ACTION ( oCol:SetAlign( AL_LEFT ), oCol:oBrw:SetFocus() )
         MENUITEM "Center Align" WHEN oCol:nDataStrAlign != AL_CENTER ;
            ACTION ( oCol:SetAlign( AL_CENTER ), oCol:oBrw:SetFocus() )
         MENUITEM "Right Align" WHEN oCol:nDataStrAlign != AL_RIGHT ;
            ACTION ( oCol:SetAlign( AL_RIGHT ), oCol:oBrw:SetFocus() )
      ENDMENU
      MENUITEM "Freeze" ACTION ( oCol:oBrw:nFreeze := oCol:nPos, oCol:oBrw:Refresh(), oCol:oBrw:SetFocus() )
      MENUITEM "Stretch" ACTION ( oCol:oBrw:nStretchCol := oCol:nCreationOrder, oCol:oBrw:ReSize(), ;
                        oCol:oBrw:Refresh(), ;
                        oCol:oBrw:SetFocus() )


      MENUITEM "Edit" ACTION (   oCol:nEditType := If( oCol:nEditType > 0, 0, 1 ), ;
                                 oMenuItem:SetCheck( oCol:nEditType > 0 ) )

      MENUITEM 'Inspect' ACTION XBrowse( oCol )
      MENUITEM 'Rptcode' ACTION MsgInfo( oCol:RptCode() )

   ENDMENU

return oPop

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

static function ConfigMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "2007" CHECKED ;
         ACTION ( oBrw:l2007 := !oBrw:l2007, oMenuItem:SetCheck( oBrw:l2007 ), ;
                  oBrw:Refresh(), oBrw:SetFocus() )
      MENUITEM "FastEdit" ;
         ACTION ( oBrw:lFastEdit := !oBrw:lFastEdit, oMenuItem:SetCheck( oBrw:lFastEdit ), ;
                  oBrw:SetFocus() )
      MENUITEM "RecordSelector" CHECKED ;
         ACTION ( oBrw:lRecordSelector := !oBrw:lRecordSelector, ;
                  oMenuItem:SetCheck( oBrw:lRecordSelector ),    ;
                  oBrw:Refresh(), oBrw:SetFocus() )
      MENUITEM "HScroll" CHECKED ;
         ACTION ( oMenuItem:SetCheck( oBrw:SetHScroll( ! oBrw:lHScroll ) ) )

      MENUITEM "Marquee"
      MENU
         MENUITEM "NoMarquee"   ACTION ( oBrw:nMarqueeStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "DottedCell"  ACTION ( oBrw:nMarqueeStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "SolidCell"   ACTION ( oBrw:nMarqueeStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL cell"  ACTION ( oBrw:nMarqueeStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL RowRC" ACTION ( oBrw:nMarqueeStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL Row"   ACTION ( oBrw:nMarqueeStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL RowMS" ACTION ( oBrw:nMarqueeStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "Row LineStyle"
      MENU
         MENUITEM "No Lines"    ACTION ( oBrw:nRowDividerStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Black"       ACTION ( oBrw:nRowDividerStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Dark Gray"   ACTION ( oBrw:nRowDividerStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "ForeColor"   ACTION ( oBrw:nRowDividerStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Light Gray"  ACTION ( oBrw:nRowDividerStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Inset"       ACTION ( oBrw:nRowDividerStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Raised"      ACTION ( oBrw:nRowDividerStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "Col LineStyle"
      MENU
         MENUITEM "No Lines"    ACTION ( oBrw:nColDividerStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Black"       ACTION ( oBrw:nColDividerStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Dark Gray"   ACTION ( oBrw:nColDividerStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "ForeColor"   ACTION ( oBrw:nColDividerStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Light Gray"  ACTION ( oBrw:nColDividerStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Inset"       ACTION ( oBrw:nColDividerStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Raised"      ACTION ( oBrw:nColDividerStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "ColDividerComplete" CHECKED ACTION ( ;
            oBrw:lColDividerComplete   := ! oBrw:lColDividerComplete,   ;
            oMenuItem:SetCheck( oBrw:lColDividerComplete ),             ;
            oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "BackGround"
      MENU
         MENUITEM "None"     ACTION ( oBrw:SetBackGround(), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "Paper"    ACTION ( oBrw:SetBackGround( "PAPER" ), oBrw:SetFocus() )
         MENUITEM "Stone"    ACTION ( oBrw:SetBackGround( "STONE" ), oBrw:SetFocus() )
         MENUITEM "FiveBack" ACTION ( oBrw:SetBackGround( "FIVEBACK" ), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "Select Image" ACTION SetBmpBack( oBrw )
         MENUITEM "ImageMode"
         MENU
            MENUITEM "Tiled"    WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_TILED ) )
            MENUITEM "Stretch"  WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_STRETCH ) )
            MENUITEM "Fill"     WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_FILL ) )
         ENDMENU
      ENDMENU

      MENUITEM "Font"        ACTION ( oBrw:SelFont(), oBrw:SetFocus() )
      MENUITEM "Stretch"
      MENU
         MENUITEM "None"     ACTION ( oBrw:nStretchCol := STRETCHCOL_NONE, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Last"     ACTION ( oBrw:nStretchCol := STRETCHCOL_LAST, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Widest"   ACTION ( oBrw:nStretchCol := STRETCHCOL_WIDEST, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU
      MENUITEM "NoFreeze"    WHEN ( oBrw:nFreeze > 0 ) ;
                             ACTION ( oBrw:nFreeze := 0, oBrw:Refresh(), oBrw:SetFocus() )

   ENDMENU

return oPop
//----------------------------------------------------------------------------//

static function SetBmpBack( oBrw )

   local cImage

   if ! Empty( cImage := cGetFile( "Image File (*.bmp,jpg,png)|*.bmp;*.png;*.jpg|", ;
                                 "Select Image file ", 1, ;
                                 "\fwh\bitmaps" ) )
      oBrw:SetBackGround( cImage )
   endif
   oBrw:SetFocus()

return nil

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

static function ViewCode( oBrw )

   local aCode    := Array( 4 )
   local aGet     := Array( 4 )
   local oDlg, oFolder
   local oFont

#define DLGWD  350 //250
#define DLGHT  250

   aCode := oBrw:PrgCode()

   DEFINE FONT oFont NAME 'LUCIDA CONSOLE' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE DLGWD*2, DLGHT*2 PIXEL ;
      TITLE oBrw:oWnd:cTitle + " ( Source)" ;
      FONT WndMain():oFont

   @ 05,05 FOLDER oFolder ;
      PROMPTS 'ListBox Style', 'CommandStyle', 'Oops Style', 'Report Code' ;
      SIZE DLGWD - 10, DLGHT - 27 PIXEL ;
      OF oDlg ; // ADJUST
      FONT WndMain():oFont

   @ 10,10 GET aGet[ 1 ] VAR aCode[ 1 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 1 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 2 ] VAR aCode[ 2 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 2 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 3 ] VAR aCode[ 3 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 3 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 4 ] VAR aCode[ 4 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 4 ] ;
      FONT oFont


   @ DLGHT-20,05 BUTTONBMP BITMAP 'COPY3' SIZE 16,16 PIXEL OF oDlg ;
      ACTION CopyToClip( aCode[ oFolder:nOption ] )
   @ DLGHT-20,23 BUTTONBMP BITMAP 'SAVE2' SIZE 16,16 PIXEL OF oDlg ;
      ACTION SaveCode( aCode[ oFolder:nOption ] )
   @ DLGHT-20,41 BUTTONBMP BITMAP 'RUN'   SIZE 16,16 PIXEL OF oDlg ;
      ACTION CompileAndRun( aCode[ oFolder:nOption ] )

   @ DLGHT-20,DLGWD-21 BUTTONBMP BITMAP 'CLOSE2' ;
      SIZE 16,16 PIXEL OF oDlg ;
      ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//
static function CopyToClip( cText )

   local oClip

   oClip := TClipBoard():New()
   if oClip:Open()
      oClip:SetText( cText )
      oClip:Close()
   endif
   oClip:End()

return nil
//----------------------------------------------------------------------------//

static function SaveCode( cText )

   local cFile

   if ! Empty( cFile := cGetFile(   "Prg File (*.PRG)|*.PRG|",          ;
                                    "Select PRG File to Save",       ;
                                    CurDir(), .t. ) )


      if ! MemoWrit( cFile, cText )
         MsgInfo( 'Write Failure' )
      endif

   endif

return nil
//----------------------------------------------------------------------------//

static function CompileAndRun( cText )

#ifdef __XHARBOUR__
   MemoWrit( 'test_x.prg', cText )
   WinExec( 'buildx.bat test_x' )
#else
   MemoWrit( 'test_x.prg', cText )
   WinExec( 'buildh.bat test_x' )
#endif

return nil

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


function dbfbuild()

   local oDlg, oGet, oGet1, oType, oLen, oDec, oLbx, oBtnAdd, oBtnEdit
   local cName    := Space( 9 ) // Limit to 9 instead of 10 for TDatabase
   local cType    := "C"
   local nLen     := 10
   local nDec     :=  0
   local cField   := Space( 20 )
   local cTypes   := "CNLDM"
   local aLens    := { 10, 10, 1, 8, 8 }
   local cDbfName := Space( 12 )
   local lEditing := .f.

   cDbfName:= padr("TEST",12)

   DEFINE DIALOG oDlg RESOURCE "DbfBuild" TITLE "FiveWin - DbfBuilder"

   REDEFINE GET oGet VAR cName ID 110 OF oDlg picture "@!XXXXXXXXX"

   REDEFINE COMBOBOX oType VAR cType  ITEMS { "C", "N", "L", "D", "M" } ;
      ON CHANGE ( nLen := aLens[ At( cType, cTypes ) ], oLen:Refresh() );
      ID 120 OF oDlg

   REDEFINE GET oLen VAR nLen PICTURE "9999" ID 130 OF oDlg

   REDEFINE GET oDec VAR nDec PICTURE "9"    ID 140 OF oDlg

   REDEFINE BUTTON oBtnAdd ID 150 OF oDlg ;
      ACTION (AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
                       @cName, cType, nLen, nDec, @lEditing ), oBtnAdd:oJump:= oGet, oDlg:refresh() )

   REDEFINE BUTTON ID 160 OF oDlg ACTION oDlg:End()

   REDEFINE LISTBOX oLbx VAR cField ID 170 OF oDlg

   oLbx:blDblClick:={|| EditField( oBtnAdd, oBtnEdit,;
                        cField, @cName, @cType, @nLen, @nDec, @lEditing,;
                        oGet, oType, oLen, oDec )}

   REDEFINE BUTTON oBtnEdit ID 180 OF oDlg ;
      ACTION EditField( oBtnAdd, oBtnEdit,;
                        cField, @cName, @cType, @nLen, @nDec, @lEditing,;
                        oGet, oType, oLen, oDec )

   REDEFINE BUTTON ID 190 OF oDlg ACTION oLbx:Del()

   REDEFINE BUTTON ID 112 OF oDlg ACTION oLbx:swapUp()

   REDEFINE BUTTON ID 113 OF oDlg action oLbx:swapDown()

   REDEFINE BUTTON ID 111 OF oDlg ;
      ACTION (cDbfName:=padr(cFileNoPath(OPEN(oLbx, cName)),12), oGet1:refresh() )

   REDEFINE GET oGet1 var cDbfName ID 210 OF oDlg

   REDEFINE BUTTON ID 220 OF oDlg ;
      ACTION BuildDbf( trim(cDbfName), oLbx )

   ACTIVATE DIALOG oDlg CENTERED ;
      //on init  import( cDbfName, oLbx )


return nil

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

static function AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
                          cName, cType, nLen, nDec, lEditing )

   if Empty( cName )
      MsgInfo( "I need a field name", "Sorry" )
   else
      if ! lEditing
         oLbx:Add( xPadR( cName, 100 )  + cType + ;
                   xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
                   oLbx:GetPos() )
            else
         oLbx:Modify( xPadR( cName, 100 ) + cType + ;
                      xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ) )
         oBtnAdd:SetText( "&Add" )
         oBtnEdit:Enable()
         lEditing = .f.
      endif
      cName = Space( 10 )
      oGet:Refresh()
      oGet:SetFocus( .t. )
   endif

return nil

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

static function BuildDbf( cDbfName, oLbx )

   local aFields := {}
   local n
   local cTempFile:=""

   if Empty( cDbfName )
      MsgAlert( "I need a DBF name", "Sorry" )
      return nil
   endif

   if Len( oLbx:aItems ) == 0
      MsgAlert( "No fields defined", "Sorry" )
      return nil
   endif

   if At( ".", cDbfName ) == 0
      cDbfName += ".dbf"
   endif

   for n = 1 to Len( oLbx:aItems )
      AAdd( aFields, _FieldInfo( AllTrim( oLbx:aItems[ n ] ) ) )
   next

   if File( cDbfName )
      if MsgYesNo( "DBF already exists, update structure?", "Info" )
         cTempFile:= tempFile("dbf")
         DbCreate( cTempFile, aFields )
         use (cTempFile)
         append from (cDbfName)
         use
         ferase( cDbfName )
         rename ( cTempFile ) to (cDbfName)

         // Handle memo field(s)
         // There is a problem when this file already exists--it doesn't get renamed for some reason.
         if file( cFileNoExt( cTempFile ) +".dbt" )
         //msgInfo( "memo file found")
         //cOld := cFileNoExt(cTempFile)+".dbt"
         //cNew := cFileNoExt( cDbfName )+".dbt"
         //msgInfo( cOld, "cOld")
         //msgInfo( cNew, "cNew")
            rename ( cFileNoExt(cTempFile)+".dbt") to ( cFileNoExt( cDbfName )+".dbt")
            //rename (cOld) to (cNew)
         endif

         return nil
      endif
   endif

   DbCreate( cDbfName, aFields )
   MsgInfo( "DBF created!", "AllRight" )

return nil

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

// Fixed function in dbfbuild.prg
static function _FieldInfo( cItem )

return { AllTrim( StrToken( cItem, 1 ) ),;
         AllTrim( StrToken( cItem, 2 ) ),;
         Val( StrToken( cItem, 3 ) ),;
         Val( StrToken( cItem, 4 ) ) }

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

static function EditField( oBtnAdd, oBtnEdit, cField,;
                           cName, cType, nLen, nDec, lEditing,;
                           oName, oType, oLen, oDec )

   if ! Empty( cField )
      oBtnAdd:SetText( "&Replace" )
      oBtnEdit:Disable()
      lEditing = .t.

      cName = padr(StrToken( cField, 1 ),9)

      cType = StrToken( cField, 2 )
      nLen  = Val( StrToken( cField, 3 ) )
      nDec  = Val( StrToken( cField, 4 ) )

      oName:Refresh()
      oType:Refresh()
      oLen:Refresh()
      oDec:Refresh()
   else
      MsgInfo( "Select a field to edit", "Please" )
   endif

return nil

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

static function import( cFile, oLbx )

   local aStruct,i:=0
   local cName,cType,nLen,nDec
   cFile:= trim(cFile)
   use (cFile)
   aStruct := dbstruct()

   for i:=1 to len( aStruct )

      cName := aStruct[i,1]
      cType := aStruct[i,2]
      nLen  := aStruct[i,3]
      nDec  := aStruct[i,4]

      oLbx:Add( xPadR( cName, 100 ) + cType + ;
              xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
              oLbx:GetPos() )

    next

    use

return cName

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

STATIC FUNCTION OPEN(oLbx)
   local cFile
   local cFileMask := "Database (DBF) | *.dbf |"
   local cInitialDirectory
   local lSave:= .f.
   local lLongNames:= .t.


   cFile:= cGetFile32( cFileMask, , , cInitialDirectory, lSave, lLongNames )

   if ! empty(cFile)
       import( cFile, oLbx )
   endif

return cFile

// Returns an unused filename with cExtension.
// cPath is optional. Defaults to current directory.
FUNCTION tempFile(cExtension,cPath)
   local cFile
   default cPath:=""
   cExtension:= strtran(cExtension,".","")
   // loop until you find a name that doesn't exist
   do while .t.
      cFile:="AAA"+trim(str(seconds(),5,0))+"."+upper(cExtension)
      cFile:=strtran(cFile," ","0") // fix for hours between 00:00 & 01:00
      cFile:= cPath + cFile
      if .not. file( cFile )
         exit
      endif
   enddo
return cPath + cFile


// eof
 


xbrdbu.rc
Code: Select all  Expand view
1 24 ".\WinXP\WindowsXP.Manifest"

TEST DIALOG 6, 15, 306, 227
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "TXBrowse demo"
FONT 8, "MS Sans Serif"
{
 DEFPUSHBUTTON "OK", IDOK, 252, 211, 50, 14
 CONTROL "", 101, "TXBrowse", 0 | WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 4, 5, 297, 202
}

ATTACH   BITMAP ".\..\bitmaps\32x32\attach.bmp"
BLUBRICK BITMAP ".\..\bitmaps\backgrnd\blubrick.bmp"
CALC     BITMAP ".\..\bitmaps\16x16\calc.bmp"
CODE     BITMAP ".\..\bitmaps\code.bmp"
CLOSE    BITMAP ".\..\bitmaps\16x16\close.bmp"
CLOSE2   BITMAP ".\..\bitmaps\16x16\close.bmp"
CONFIG   BITMAP ".\..\bitmaps\16x16\tools.bmp"
COPY     BITMAP ".\..\bitmaps\16x16\copy.bmp"
COPY2    BITMAP ".\..\bitmaps\copy2.bmp"
COPY3    BITMAP ".\..\bitmaps\copy3.bmp"
COMPILE  BITMAP ".\..\bitmaps\compile.bmp"
DEL      BITMAP ".\..\bitmaps\16x16\delete0.bmp"
EXCEL    BITMAP ".\..\bitmaps\excel.bmp"
EXIT     BITMAP ".\..\bitmaps\16x16\exit2.bmp"
GREEN    BITMAP ".\..\bitmaps\level1.bmp"
RED      BITMAP ".\..\bitmaps\level2.bmp"
FIVEBACK BITMAP ".\..\bitmaps\fiveback.bmp"
PAPER    BITMAP ".\..\bitmaps\backgrnd\paper.bmp"
INFO     BITMAP ".\..\bitmaps\16x16\info.bmp"
ON       BITMAP ".\..\bitmaps\checkon.bmp"
OFF      BITMAP ".\..\bitmaps\checkoff.bmp"
MAIL     BITMAP ".\..\bitmaps\16x16\mail.bmp"
NEXT     BITMAP ".\..\bitmaps\16x16\next2.bmp"
NEW      BITMAP ".\..\bitmaps\16x16\new2.bmp"
REPORT   BITMAP ".\..\bitmaps\32x32\print.bmp"
OPEN     BITMAP ".\..\bitmaps\16x16\folder3.bmp"
PASTE    BITMAP ".\..\bitmaps\16x16\paste.bmp"
PREV     BITMAP ".\..\bitmaps\16x16\previous2.bmp"
PRINTER  BITMAP ".\..\bitmaps\16x16\print.bmp"
EXPAND   BITMAP ".\..\bitmaps\expand.bmp"
COLLAPS  BITMAP ".\..\bitmaps\collaps.bmp"
TREE     BITMAP ".\..\bitmaps\tree.bmp"
SEARCH   BITMAP ".\..\bitmaps\16x16\search.bmp"
SOURCE   BITMAP ".\..\bitmaps\prg.bmp"
RUN      BITMAP ".\..\bitmaps\run.bmp"
DLG      BITMAP ".\..\bitmaps\dlg.bmp"
SAVE     BITMAP ".\..\bitmaps\16x16\save.bmp"
SAVE2    BITMAP ".\..\bitmaps\save2.bmp"
STAR     BITMAP ".\..\bitmaps\16x16\favorite.bmp"
STONE    BITMAP ".\..\bitmaps\backgrnd\stone.bmp"

#define IDC_PUSHBUTTON1 112
#define IDC_PUSHBUTTON2 113
DBFBUILD DIALOG 20, 22, 203, 222
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "FiveWin 1.4 - Dbf Builder"
FONT 8, "Tahoma"
{
 LTEXT "Field Na&me           Type     Len     Dec", -1, 15, 13, 123, 8
 EDITTEXT 110, 12, 25, 54, 12, WS_BORDER | WS_TABSTOP
 COMBOBOX 120, 70, 25, 22, 50, CBS_DROPDOWNLIST | WS_TABSTOP
 EDITTEXT 130, 94, 25, 23, 12, WS_BORDER | WS_TABSTOP
 EDITTEXT 140, 120, 25, 14, 12, WS_BORDER | WS_TABSTOP
 PUSHBUTTON "&Add", 150, 143, 24, 50, 14
 LTEXT "&Fields:", -1, 18, 39, 25, 8
 LISTBOX 170, 15, 50, 118, 140, LBS_NOTIFY | WS_BORDER | LBS_USETABSTOPS | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
 PUSHBUTTON "&Edit", 180, 145, 50, 50, 14
 PUSHBUTTON "&Delete", 190, 145, 69, 50, 14
 PUSHBUTTON "E&xit", 160, 145, 170, 50, 14
 LTEXT "Dbf &Name:", -1, 18, 202, 34, 9
 EDITTEXT 210, 56, 200, 79, 13, WS_BORDER | WS_TABSTOP
 PUSHBUTTON "&Create", 220, 143, 200, 50, 14
 PUSHBUTTON "Open", 111, 145, 143, 50, 14
 PUSHBUTTON "Move Up", IDC_PUSHBUTTON1, 145, 88, 50, 14
 PUSHBUTTON "Move Down", IDC_PUSHBUTTON2, 145, 107, 50, 14
}


ACCELERATORS_1 ACCELERATORS
{
 0, 101, VIRTKEY
}




 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WDBU clone - xbrDBU

Postby Antonio Linares » Tue Aug 30, 2011 6:53 am

You can download it from here (EXE included):

http://fivewin-contributions.googlecode.com/files/xbrdbu.zop
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WDBU clone - xbrDBU

Postby MdaSolution » Tue Aug 30, 2011 8:19 am

who is dotnew() ?
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: WDBU clone - xbrDBU

Postby Antonio Linares » Tue Aug 30, 2011 9:43 am

Following this way you can port methods from WDBU to xbrDBU (as per Otto's requirement) :-)

Please review Method DelRec() for Class TDbfWnd

xbrdbu.prg
Code: Select all  Expand view
#include 'fivewin.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

#DEFINE EXENAME "xWDBU"

static oWnd, oDbfWnd

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

function Main()

   local oBrw, oFont

   SetBalloon( .t. )
   xbrNumformat( ,.t. )

   SET XBROWSE TO TXBrCode()

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12

   DEFINE WINDOW oWnd MDI ;
      TITLE 'DBU for Windows' ;
      MENU MainMenu()
   
   oWnd:SetFont( oFont )
    // MakeBar( oWnd )
    // oWnd:oBar:cToolTip := { || "My Color" }

   SET MESSAGE OF oWnd TO 'Developed with Harbour and FWH (FiveWin for Harbour/xHarbour)' 2007 DATE CLOCK KEYBOARD

   ACTIVATE WINDOW oWnd ;
      ON DROPFILES Files2Brw( nRow, nCol, aFiles )

return nil

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

INIT PROCEDURE PrgInit

   SET DELETED ON
   SET EXCLUSIVE OFF

   SET DATE ITALIAN
   SET CENTURY ON

   RDDSetDefault( 'DBFCDX' )

return

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

static function MakeBar( oWnd )

   local oBar

   DEFINE BUTTONBAR oBar OF oWnd SIZE 56,64 2007

   DEFINE BUTTON OF oBar PROMPT 'Open Data' ;
      RESOURCE 'Open' ;
      ACTION NewFile()

    DEFINE BUTTON OF oBar PROMPT 'dbfbuild' ;
      RESOURCE 'Open' ;
      ACTION dbfbuild()

return oBar

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

static function MainMenu()

   local oMenu, URLNAME := "http://www.fivetechsoft.com"

   MENU oMenu 2007
     
          MENUITEM "File"
 
          MENU
               MENUITEM "&New"+chr(9)+"Ctrl+U" ;
                    RESOURCE "NEW" ;
                    ACTION  NewFile(dbfbuild()) ;  //MsgInfo( "Fbrowse(DbfBuild(),.t.) ") ;
                    MESSAGE "Create new file" ;
                    ACCELERATOR ACC_CONTROL, asc("U") ;
                    ENABLED
                   
               MENUITEM "&Open"+chr(9)+"Ctrl+A" ;
                    RESOURCE "OPEN" ;
                    ACTION NewFile() ;
                    MESSAGE "Open file" ;
                    ACCELERATOR ACC_CONTROL, asc("A") ;
                    ENABLED
                   
               MENUITEM "C&lose"+chr(9)+"Ctrl+E" ;
                    RESOURCE "SAVE" ;
                    ACTION WndMain():oWnd:End() ;
                    MESSAGE "Close file" ;
                    ACCELERATOR ACC_CONTROL, asc("E") ;
                    ENABLED
                   
               MENUITEM "&Print"+chr(9)+"Ctrl+T" ;
                    RESOURCE "PRINTER" ;
                    ACTION MsgInfo( " oDbfWnd:Report() ") ;
                    MESSAGE "Print file" ;
                    ACCELERATOR ACC_CONTROL, asc("T") ;
                    ENABLED
                   
               MENUITEM "Command &Interpreter" ;
                    RESOURCE "DOT" ;
                    ACTION MsgInfo( " DotNew()  ");
                    MESSAGE "Invokes the command interpreter" ;
                    ENABLED
                   
               MENUITEM "&Modify structure"+chr(9)+"Ctrl+M" ;
                    RESOURCE "DESIGN" ;
                    ACTION  NewFile(dbfbuild()) ;
                    MESSAGE "Modify file structure" ;
                    ACCELERATOR ACC_CONTROL, asc("M") ;
                    ENABLED
                   
               MENUITEM "Multi-&file operation" ;
                    RESOURCE "MULTFILE" ;
                    ACTION MsgInfo( " MultiFile()  ");
                    MESSAGE "&Multi-file operation" ;
                    ENABLED
                   
               MENUITEM "Import from ODBC database" ;
                    RESOURCE "IMPORT" ;
                    ACTION MsgInfo( " ImportODBC(oWnd)  ");
                    MESSAGE "Import data from a ODBC database" ;
                    ENABLED
                   
               MENUITEM "&Configuration" ;
                    RESOURCE "CONFIG" ;
                    ACTION MsgInfo( " AppConfig() ");
                    MESSAGE "Program configuration" ;
                    ENABLED
                   
               SEPARATOR
               
               MENUITEM "Specif&y printer" ;
                    RESOURCE "PROPERTY" ;
                    ACTION  PrinterSetup()  ;
                    MESSAGE "Printer configuration" ;
                    ENABLED
               
               MENUITEM "&Map Network Drive" ;
                    RESOURCE "NETCONNE" ;
                    ACTION  MsgInfo(" WNetConnectDialog() ") ;
                    MESSAGE "Connect to a network drive" ;
                    ENABLED
               
               MENUITEM "&Disconnect Network Drive" ;
                    RESOURCE "NETDISCO" ;
                    ACTION  MsgInfo(" WNetDisconnect() ") ;
                    MESSAGE "Disconnect from a network drive" ;
                    ENABLED
               
               MENUITEM "&Exit"+chr(9)+"Alt+F4" ;
                    RESOURCE "EXIT" ;
                    ACTION WndMain():End() ;
                    MESSAGE "Exit from the application" ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Edit"
          MENU
               MENUITEM "&Copy record"+chr(9)+"Ctrl+C" ;
                    RESOURCE "COPY" ;
                    ACTION MsgInfo( " oDbfWnd:CopyRec() ") ;
                    MESSAGE "Copy record to the Clipboard" ;
                    ACCELERATOR ACC_CONTROL, asc("C") ;
                    ENABLED
               
               MENUITEM "&Paste record"+chr(9)+"Ctrl+V" ;
                    RESOURCE "PASTE" ;
                    ACTION MsgInfo( " oDbfWnd:PasteRec() ");
                    MESSAGE "Paste record from the Clipboard" ;
                    ACCELERATOR ACC_CONTROL, asc("V")
               
               SEPARATOR
               
               MENUITEM "&Insert record"+chr(9)+"Ctrl+Insert" ;
                    RESOURCE "NEW" ;
                    ACTION MsgInfo( " oDbfWnd:AppRec() ");
                    MESSAGE "Append record" ;
                    ACCELERATOR ACC_CONTROL, VK_INSERT ;
                    ENABLED
               
               MENUITEM "&Del/Recall record"+chr(9)+"Ctrl+Del" ;
                    RESOURCE "DEL" ;
                    ACTION oDbfWnd:DelRec() ;
                    MESSAGE "Del actual record" ;
                    ACCELERATOR ACC_CONTROL, VK_DELETE ;
                    ENABLED
               
               MENUITEM "&Edit field"+chr(9)+"Enter" ;
                    RESOURCE "TEXTBOX" ;
                    ACTION MsgInfo( " oDbfWnd:EditFld() ");
                    MESSAGE "Edit actual record field" ;
                    ENABLED
                    //ACCELERATOR ACC_SHIFT, VK_RETURN ;

               MENUITEM "&Edit record"+chr(9)+"CTRL+Enter" ;
                    RESOURCE "EDIT" ;
                    ACTION MsgInfo( " oDbfWnd:EditRec() ");
                    MESSAGE "Edit actual record (all fields)" ;
                    ENABLED
                    //ACCELERATOR ACC_CONTROL, VK_RETURN ;

          ENDMENU
         
          MENUITEM "&Navigation"
          MENU
               MENUITEM "&Search"+chr(9)+"Ctrl+S" ;
                    RESOURCE "SEARCH" ;
                    ACTION MsgInfo( " oDbfWnd:Seek() ");
                    MESSAGE "Search records using the active index" ;
                    ACCELERATOR ACC_CONTROL, asc("S") ;
                    ENABLED
               
               MENUITEM "&Go to"+chr(9)+"Ctrl+G" ;
                    ACTION MsgInfo( " oDbfWnd:Ira() ");
                    MESSAGE "Jump to a record by its Recno()" ;
                    ACCELERATOR ACC_CONTROL, asc("G") ;
                    ENABLED
               
               MENUITEM "S&kip"+chr(9)+"Ctrl+K" ;
                    ACTION MsgInfo( " oDbfWnd:Skip() ");
                    MESSAGE "Skip records" ;
                    ACCELERATOR ACC_CONTROL, asc("K") ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Locate"+chr(9)+"F3" ;
                    ACTION MsgInfo( " oDbfWnd:Locate() ");
                    MESSAGE "Locate record" ;
                    ACCELERATOR ACC_NORMAL, VK_F3 ;
                    ENABLED
               
               MENUITEM "&Continue"+chr(9)+"F4" ;
                    ACTION MsgInfo( " oDbfWnd:Locate(.T.)") ;
                    MESSAGE "Locate next record" ;
                    ACCELERATOR ACC_NORMAL, VK_F4 ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Indexes"
          MENU
               MENUITEM OemtoAnsi("&Open Index"+chr(9)+"Ctrl+X") ;
                    RESOURCE "OPEN" ;
                    ACTION MsgInfo( " oDbfWnd:OpenIndex() ");
                    MESSAGE "Select an index file" ;
                    ACCELERATOR ACC_CONTROL, asc("X") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Close Index"+chr(9)+"Ctrl+L") ;
                    RESOURCE "SAVE" ;
                    ACTION MsgInfo( " oDbfWnd:CloseIndex()") ;
                    MESSAGE "Close current index file" ;
                    ACCELERATOR ACC_CONTROL, asc("L") ;
                    ENABLED
               
               MENUITEM "&Previous order"+chr(9)+"Ctrl+P" ;
                    RESOURCE "PREV" ;
                    ACTION MsgInfo( " oDbfWnd:PrevOrder()");
                    MESSAGE "Go to previous order" ;
                    ACCELERATOR ACC_CONTROL, asc("P") ;
                    ENABLED
               
               MENUITEM "&Next order"+chr(9)+"Ctrl+N" ;
                    RESOURCE "NEXT" ;
                    ACTION MsgInfo( " oDbfWnd:NextOrder() ");
                    MESSAGE "Go to next order" ;
                    ACCELERATOR ACC_CONTROL, asc("N") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Filter by scope"+chr(9)+"Ctrl+F") ;
                    RESOURCE "FILTER" ;
                    ACTION MsgInfo( " oDbfWnd:Scope() ");
                    MESSAGE "Set a scope to filter records, based on the active index" ;
                    ACCELERATOR ACC_CONTROL, asc("F") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Create new index"+chr(9)+"Ctrl+W") ;
                    RESOURCE "INDEX" ;
                    ACTION MsgInfo( " oDbfWnd:BuildIndex() ");
                    MESSAGE "Create a new index file or Tag" ;
                    ACCELERATOR ACC_CONTROL, asc("W") ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Delete Order" ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DelTag() ");
                    MESSAGE "Delete current Order (Tag)" ;
                    ENABLED
               
               MENUITEM "&Reindex"+chr(9)+"Ctrl+R" ;
                    RESOURCE "REPEAT" ;
                    ACTION MsgInfo( " oDbfWnd:Reindex() ");
                    MESSAGE "Reindex all the open indexes" ;
                    ACCELERATOR ACC_CONTROL, asc("R") ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Utilities"
          MENU
               MENUITEM "&More information"+chr(9)+"Ctrl+I" ;
                    RESOURCE "PROPERTY" ;
                    ACTION MsgInfo( " oDbfWnd:Info() ");
                    MESSAGE "Show additional information about the current file" ;
                    ACCELERATOR ACC_CONTROL, asc("I") ;
                    ENABLED
               
               MENUITEM "&Browse Columns"+chr(9)+"Ctrl+B" ;
                    RESOURCE "TBROWSE" ;
                    ACTION MsgInfo( " oDbfWnd:SetColumn() ");
                    MESSAGE "Columns configuration" ;
                    ACCELERATOR ACC_CONTROL, asc("B") ;
                    ENABLED
               
               MENUITEM "&Relations" ;
                    RESOURCE "CHAIN" ;
                    ACTION MsgInfo( " oDbfWnd:Relations() ");
                    MESSAGE "Establish relations with other databases" ;
                    ENABLED
               
               MENUITEM "Establish &Filter" ;
                    RESOURCE "FILTER" ;
                    ACTION MsgInfo( " oDbfWnd:Filter() ");
                    MESSAGE "Set the criteria by which to filter records" ;
                    ENABLED
               
               MENUITEM "Coun&t" ;
                    ACTION MsgInfo( " oDbfWnd:Count() ");
                    MESSAGE "Count the number of records meeting a certain criteria" ;
                    ENABLED
               
               MENUITEM "&Statistics" ;
                    RESOURCE "STATICS" ;
                    ACTION MsgInfo( " oDbfWnd:Sum() ");
                    MESSAGE "Statistics calculations of all numeric fields" ;
                    ENABLED
               
               MENUITEM "&Graphics" ;
                    RESOURCE "GRAPH" ;
                    ACTION MsgInfo( " oDbfWnd:Graphics() ");
                    MESSAGE "Graphics based on current data file" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Append from..." ;
                    RESOURCE "IMPORT" ;
                    ACTION MsgInfo( " oDbfWnd:AppendFrom() ");
                    MESSAGE "Append records from another file" ;
                    ENABLED
               
               MENUITEM "&Copy to..." ;
                    RESOURCE "COPY" ;
                    ACTION MsgInfo( " oDbfWnd:CopyTo() ");
                    MESSAGE "Copy records to another file" ;
                    ENABLED
               
               MENUITEM "&Delete..." ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DeleteFor() ");
                    MESSAGE "Delete all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "Reca&ll..." ;
                    ACTION MsgInfo( " oDbfWnd:RecallFor() ");
                    MESSAGE "Recall all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "R&eplace..." ;
                    ACTION MsgInfo( " oDbfWnd:ReplaceFor() ");
                    MESSAGE "Replace all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "S&cript process..." ;
                    RESOURCE "SCRIPT" ;
                    ACTION MsgInfo( " oDbfWnd:Script()  ");
                    MESSAGE "Process a script file to all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "Pac&k" ;
                    ACTION MsgInfo( " oDbfWnd:Pack()  ");
                    MESSAGE "Eliminate phisically deleted records" ;
                    ENABLED
               
               MENUITEM "&Zap" ;
                    ACTION MsgInfo( " oDbfWnd:Zap()  ");
                    MESSAGE "Delete every record in the database" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Oem to Ansi" ;
                    ACTION MsgInfo( " oDbfWnd:OtoA(.F.)  ");
                    MESSAGE "Translate from OEM to ANSI" ;
                    ENABLED
               
               MENUITEM "A&nsi to Oem" ;
                    ACTION MsgInfo( " oDbfWnd:OtoA(.T.)  ");
                    MESSAGE "Translate from ANSI to OEM" ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Windows"
          MENU
          MENUITEM "&Cascade" ;
               RESOURCE "CASCAWND" ;
               MESSAGE OemToAnsi( "Organize windows on cascade" ) ;
               ACTION WndMain():Cascade()
         
          MENUITEM "&Vertical mosaic" ;
               RESOURCE "MOSVRWND" ;
               MESSAGE OemToAnsi( "Organize windows on vertical mosaic" ) ;
               ACTION WndMain():Tile()
         
          MENUITEM "&Horizontal mosaic" ;
               RESOURCE "MOSHRWND" ;
               ACTION WndMain():Tile( .t. );
               MESSAGE OemToAnsi( "Organize windows on horizontal mosaic" )
         
          MENUITEM "&Minimize Windows" ;
               RESOURCE "MINIMWND" ;
               ACTION WndMain():IconizeAll() ;
               MESSAGE "Minimize all Windows"
         
          MENUITEM "&Restore all windows" ;
               RESOURCE "MAXIMWND" ;
               ACTION Asend(WndMain():oWndClient:aWnd,'NORMAL') ;
               MESSAGE "Restore all windows"
         
          MENUITEM "C&lose windows" ;
               RESOURCE "CLOSEWND" ;
               ACTION WndMain():CloseAll() ;
               MESSAGE "Close all windows"
         
          MENUITEM "&Organize Icons" ;
               MESSAGE OemToAnsi( "Organize minimized windows" ) ;
               ACTION WndMain():ArrangeIcons()
         
          ENDMENU
         
          MENUITEM "&Help"
          MENU
               MENUITEM "&Index"+chr(9)+"F1" ;
                    RESOURCE "HELP" ;
                    ACTION MsgInfo( " HelpIndex()  ");
                    MESSAGE "Shows the Help contents" ;
                    ENABLED
               
               MENUITEM "&Using Help" ;
                    ACTION MsgInfo( " Winhelp.hlp") ;
                    MESSAGE "More information about using help" ;
                    ENABLED
               
               MENUITEM "&Readme text file" ;
                    RESOURCE "NOTEPAD" ;
                    ACTION  WinExec("Notepad readme.txt") ;
                    MESSAGE "Modifications and enhancements not present on the help file" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Web page (Internet)" ;
                    RESOURCE "INTERNET" ;
                    ACTION ShellExecute(oWnd:hWnd, "open", URLNAME) ;
                    MESSAGE "Web page on the Internet" ;
                    ENABLED
               
               MENUITEM "&Send mail" ;
                    RESOURCE "MAIL" ;
                    ACTION  MsgInfo(" SendMail() ") ;
                    MESSAGE "Contact with us via eMail" ;
                    ENABLED
               
               MENUITEM "&Calculator" ;
                    RESOURCE "CALC" ;
                    ACTION  WinExec("Calc.exe") ;
                    MESSAGE "Windows calculator" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&About "+EXENAME ;
                    RESOURCE "INFO" ;
                    ACTION MsgAbout( "DBU for Windows", "(c) FiveTech Software 2011" ) ;
                    MESSAGE "More information about the program" ;
                    ENABLED
          ENDMENU

ENDMENU

return oMenu

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

static function files2brw( nRow, nCol, aFiles )

   local cFile

   for each cFile in aFiles
      if Upper( cFileExt( cFile ) ) == 'DBF'
         File2Brw( cFile )
      else
         CheckBrwDrop( ClientToScreen( WndMain():hWnd, { nRow, nCol } ), cFile)
      endif
   next

return nil

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

static function file2brw( cFile )

   local oWndChild, oBrw
   local cAlias, cFileNoExt

   if ! OpenFile( cFile, @cAlias, @cFileNoExt )
      return nil
   endif

   DEFINE WINDOW oWndChild MDICHILD OF WndMain() ;
      TITLE cFileNoExt

   @ 0,0 XBROWSE oBrw OF oWndChild ;
      ALIAS cAlias ;
      AUTOCOLS AUTOSORT FOOTERS LINES CELL NOBORDER

   AEval( oBrw:aCols, { |oCol| oCol:cCol := oCol:cHeader } )
   AEval( oBrw:aCols, { |oCol| oCol:cHeader := Upper( Left( oCol:cHeader, 1 ) ) + Lower( Substr( oCol:cHeader, 2 ) ) } )
   oBrw:bPopUp       := { |o| ColMenu( o ) }

   oBrw:CreateFromCode()
   oWndChild:oClient := oBrw

   BrwBtnBar( oBrw )
   SET MESSAGE OF oWndChild TO cFile 2007
   
   ACTIVATE WINDOW oWndChild
   
   TDbfWnd():New( oWndChild, oBrw )

return nil

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

static function CheckBrwDrop( aPoint, cFile )

   local ownd, oBrw, nRow, nCol
   local nColPos, nRowPos

   if ( oWnd := WndMain():oWndActive ) != nil
      oBrw  := oWnd:oClient
      if oBrw != nil .and. oBrw:IsKindOf( TXBrowse() )
         aPoint   := ScreenToClient( oBrw:hWnd, aPoint )
         nRow     := aPoint[ 1 ]
         nCol     := aPoint[ 2 ]
         if oBrw:DropFile( nRow, nCol, cFile )
//            MsgInfo( 'handled' )
         else
            msginfo( 'Not Valid File' )
         endif
      endif
   endif

return nil

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

static function OpenFile( cFile, cAlias, cFileNoExt )

   local lOpen    := .f.
   local cDriver  := 'DBFCDX'

   if Upper( cFileExt( cFile ) ) == 'DBF'
      cFileNoExt  := cFileNoExt( cFile )
      cAlias   := cGetNewAlias( Left( cFileNoExt, 4 ) )
      TRY
         dbUseArea( .t., cDriver, cFile, cAlias, .t., .f. )
      CATCH
         MsgInfo( cFile + CRLF + 'can not be opened' )
         return .f.
      END
      lOpen := .t.
   else
      MsgInfo( 'Not a DBF File' )
   endif

return lOpen

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

static function NewFile()

   local cFile

   if ! Empty( cFile := cGetFile(   "DataFile (*.DBF)|*.dbf|",          ;
                                    "Select Data File to Browse",1,     ;
                                    "\fwh\samples" ) )
      File2Brw( cFile )
   endif


return nil

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


static function BrwbtnBar( oBrw )

   local oBar, oBtn

   DEFINE BUTTONBAR oBar OF oBrw:oWnd SIZE 56,64 3D 2007

   DEFINE BUTTON OF oBar ;
      RESOURCE "REPORT" TOP ;
      PROMPT "Report" ;
      MENU ReportMenu( oBrw ) ;
      ACTION This:ShowPopUp() ;
      MESSAGE "Print the browse contents" ;
      TOOLTIP { "Print Report", "Report" }

   DEFINE BUTTON OF oBar ;
      RESOURCE "EXCEL" TOP ;
      PROMPT "Excel" ;
      ACTION This:ShowPopUp() ;
      MENU ExcelMenu( oBrw ) ;
      MESSAGE "Export browse contents to Excel" ;
      TOOLTIP { "Export to Excel", "Excel" }

   DEFINE BUTTON oBtn OF oBar ;
      RESOURCE "CONFIG" TOP ;
      PROMPT "Config" ;
      MENU ConfigMenu( oBrw )  ;
      ACTION This:ShowPopUp() ;
      MESSAGE "Change background, Style2007, FastEdit option, etc" ;
      TOOLTIP { "Configure", "SetUp",,CLR_BLUE,nRGB(220,230,247) }

   DEFINE BUTTON OF oBar ;
      RESOURCE 'CODE' TOP ;
      PROMPT 'Source' ;
      ACTION ViewCode( oBrw ) ; //MemoEdit( oBrw:PrgCode() ) ;
      TOOLTIP 'Generate program source'

   DEFINE BUTTON OF oBar ;
      RESOURCE 'DLG' TOP ;
      PROMPT 'Dialog' ;
      ACTION SetBrwInDlg( oBrw ) ;
      TOOLTIP 'View Browse in Dialog'

return oBar

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

static function SetBrwInDlg( oBrw )

   local oWnd, oDlg

   oWnd  := oBrw:oWnd

   DEFINE DIALOG oDlg SIZE 800,600 PIXEL TITLE oWnd:cTitle


   ACTIVATE DIALOG oDlg ;
      ON INIT InitBrwDlg( oBrw, oDlg ) ;
      VALID ExitBrwDlg( oBrw, oWnd ) ;
      ON RIGHT CLICK ( SetWindowLong( oBrw:hWnd, -20, ;
         nXor( GetWindowLong( oBrw:hWnd, -20 ), 0x200 ) ) )


return nil

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

static function InitBrwDlg( oBrw, oDlg )

   local oWnd  := oBrw:oWnd
   local nColsWidth  := oBrw:GetDisplayColsWidth() + 24

   oBrw:oWnd   := oDlg
   SetParent( oBrw:hWnd, oDlg:hWnd )
   oBrw:nTop      := 20
   oBrw:nLeft     := 20
   oBrw:nHeight   := oDlg:nHeight - 80
   oBrw:nWidth    := oDlg:nWidth - 40
   if oBrw:nWidth > nColsWidth
      oBrw:nWidth       := nColsWidth
      oDlg:nWidth       := oBrw:nWidth + 40
   endif
   oBrw:Resize()
   oDlg:Center()
   oWnd:Hide()

return .f.

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

static function ExitBrwDlg( oBrw, oWnd )

   oBrw:oWnd   := oWnd
   SetParent( oBrw:hWnd, oWnd:hWnd )
   oWnd:oClient := oBrw
   oWnd:Show()
   oWnd:ReSize()

return .t.

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

static function ExcelMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Export to Excel" ACTION oBrw:ToExcel()
      MENUITEM "Export to Excel with Group Totals" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:ToExcel(,1)
   ENDMENU

return oPop

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

static function ReportMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Simple Report" ACTION oBrw:Report()
      MENUITEM "Report with Grouping" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:Report( nil, .t., .t., nil, 1 )
   ENDMENU

return oPop

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

static function ColMenu( ocol )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Align"
      MENU
         MENUITEM "Left Align" WHEN oCol:nDataStrAlign > 0 ;
            ACTION ( oCol:SetAlign( AL_LEFT ), oCol:oBrw:SetFocus() )
         MENUITEM "Center Align" WHEN oCol:nDataStrAlign != AL_CENTER ;
            ACTION ( oCol:SetAlign( AL_CENTER ), oCol:oBrw:SetFocus() )
         MENUITEM "Right Align" WHEN oCol:nDataStrAlign != AL_RIGHT ;
            ACTION ( oCol:SetAlign( AL_RIGHT ), oCol:oBrw:SetFocus() )
      ENDMENU
      MENUITEM "Freeze" ACTION ( oCol:oBrw:nFreeze := oCol:nPos, oCol:oBrw:Refresh(), oCol:oBrw:SetFocus() )
      MENUITEM "Stretch" ACTION ( oCol:oBrw:nStretchCol := oCol:nCreationOrder, oCol:oBrw:ReSize(), ;
                        oCol:oBrw:Refresh(), ;
                        oCol:oBrw:SetFocus() )


      MENUITEM "Edit" ACTION (   oCol:nEditType := If( oCol:nEditType > 0, 0, 1 ), ;
                                 oMenuItem:SetCheck( oCol:nEditType > 0 ) )

      MENUITEM 'Inspect' ACTION XBrowse( oCol )
      MENUITEM 'Rptcode' ACTION MsgInfo( oCol:RptCode() )

   ENDMENU

return oPop

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

static function ConfigMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "2007" CHECKED ;
         ACTION ( oBrw:l2007 := !oBrw:l2007, oMenuItem:SetCheck( oBrw:l2007 ), ;
                  oBrw:Refresh(), oBrw:SetFocus() )
      MENUITEM "FastEdit" ;
         ACTION ( oBrw:lFastEdit := !oBrw:lFastEdit, oMenuItem:SetCheck( oBrw:lFastEdit ), ;
                  oBrw:SetFocus() )
      MENUITEM "RecordSelector" CHECKED ;
         ACTION ( oBrw:lRecordSelector := !oBrw:lRecordSelector, ;
                  oMenuItem:SetCheck( oBrw:lRecordSelector ),    ;
                  oBrw:Refresh(), oBrw:SetFocus() )
      MENUITEM "HScroll" CHECKED ;
         ACTION ( oMenuItem:SetCheck( oBrw:SetHScroll( ! oBrw:lHScroll ) ) )

      MENUITEM "Marquee"
      MENU
         MENUITEM "NoMarquee"   ACTION ( oBrw:nMarqueeStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "DottedCell"  ACTION ( oBrw:nMarqueeStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "SolidCell"   ACTION ( oBrw:nMarqueeStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL cell"  ACTION ( oBrw:nMarqueeStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL RowRC" ACTION ( oBrw:nMarqueeStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL Row"   ACTION ( oBrw:nMarqueeStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL RowMS" ACTION ( oBrw:nMarqueeStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "Row LineStyle"
      MENU
         MENUITEM "No Lines"    ACTION ( oBrw:nRowDividerStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Black"       ACTION ( oBrw:nRowDividerStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Dark Gray"   ACTION ( oBrw:nRowDividerStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "ForeColor"   ACTION ( oBrw:nRowDividerStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Light Gray"  ACTION ( oBrw:nRowDividerStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Inset"       ACTION ( oBrw:nRowDividerStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Raised"      ACTION ( oBrw:nRowDividerStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "Col LineStyle"
      MENU
         MENUITEM "No Lines"    ACTION ( oBrw:nColDividerStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Black"       ACTION ( oBrw:nColDividerStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Dark Gray"   ACTION ( oBrw:nColDividerStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "ForeColor"   ACTION ( oBrw:nColDividerStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Light Gray"  ACTION ( oBrw:nColDividerStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Inset"       ACTION ( oBrw:nColDividerStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Raised"      ACTION ( oBrw:nColDividerStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "ColDividerComplete" CHECKED ACTION ( ;
            oBrw:lColDividerComplete   := ! oBrw:lColDividerComplete,   ;
            oMenuItem:SetCheck( oBrw:lColDividerComplete ),             ;
            oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "BackGround"
      MENU
         MENUITEM "None"     ACTION ( oBrw:SetBackGround(), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "Paper"    ACTION ( oBrw:SetBackGround( "PAPER" ), oBrw:SetFocus() )
         MENUITEM "Stone"    ACTION ( oBrw:SetBackGround( "STONE" ), oBrw:SetFocus() )
         MENUITEM "FiveBack" ACTION ( oBrw:SetBackGround( "FIVEBACK" ), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "Select Image" ACTION SetBmpBack( oBrw )
         MENUITEM "ImageMode"
         MENU
            MENUITEM "Tiled"    WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_TILED ) )
            MENUITEM "Stretch"  WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_STRETCH ) )
            MENUITEM "Fill"     WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_FILL ) )
         ENDMENU
      ENDMENU

      MENUITEM "Font"        ACTION ( oBrw:SelFont(), oBrw:SetFocus() )
      MENUITEM "Stretch"
      MENU
         MENUITEM "None"     ACTION ( oBrw:nStretchCol := STRETCHCOL_NONE, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Last"     ACTION ( oBrw:nStretchCol := STRETCHCOL_LAST, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Widest"   ACTION ( oBrw:nStretchCol := STRETCHCOL_WIDEST, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU
      MENUITEM "NoFreeze"    WHEN ( oBrw:nFreeze > 0 ) ;
                             ACTION ( oBrw:nFreeze := 0, oBrw:Refresh(), oBrw:SetFocus() )

   ENDMENU

return oPop
//----------------------------------------------------------------------------//

static function SetBmpBack( oBrw )

   local cImage

   if ! Empty( cImage := cGetFile( "Image File (*.bmp,jpg,png)|*.bmp;*.png;*.jpg|", ;
                                 "Select Image file ", 1, ;
                                 "\fwh\bitmaps" ) )
      oBrw:SetBackGround( cImage )
   endif
   oBrw:SetFocus()

return nil

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

static function ViewCode( oBrw )

   local aCode    := Array( 4 )
   local aGet     := Array( 4 )
   local oDlg, oFolder
   local oFont

#define DLGWD  350 //250
#define DLGHT  250

   aCode := oBrw:PrgCode()

   DEFINE FONT oFont NAME 'LUCIDA CONSOLE' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE DLGWD*2, DLGHT*2 PIXEL ;
      TITLE oBrw:oWnd:cTitle + " ( Source)" ;
      FONT WndMain():oFont

   @ 05,05 FOLDER oFolder ;
      PROMPTS 'ListBox Style', 'CommandStyle', 'Oops Style', 'Report Code' ;
      SIZE DLGWD - 10, DLGHT - 27 PIXEL ;
      OF oDlg ; // ADJUST
      FONT WndMain():oFont

   @ 10,10 GET aGet[ 1 ] VAR aCode[ 1 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 1 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 2 ] VAR aCode[ 2 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 2 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 3 ] VAR aCode[ 3 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 3 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 4 ] VAR aCode[ 4 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 4 ] ;
      FONT oFont


   @ DLGHT-20,05 BUTTONBMP BITMAP 'COPY3' SIZE 16,16 PIXEL OF oDlg ;
      ACTION CopyToClip( aCode[ oFolder:nOption ] )
   @ DLGHT-20,23 BUTTONBMP BITMAP 'SAVE2' SIZE 16,16 PIXEL OF oDlg ;
      ACTION SaveCode( aCode[ oFolder:nOption ] )
   @ DLGHT-20,41 BUTTONBMP BITMAP 'RUN'   SIZE 16,16 PIXEL OF oDlg ;
      ACTION CompileAndRun( aCode[ oFolder:nOption ] )

   @ DLGHT-20,DLGWD-21 BUTTONBMP BITMAP 'CLOSE2' ;
      SIZE 16,16 PIXEL OF oDlg ;
      ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//
static function CopyToClip( cText )

   local oClip

   oClip := TClipBoard():New()
   if oClip:Open()
      oClip:SetText( cText )
      oClip:Close()
   endif
   oClip:End()

return nil
//----------------------------------------------------------------------------//

static function SaveCode( cText )

   local cFile

   if ! Empty( cFile := cGetFile(   "Prg File (*.PRG)|*.PRG|",          ;
                                    "Select PRG File to Save",       ;
                                    CurDir(), .t. ) )


      if ! MemoWrit( cFile, cText )
         MsgInfo( 'Write Failure' )
      endif

   endif

return nil
//----------------------------------------------------------------------------//

static function CompileAndRun( cText )

#ifdef __XHARBOUR__
   MemoWrit( 'test_x.prg', cText )
   WinExec( 'buildx.bat test_x' )
#else
   MemoWrit( 'test_x.prg', cText )
   WinExec( 'buildh.bat test_x' )
#endif

return nil

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


function dbfbuild()

   local oDlg, oGet, oGet1, oType, oLen, oDec, oLbx, oBtnAdd, oBtnEdit
   local cName    := Space( 9 ) // Limit to 9 instead of 10 for TDatabase
   local cType    := "C"
   local nLen     := 10
   local nDec     :=  0
   local cField   := Space( 20 )
   local cTypes   := "CNLDM"
   local aLens    := { 10, 10, 1, 8, 8 }
   local cDbfName := Space( 12 )
   local lEditing := .f.

   cDbfName:= padr("TEST",12)

   DEFINE DIALOG oDlg RESOURCE "DbfBuild" TITLE "FiveWin - DbfBuilder"

   REDEFINE GET oGet VAR cName ID 110 OF oDlg picture "@!XXXXXXXXX"

   REDEFINE COMBOBOX oType VAR cType  ITEMS { "C", "N", "L", "D", "M" } ;
      ON CHANGE ( nLen := aLens[ At( cType, cTypes ) ], oLen:Refresh() );
      ID 120 OF oDlg

   REDEFINE GET oLen VAR nLen PICTURE "9999" ID 130 OF oDlg

   REDEFINE GET oDec VAR nDec PICTURE "9"    ID 140 OF oDlg

   REDEFINE BUTTON oBtnAdd ID 150 OF oDlg ;
      ACTION (AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
                       @cName, cType, nLen, nDec, @lEditing ), oBtnAdd:oJump:= oGet, oDlg:refresh() )

   REDEFINE BUTTON ID 160 OF oDlg ACTION oDlg:End()

   REDEFINE LISTBOX oLbx VAR cField ID 170 OF oDlg

   oLbx:blDblClick:={|| EditField( oBtnAdd, oBtnEdit,;
                        cField, @cName, @cType, @nLen, @nDec, @lEditing,;
                        oGet, oType, oLen, oDec )}

   REDEFINE BUTTON oBtnEdit ID 180 OF oDlg ;
      ACTION EditField( oBtnAdd, oBtnEdit,;
                        cField, @cName, @cType, @nLen, @nDec, @lEditing,;
                        oGet, oType, oLen, oDec )

   REDEFINE BUTTON ID 190 OF oDlg ACTION oLbx:Del()

   REDEFINE BUTTON ID 112 OF oDlg ACTION oLbx:swapUp()

   REDEFINE BUTTON ID 113 OF oDlg action oLbx:swapDown()

   REDEFINE BUTTON ID 111 OF oDlg ;
      ACTION (cDbfName:=padr(cFileNoPath(OPEN(oLbx, cName)),12), oGet1:refresh() )

   REDEFINE GET oGet1 var cDbfName ID 210 OF oDlg

   REDEFINE BUTTON ID 220 OF oDlg ;
      ACTION BuildDbf( trim(cDbfName), oLbx )

   ACTIVATE DIALOG oDlg CENTERED ;
      //on init  import( cDbfName, oLbx )


return nil

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

static function AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
                          cName, cType, nLen, nDec, lEditing )

   if Empty( cName )
      MsgInfo( "I need a field name", "Sorry" )
   else
      if ! lEditing
         oLbx:Add( xPadR( cName, 100 )  + cType + ;
                   xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
                   oLbx:GetPos() )
            else
         oLbx:Modify( xPadR( cName, 100 ) + cType + ;
                      xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ) )
         oBtnAdd:SetText( "&Add" )
         oBtnEdit:Enable()
         lEditing = .f.
      endif
      cName = Space( 10 )
      oGet:Refresh()
      oGet:SetFocus( .t. )
   endif

return nil

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

static function BuildDbf( cDbfName, oLbx )

   local aFields := {}
   local n
   local cTempFile:=""

   if Empty( cDbfName )
      MsgAlert( "I need a DBF name", "Sorry" )
      return nil
   endif

   if Len( oLbx:aItems ) == 0
      MsgAlert( "No fields defined", "Sorry" )
      return nil
   endif

   if At( ".", cDbfName ) == 0
      cDbfName += ".dbf"
   endif

   for n = 1 to Len( oLbx:aItems )
      AAdd( aFields, _FieldInfo( AllTrim( oLbx:aItems[ n ] ) ) )
   next

   if File( cDbfName )
      if MsgYesNo( "DBF already exists, update structure?", "Info" )
         cTempFile:= tempFile("dbf")
         DbCreate( cTempFile, aFields )
         use (cTempFile)
         append from (cDbfName)
         use
         ferase( cDbfName )
         rename ( cTempFile ) to (cDbfName)

         // Handle memo field(s)
         // There is a problem when this file already exists--it doesn't get renamed for some reason.
         if file( cFileNoExt( cTempFile ) +".dbt" )
         //msgInfo( "memo file found")
         //cOld := cFileNoExt(cTempFile)+".dbt"
         //cNew := cFileNoExt( cDbfName )+".dbt"
         //msgInfo( cOld, "cOld")
         //msgInfo( cNew, "cNew")
            rename ( cFileNoExt(cTempFile)+".dbt") to ( cFileNoExt( cDbfName )+".dbt")
            //rename (cOld) to (cNew)
         endif

         return nil
      endif
   endif

   DbCreate( cDbfName, aFields )
   MsgInfo( "DBF created!", "AllRight" )

return nil

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

// Fixed function in dbfbuild.prg
static function _FieldInfo( cItem )

return { AllTrim( StrToken( cItem, 1 ) ),;
         AllTrim( StrToken( cItem, 2 ) ),;
         Val( StrToken( cItem, 3 ) ),;
         Val( StrToken( cItem, 4 ) ) }

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

static function EditField( oBtnAdd, oBtnEdit, cField,;
                           cName, cType, nLen, nDec, lEditing,;
                           oName, oType, oLen, oDec )

   if ! Empty( cField )
      oBtnAdd:SetText( "&Replace" )
      oBtnEdit:Disable()
      lEditing = .t.

      cName = padr(StrToken( cField, 1 ),9)

      cType = StrToken( cField, 2 )
      nLen  = Val( StrToken( cField, 3 ) )
      nDec  = Val( StrToken( cField, 4 ) )

      oName:Refresh()
      oType:Refresh()
      oLen:Refresh()
      oDec:Refresh()
   else
      MsgInfo( "Select a field to edit", "Please" )
   endif

return nil

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

static function import( cFile, oLbx )

   local aStruct,i:=0
   local cName,cType,nLen,nDec
   cFile:= trim(cFile)
   use (cFile)
   aStruct := dbstruct()

   for i:=1 to len( aStruct )

      cName := aStruct[i,1]
      cType := aStruct[i,2]
      nLen  := aStruct[i,3]
      nDec  := aStruct[i,4]

      oLbx:Add( xPadR( cName, 100 ) + cType + ;
              xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
              oLbx:GetPos() )

    next

    use

return cName

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

STATIC FUNCTION OPEN(oLbx)
   local cFile
   local cFileMask := "Database (DBF) | *.dbf |"
   local cInitialDirectory
   local lSave:= .f.
   local lLongNames:= .t.


   cFile:= cGetFile32( cFileMask, , , cInitialDirectory, lSave, lLongNames )

   if ! empty(cFile)
       import( cFile, oLbx )
   endif

return cFile

// Returns an unused filename with cExtension.
// cPath is optional. Defaults to current directory.
FUNCTION tempFile(cExtension,cPath)
   local cFile
   default cPath:=""
   cExtension:= strtran(cExtension,".","")
   // loop until you find a name that doesn't exist
   do while .t.
      cFile:="AAA"+trim(str(seconds(),5,0))+"."+upper(cExtension)
      cFile:=strtran(cFile," ","0") // fix for hours between 00:00 & 01:00
      cFile:= cPath + cFile
      if .not. file( cFile )
         exit
      endif
   enddo
return cPath + cFile

CLASS TDbfWnd

   DATA  oBrowse, oWnd
   DATA  cAlias
   DATA  lExclusive INIT .F.
   
   METHOD New( oWndChild, oBrw )
   METHOD DelRec()
   METHOD Refresh() INLINE ::oBrowse:Refresh()

ENDCLASS

METHOD New( oWndChild, oBrw ) CLASS TDbfWnd

   ::oWnd    = oWndChild
   ::oBrowse = oBrw
   ::oWnd:Cargo = Self
   ::oWnd:bGotFocus = { || oDbfWnd := ::oWnd:Cargo }
   ::cAlias = Alias()
   
   oDbfWnd = Self

return Self

METHOD DelRec() CLASS TDbfWnd

     /*
     IF ! ::oItemDelReg:lActive

          ::oBrowse:Setfocus()

          RETU NIL

     ENDIF
     */


     Select(::cAlias)

     IF ! ::lExclusive

          IF !(::cAlias)->(DbRLock())

               MsgRun({|| SysWait(1) }, "Record lock error")

               RETU NIL

          ENDIF

     ENDIF

     IF Deleted()
          DbRecall()
     ELSE
          DbDelete()
     ENDIF

     IF ! ::lExclusive
        ( ::cAlias )->( DbUnlock() )
     ENDIF

     IF Set( _SET_DELETED )
          DO WHILE Deleted() .AND. !Bof()
               DbSkip( -1 )
          ENDDO
          ::Refresh()
     ENDIF

     // SayInfo(Self)

     ::oBrowse:Setfocus()
     
return nil    

// eof
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WDBU clone - xbrDBU

Postby Otto » Tue Aug 30, 2011 12:09 pm

Hello Antonio,

thank you for your help.

I insert AppRec. It is working.

Best regrards,
Otto

Code: Select all  Expand view
#include 'fivewin.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

#DEFINE EXENAME "xWDBU"

static oWnd, oDbfWnd

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

function Main()

   local oBrw, oFont

   SetBalloon( .t. )
   xbrNumformat( ,.t. )

   SET XBROWSE TO TXBrCode()

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12

   DEFINE WINDOW oWnd MDI ;
      TITLE 'DBU for Windows' ;
      MENU MainMenu()
   
   oWnd:SetFont( oFont )
    // MakeBar( oWnd )
    // oWnd:oBar:cToolTip := { || "My Color" }

   SET MESSAGE OF oWnd TO 'Developed with Harbour and FWH (FiveWin for Harbour/xHarbour)' 2007 DATE CLOCK KEYBOARD

   ACTIVATE WINDOW oWnd ;
      ON DROPFILES Files2Brw( nRow, nCol, aFiles )

return nil

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

INIT PROCEDURE PrgInit

   SET DELETED ON
   SET EXCLUSIVE OFF

   SET DATE ITALIAN
   SET CENTURY ON

   RDDSetDefault( 'DBFCDX' )

return

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

static function MakeBar( oWnd )

   local oBar

   DEFINE BUTTONBAR oBar OF oWnd SIZE 56,64 2007

   DEFINE BUTTON OF oBar PROMPT 'Open Data' ;
      RESOURCE 'Open' ;
      ACTION NewFile()

    DEFINE BUTTON OF oBar PROMPT 'dbfbuild' ;
      RESOURCE 'Open' ;
      ACTION dbfbuild()

return oBar

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

static function MainMenu()

   local oMenu, URLNAME := "http://www.fivetechsoft.com"

   MENU oMenu 2007
     
          MENUITEM "File"
 
          MENU
               MENUITEM "&New"+chr(9)+"Ctrl+U" ;
                    RESOURCE "NEW" ;
                    ACTION  NewFile(dbfbuild()) ;  //MsgInfo( "Fbrowse(DbfBuild(),.t.) ") ;
                    MESSAGE "Create new file" ;
                    ACCELERATOR ACC_CONTROL, asc("U") ;
                    ENABLED
                   
               MENUITEM "&Open"+chr(9)+"Ctrl+A" ;
                    RESOURCE "OPEN" ;
                    ACTION NewFile() ;
                    MESSAGE "Open file" ;
                    ACCELERATOR ACC_CONTROL, asc("A") ;
                    ENABLED
                   
               MENUITEM "C&lose"+chr(9)+"Ctrl+E" ;
                    RESOURCE "SAVE" ;
                    ACTION WndMain():oWnd:End() ;
                    MESSAGE "Close file" ;
                    ACCELERATOR ACC_CONTROL, asc("E") ;
                    ENABLED
                   
               MENUITEM "&Print"+chr(9)+"Ctrl+T" ;
                    RESOURCE "PRINTER" ;
                    ACTION MsgInfo( " oDbfWnd:Report() ") ;
                    MESSAGE "Print file" ;
                    ACCELERATOR ACC_CONTROL, asc("T") ;
                    ENABLED
                   
               MENUITEM "Command &Interpreter" ;
                    RESOURCE "DOT" ;
                    ACTION MsgInfo( " DotNew()  ");
                    MESSAGE "Invokes the command interpreter" ;
                    ENABLED
                   
               MENUITEM "&Modify structure"+chr(9)+"Ctrl+M" ;
                    RESOURCE "DESIGN" ;
                    ACTION  NewFile(dbfbuild()) ;
                    MESSAGE "Modify file structure" ;
                    ACCELERATOR ACC_CONTROL, asc("M") ;
                    ENABLED
                   
               MENUITEM "Multi-&file operation" ;
                    RESOURCE "MULTFILE" ;
                    ACTION MsgInfo( " MultiFile()  ");
                    MESSAGE "&Multi-file operation" ;
                    ENABLED
                   
               MENUITEM "Import from ODBC database" ;
                    RESOURCE "IMPORT" ;
                    ACTION MsgInfo( " ImportODBC(oWnd)  ");
                    MESSAGE "Import data from a ODBC database" ;
                    ENABLED
                   
               MENUITEM "&Configuration" ;
                    RESOURCE "CONFIG" ;
                    ACTION MsgInfo( " AppConfig() ");
                    MESSAGE "Program configuration" ;
                    ENABLED
                   
               SEPARATOR
               
               MENUITEM "Specif&y printer" ;
                    RESOURCE "PROPERTY" ;
                    ACTION  PrinterSetup()  ;
                    MESSAGE "Printer configuration" ;
                    ENABLED
               
               MENUITEM "&Map Network Drive" ;
                    RESOURCE "NETCONNE" ;
                    ACTION  MsgInfo(" WNetConnectDialog() ") ;
                    MESSAGE "Connect to a network drive" ;
                    ENABLED
               
               MENUITEM "&Disconnect Network Drive" ;
                    RESOURCE "NETDISCO" ;
                    ACTION  MsgInfo(" WNetDisconnect() ") ;
                    MESSAGE "Disconnect from a network drive" ;
                    ENABLED
               
               MENUITEM "&Exit"+chr(9)+"Alt+F4" ;
                    RESOURCE "EXIT" ;
                    ACTION WndMain():End() ;
                    MESSAGE "Exit from the application" ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Edit"
          MENU
               MENUITEM "&Copy record"+chr(9)+"Ctrl+C" ;
                    RESOURCE "COPY" ;
                    ACTION MsgInfo( " oDbfWnd:CopyRec() ") ;
                    MESSAGE "Copy record to the Clipboard" ;
                    ACCELERATOR ACC_CONTROL, asc("C") ;
                    ENABLED
               
               MENUITEM "&Paste record"+chr(9)+"Ctrl+V" ;
                    RESOURCE "PASTE" ;
                    ACTION MsgInfo( " oDbfWnd:PasteRec() ");
                    MESSAGE "Paste record from the Clipboard" ;
                    ACCELERATOR ACC_CONTROL, asc("V")
               
               SEPARATOR
               
               MENUITEM "&Insert record"+chr(9)+"Ctrl+Insert" ;
                    RESOURCE "NEW" ;
                    ACTION oDbfWnd:AppRec();
                    MESSAGE "Append record" ;
                    ACCELERATOR ACC_CONTROL, VK_INSERT ;
                    ENABLED
               
               MENUITEM "&Del/Recall record"+chr(9)+"Ctrl+Del" ;
                    RESOURCE "DEL" ;
                    ACTION oDbfWnd:DelRec() ;
                    MESSAGE "Del actual record" ;
                    ACCELERATOR ACC_CONTROL, VK_DELETE ;
                    ENABLED
               
               MENUITEM "&Edit field"+chr(9)+"Enter" ;
                    RESOURCE "TEXTBOX" ;
                    ACTION MsgInfo( " oDbfWnd:EditFld() ");
                    MESSAGE "Edit actual record field" ;
                    ENABLED
                    //ACCELERATOR ACC_SHIFT, VK_RETURN ;

               MENUITEM "&Edit record"+chr(9)+"CTRL+Enter" ;
                    RESOURCE "EDIT" ;
                    ACTION oDbfWnd:EditRec();
                    MESSAGE "Edit actual record (all fields)" ;
                    ENABLED
                    //ACCELERATOR ACC_CONTROL, VK_RETURN ;

          ENDMENU
         
          MENUITEM "&Navigation"
          MENU
               MENUITEM "&Search"+chr(9)+"Ctrl+S" ;
                    RESOURCE "SEARCH" ;
                    ACTION MsgInfo( " oDbfWnd:Seek() ");
                    MESSAGE "Search records using the active index" ;
                    ACCELERATOR ACC_CONTROL, asc("S") ;
                    ENABLED
               
               MENUITEM "&Go to"+chr(9)+"Ctrl+G" ;
                    ACTION MsgInfo( " oDbfWnd:Ira() ");
                    MESSAGE "Jump to a record by its Recno()" ;
                    ACCELERATOR ACC_CONTROL, asc("G") ;
                    ENABLED
               
               MENUITEM "S&kip"+chr(9)+"Ctrl+K" ;
                    ACTION MsgInfo( " oDbfWnd:Skip() ");
                    MESSAGE "Skip records" ;
                    ACCELERATOR ACC_CONTROL, asc("K") ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Locate"+chr(9)+"F3" ;
                    ACTION MsgInfo( " oDbfWnd:Locate() ");
                    MESSAGE "Locate record" ;
                    ACCELERATOR ACC_NORMAL, VK_F3 ;
                    ENABLED
               
               MENUITEM "&Continue"+chr(9)+"F4" ;
                    ACTION MsgInfo( " oDbfWnd:Locate(.T.)") ;
                    MESSAGE "Locate next record" ;
                    ACCELERATOR ACC_NORMAL, VK_F4 ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Indexes"
          MENU
               MENUITEM OemtoAnsi("&Open Index"+chr(9)+"Ctrl+X") ;
                    RESOURCE "OPEN" ;
                    ACTION MsgInfo( " oDbfWnd:OpenIndex() ");
                    MESSAGE "Select an index file" ;
                    ACCELERATOR ACC_CONTROL, asc("X") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Close Index"+chr(9)+"Ctrl+L") ;
                    RESOURCE "SAVE" ;
                    ACTION MsgInfo( " oDbfWnd:CloseIndex()") ;
                    MESSAGE "Close current index file" ;
                    ACCELERATOR ACC_CONTROL, asc("L") ;
                    ENABLED
               
               MENUITEM "&Previous order"+chr(9)+"Ctrl+P" ;
                    RESOURCE "PREV" ;
                    ACTION MsgInfo( " oDbfWnd:PrevOrder()");
                    MESSAGE "Go to previous order" ;
                    ACCELERATOR ACC_CONTROL, asc("P") ;
                    ENABLED
               
               MENUITEM "&Next order"+chr(9)+"Ctrl+N" ;
                    RESOURCE "NEXT" ;
                    ACTION MsgInfo( " oDbfWnd:NextOrder() ");
                    MESSAGE "Go to next order" ;
                    ACCELERATOR ACC_CONTROL, asc("N") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Filter by scope"+chr(9)+"Ctrl+F") ;
                    RESOURCE "FILTER" ;
                    ACTION MsgInfo( " oDbfWnd:Scope() ");
                    MESSAGE "Set a scope to filter records, based on the active index" ;
                    ACCELERATOR ACC_CONTROL, asc("F") ;
                    ENABLED
               
               MENUITEM OemtoAnsi("&Create new index"+chr(9)+"Ctrl+W") ;
                    RESOURCE "INDEX" ;
                    ACTION MsgInfo( " oDbfWnd:BuildIndex() ");
                    MESSAGE "Create a new index file or Tag" ;
                    ACCELERATOR ACC_CONTROL, asc("W") ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Delete Order" ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DelTag() ");
                    MESSAGE "Delete current Order (Tag)" ;
                    ENABLED
               
               MENUITEM "&Reindex"+chr(9)+"Ctrl+R" ;
                    RESOURCE "REPEAT" ;
                    ACTION MsgInfo( " oDbfWnd:Reindex() ");
                    MESSAGE "Reindex all the open indexes" ;
                    ACCELERATOR ACC_CONTROL, asc("R") ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Utilities"
          MENU
               MENUITEM "&More information"+chr(9)+"Ctrl+I" ;
                    RESOURCE "PROPERTY" ;
                    ACTION MsgInfo( " oDbfWnd:Info() ");
                    MESSAGE "Show additional information about the current file" ;
                    ACCELERATOR ACC_CONTROL, asc("I") ;
                    ENABLED
               
               MENUITEM "&Browse Columns"+chr(9)+"Ctrl+B" ;
                    RESOURCE "TBROWSE" ;
                    ACTION MsgInfo( " oDbfWnd:SetColumn() ");
                    MESSAGE "Columns configuration" ;
                    ACCELERATOR ACC_CONTROL, asc("B") ;
                    ENABLED
               
               MENUITEM "&Relations" ;
                    RESOURCE "CHAIN" ;
                    ACTION MsgInfo( " oDbfWnd:Relations() ");
                    MESSAGE "Establish relations with other databases" ;
                    ENABLED
               
               MENUITEM "Establish &Filter" ;
                    RESOURCE "FILTER" ;
                    ACTION MsgInfo( " oDbfWnd:Filter() ");
                    MESSAGE "Set the criteria by which to filter records" ;
                    ENABLED
               
               MENUITEM "Coun&t" ;
                    ACTION MsgInfo( " oDbfWnd:Count() ");
                    MESSAGE "Count the number of records meeting a certain criteria" ;
                    ENABLED
               
               MENUITEM "&Statistics" ;
                    RESOURCE "STATICS" ;
                    ACTION MsgInfo( " oDbfWnd:Sum() ");
                    MESSAGE "Statistics calculations of all numeric fields" ;
                    ENABLED
               
               MENUITEM "&Graphics" ;
                    RESOURCE "GRAPH" ;
                    ACTION MsgInfo( " oDbfWnd:Graphics() ");
                    MESSAGE "Graphics based on current data file" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Append from..." ;
                    RESOURCE "IMPORT" ;
                    ACTION MsgInfo( " oDbfWnd:AppendFrom() ");
                    MESSAGE "Append records from another file" ;
                    ENABLED
               
               MENUITEM "&Copy to..." ;
                    RESOURCE "COPY" ;
                    ACTION MsgInfo( " oDbfWnd:CopyTo() ");
                    MESSAGE "Copy records to another file" ;
                    ENABLED
               
               MENUITEM "&Delete..." ;
                    RESOURCE "DEL" ;
                    ACTION MsgInfo( " oDbfWnd:DeleteFor() ");
                    MESSAGE "Delete all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "Reca&ll..." ;
                    ACTION MsgInfo( " oDbfWnd:RecallFor() ");
                    MESSAGE "Recall all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "R&eplace..." ;
                    ACTION MsgInfo( " oDbfWnd:ReplaceFor() ");
                    MESSAGE "Replace all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "S&cript process..." ;
                    RESOURCE "SCRIPT" ;
                    ACTION MsgInfo( " oDbfWnd:Script()  ");
                    MESSAGE "Process a script file to all records matching a certain criteria" ;
                    ENABLED
               
               MENUITEM "Pac&k" ;
                    ACTION MsgInfo( " oDbfWnd:Pack()  ");
                    MESSAGE "Eliminate phisically deleted records" ;
                    ENABLED
               
               MENUITEM "&Zap" ;
                    ACTION MsgInfo( " oDbfWnd:Zap()  ");
                    MESSAGE "Delete every record in the database" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Oem to Ansi" ;
                    ACTION MsgInfo( " oDbfWnd:OtoA(.F.)  ");
                    MESSAGE "Translate from OEM to ANSI" ;
                    ENABLED
               
               MENUITEM "A&nsi to Oem" ;
                    ACTION MsgInfo( " oDbfWnd:OtoA(.T.)  ");
                    MESSAGE "Translate from ANSI to OEM" ;
                    ENABLED
          ENDMENU
         
          MENUITEM "&Windows"
          MENU
          MENUITEM "&Cascade" ;
               RESOURCE "CASCAWND" ;
               MESSAGE OemToAnsi( "Organize windows on cascade" ) ;
               ACTION WndMain():Cascade()
         
          MENUITEM "&Vertical mosaic" ;
               RESOURCE "MOSVRWND" ;
               MESSAGE OemToAnsi( "Organize windows on vertical mosaic" ) ;
               ACTION WndMain():Tile()
         
          MENUITEM "&Horizontal mosaic" ;
               RESOURCE "MOSHRWND" ;
               ACTION WndMain():Tile( .t. );
               MESSAGE OemToAnsi( "Organize windows on horizontal mosaic" )
         
          MENUITEM "&Minimize Windows" ;
               RESOURCE "MINIMWND" ;
               ACTION WndMain():IconizeAll() ;
               MESSAGE "Minimize all Windows"
         
          MENUITEM "&Restore all windows" ;
               RESOURCE "MAXIMWND" ;
               ACTION Asend(WndMain():oWndClient:aWnd,'NORMAL') ;
               MESSAGE "Restore all windows"
         
          MENUITEM "C&lose windows" ;
               RESOURCE "CLOSEWND" ;
               ACTION WndMain():CloseAll() ;
               MESSAGE "Close all windows"
         
          MENUITEM "&Organize Icons" ;
               MESSAGE OemToAnsi( "Organize minimized windows" ) ;
               ACTION WndMain():ArrangeIcons()
         
          ENDMENU
         
          MENUITEM "&Help"
          MENU
               MENUITEM "&Index"+chr(9)+"F1" ;
                    RESOURCE "HELP" ;
                    ACTION MsgInfo( " HelpIndex()  ");
                    MESSAGE "Shows the Help contents" ;
                    ENABLED
               
               MENUITEM "&Using Help" ;
                    ACTION MsgInfo( " Winhelp.hlp") ;
                    MESSAGE "More information about using help" ;
                    ENABLED
               
               MENUITEM "&Readme text file" ;
                    RESOURCE "NOTEPAD" ;
                    ACTION  WinExec("Notepad readme.txt") ;
                    MESSAGE "Modifications and enhancements not present on the help file" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&Web page (Internet)" ;
                    RESOURCE "INTERNET" ;
                    ACTION ShellExecute(oWnd:hWnd, "open", URLNAME) ;
                    MESSAGE "Web page on the Internet" ;
                    ENABLED
               
               MENUITEM "&Send mail" ;
                    RESOURCE "MAIL" ;
                    ACTION  MsgInfo(" SendMail() ") ;
                    MESSAGE "Contact with us via eMail" ;
                    ENABLED
               
               MENUITEM "&Calculator" ;
                    RESOURCE "CALC" ;
                    ACTION  WinExec("Calc.exe") ;
                    MESSAGE "Windows calculator" ;
                    ENABLED
               
               SEPARATOR
               
               MENUITEM "&About "+EXENAME ;
                    RESOURCE "INFO" ;
                    ACTION MsgAbout( "DBU for Windows", "(c) FiveTech Software 2011" ) ;
                    MESSAGE "More information about the program" ;
                    ENABLED
          ENDMENU

ENDMENU

return oMenu

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

static function files2brw( nRow, nCol, aFiles )

   local cFile

   for each cFile in aFiles
      if Upper( cFileExt( cFile ) ) == 'DBF'
         File2Brw( cFile )
      else
         CheckBrwDrop( ClientToScreen( WndMain():hWnd, { nRow, nCol } ), cFile)
      endif
   next

return nil

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

static function file2brw( cFile )

   local oWndChild, oBrw
   local cAlias, cFileNoExt

   if ! OpenFile( cFile, @cAlias, @cFileNoExt )
      return nil
   endif

   DEFINE WINDOW oWndChild MDICHILD OF WndMain() ;
      TITLE cFileNoExt

   @ 0,0 XBROWSE oBrw OF oWndChild ;
      ALIAS cAlias ;
      AUTOCOLS AUTOSORT FOOTERS LINES CELL NOBORDER

   AEval( oBrw:aCols, { |oCol| oCol:cCol := oCol:cHeader } )
   AEval( oBrw:aCols, { |oCol| oCol:cHeader := Upper( Left( oCol:cHeader, 1 ) ) + Lower( Substr( oCol:cHeader, 2 ) ) } )
   oBrw:bPopUp       := { |o| ColMenu( o ) }

   oBrw:CreateFromCode()
   oWndChild:oClient := oBrw

   BrwBtnBar( oBrw )
   SET MESSAGE OF oWndChild TO cFile 2007
   
   ACTIVATE WINDOW oWndChild
   
   TDbfWnd():New( oWndChild, oBrw )

return nil

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

static function CheckBrwDrop( aPoint, cFile )

   local ownd, oBrw, nRow, nCol
   local nColPos, nRowPos

   if ( oWnd := WndMain():oWndActive ) != nil
      oBrw  := oWnd:oClient
      if oBrw != nil .and. oBrw:IsKindOf( TXBrowse() )
         aPoint   := ScreenToClient( oBrw:hWnd, aPoint )
         nRow     := aPoint[ 1 ]
         nCol     := aPoint[ 2 ]
         if oBrw:DropFile( nRow, nCol, cFile )
//            MsgInfo( 'handled' )
         else
            msginfo( 'Not Valid File' )
         endif
      endif
   endif

return nil

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

static function OpenFile( cFile, cAlias, cFileNoExt )

   local lOpen    := .f.
   local cDriver  := 'DBFCDX'

   if Upper( cFileExt( cFile ) ) == 'DBF'
      cFileNoExt  := cFileNoExt( cFile )
      cAlias   := cGetNewAlias( Left( cFileNoExt, 4 ) )
      TRY
         dbUseArea( .t., cDriver, cFile, cAlias, .t., .f. )
      CATCH
         MsgInfo( cFile + CRLF + 'can not be opened' )
         return .f.
      END
      lOpen := .t.
   else
      MsgInfo( 'Not a DBF File' )
   endif

return lOpen

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

static function NewFile()

   local cFile

   if ! Empty( cFile := cGetFile(   "DataFile (*.DBF)|*.dbf|",          ;
                                    "Select Data File to Browse",1,     ;
                                    "\fwh\samples" ) )
      File2Brw( cFile )
   endif


return nil

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


static function BrwbtnBar( oBrw )

   local oBar, oBtn

   DEFINE BUTTONBAR oBar OF oBrw:oWnd SIZE 56,64 3D 2007

   DEFINE BUTTON OF oBar ;
      RESOURCE "REPORT" TOP ;
      PROMPT "Report" ;
      MENU ReportMenu( oBrw ) ;
      ACTION This:ShowPopUp() ;
      MESSAGE "Print the browse contents" ;
      TOOLTIP { "Print Report", "Report" }

   DEFINE BUTTON OF oBar ;
      RESOURCE "EXCEL" TOP ;
      PROMPT "Excel" ;
      ACTION This:ShowPopUp() ;
      MENU ExcelMenu( oBrw ) ;
      MESSAGE "Export browse contents to Excel" ;
      TOOLTIP { "Export to Excel", "Excel" }

   DEFINE BUTTON oBtn OF oBar ;
      RESOURCE "CONFIG" TOP ;
      PROMPT "Config" ;
      MENU ConfigMenu( oBrw )  ;
      ACTION This:ShowPopUp() ;
      MESSAGE "Change background, Style2007, FastEdit option, etc" ;
      TOOLTIP { "Configure", "SetUp",,CLR_BLUE,nRGB(220,230,247) }

   DEFINE BUTTON OF oBar ;
      RESOURCE 'CODE' TOP ;
      PROMPT 'Source' ;
      ACTION ViewCode( oBrw ) ; //MemoEdit( oBrw:PrgCode() ) ;
      TOOLTIP 'Generate program source'

   DEFINE BUTTON OF oBar ;
      RESOURCE 'DLG' TOP ;
      PROMPT 'Dialog' ;
      ACTION SetBrwInDlg( oBrw ) ;
      TOOLTIP 'View Browse in Dialog'

return oBar

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

static function SetBrwInDlg( oBrw )

   local oWnd, oDlg

   oWnd  := oBrw:oWnd

   DEFINE DIALOG oDlg SIZE 800,600 PIXEL TITLE oWnd:cTitle


   ACTIVATE DIALOG oDlg ;
      ON INIT InitBrwDlg( oBrw, oDlg ) ;
      VALID ExitBrwDlg( oBrw, oWnd ) ;
      ON RIGHT CLICK ( SetWindowLong( oBrw:hWnd, -20, ;
         nXor( GetWindowLong( oBrw:hWnd, -20 ), 0x200 ) ) )


return nil

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

static function InitBrwDlg( oBrw, oDlg )

   local oWnd  := oBrw:oWnd
   local nColsWidth  := oBrw:GetDisplayColsWidth() + 24

   oBrw:oWnd   := oDlg
   SetParent( oBrw:hWnd, oDlg:hWnd )
   oBrw:nTop      := 20
   oBrw:nLeft     := 20
   oBrw:nHeight   := oDlg:nHeight - 80
   oBrw:nWidth    := oDlg:nWidth - 40
   if oBrw:nWidth > nColsWidth
      oBrw:nWidth       := nColsWidth
      oDlg:nWidth       := oBrw:nWidth + 40
   endif
   oBrw:Resize()
   oDlg:Center()
   oWnd:Hide()

return .f.

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

static function ExitBrwDlg( oBrw, oWnd )

   oBrw:oWnd   := oWnd
   SetParent( oBrw:hWnd, oWnd:hWnd )
   oWnd:oClient := oBrw
   oWnd:Show()
   oWnd:ReSize()

return .t.

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

static function ExcelMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Export to Excel" ACTION oBrw:ToExcel()
      MENUITEM "Export to Excel with Group Totals" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:ToExcel(,1)
   ENDMENU

return oPop

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

static function ReportMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Simple Report" ACTION oBrw:Report()
      MENUITEM "Report with Grouping" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:Report( nil, .t., .t., nil, 1 )
   ENDMENU

return oPop

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

static function ColMenu( ocol )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Align"
      MENU
         MENUITEM "Left Align" WHEN oCol:nDataStrAlign > 0 ;
            ACTION ( oCol:SetAlign( AL_LEFT ), oCol:oBrw:SetFocus() )
         MENUITEM "Center Align" WHEN oCol:nDataStrAlign != AL_CENTER ;
            ACTION ( oCol:SetAlign( AL_CENTER ), oCol:oBrw:SetFocus() )
         MENUITEM "Right Align" WHEN oCol:nDataStrAlign != AL_RIGHT ;
            ACTION ( oCol:SetAlign( AL_RIGHT ), oCol:oBrw:SetFocus() )
      ENDMENU
      MENUITEM "Freeze" ACTION ( oCol:oBrw:nFreeze := oCol:nPos, oCol:oBrw:Refresh(), oCol:oBrw:SetFocus() )
      MENUITEM "Stretch" ACTION ( oCol:oBrw:nStretchCol := oCol:nCreationOrder, oCol:oBrw:ReSize(), ;
                        oCol:oBrw:Refresh(), ;
                        oCol:oBrw:SetFocus() )


      MENUITEM "Edit" ACTION (   oCol:nEditType := If( oCol:nEditType > 0, 0, 1 ), ;
                                 oMenuItem:SetCheck( oCol:nEditType > 0 ) )

      MENUITEM 'Inspect' ACTION XBrowse( oCol )
      MENUITEM 'Rptcode' ACTION MsgInfo( oCol:RptCode() )

   ENDMENU

return oPop

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

static function ConfigMenu( oBrw )

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "2007" CHECKED ;
         ACTION ( oBrw:l2007 := !oBrw:l2007, oMenuItem:SetCheck( oBrw:l2007 ), ;
                  oBrw:Refresh(), oBrw:SetFocus() )
      MENUITEM "FastEdit" ;
         ACTION ( oBrw:lFastEdit := !oBrw:lFastEdit, oMenuItem:SetCheck( oBrw:lFastEdit ), ;
                  oBrw:SetFocus() )
      MENUITEM "RecordSelector" CHECKED ;
         ACTION ( oBrw:lRecordSelector := !oBrw:lRecordSelector, ;
                  oMenuItem:SetCheck( oBrw:lRecordSelector ),    ;
                  oBrw:Refresh(), oBrw:SetFocus() )
      MENUITEM "HScroll" CHECKED ;
         ACTION ( oMenuItem:SetCheck( oBrw:SetHScroll( ! oBrw:lHScroll ) ) )

      MENUITEM "Marquee"
      MENU
         MENUITEM "NoMarquee"   ACTION ( oBrw:nMarqueeStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "DottedCell"  ACTION ( oBrw:nMarqueeStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "SolidCell"   ACTION ( oBrw:nMarqueeStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL cell"  ACTION ( oBrw:nMarqueeStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL RowRC" ACTION ( oBrw:nMarqueeStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL Row"   ACTION ( oBrw:nMarqueeStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "HighL RowMS" ACTION ( oBrw:nMarqueeStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "Row LineStyle"
      MENU
         MENUITEM "No Lines"    ACTION ( oBrw:nRowDividerStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Black"       ACTION ( oBrw:nRowDividerStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Dark Gray"   ACTION ( oBrw:nRowDividerStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "ForeColor"   ACTION ( oBrw:nRowDividerStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Light Gray"  ACTION ( oBrw:nRowDividerStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Inset"       ACTION ( oBrw:nRowDividerStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Raised"      ACTION ( oBrw:nRowDividerStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "Col LineStyle"
      MENU
         MENUITEM "No Lines"    ACTION ( oBrw:nColDividerStyle := 0, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Black"       ACTION ( oBrw:nColDividerStyle := 1, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Dark Gray"   ACTION ( oBrw:nColDividerStyle := 2, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "ForeColor"   ACTION ( oBrw:nColDividerStyle := 3, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Light Gray"  ACTION ( oBrw:nColDividerStyle := 4, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Inset"       ACTION ( oBrw:nColDividerStyle := 5, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Raised"      ACTION ( oBrw:nColDividerStyle := 6, oBrw:Refresh(), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "ColDividerComplete" CHECKED ACTION ( ;
            oBrw:lColDividerComplete   := ! oBrw:lColDividerComplete,   ;
            oMenuItem:SetCheck( oBrw:lColDividerComplete ),             ;
            oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU

      MENUITEM "BackGround"
      MENU
         MENUITEM "None"     ACTION ( oBrw:SetBackGround(), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "Paper"    ACTION ( oBrw:SetBackGround( "PAPER" ), oBrw:SetFocus() )
         MENUITEM "Stone"    ACTION ( oBrw:SetBackGround( "STONE" ), oBrw:SetFocus() )
         MENUITEM "FiveBack" ACTION ( oBrw:SetBackGround( "FIVEBACK" ), oBrw:SetFocus() )
         SEPARATOR
         MENUITEM "Select Image" ACTION SetBmpBack( oBrw )
         MENUITEM "ImageMode"
         MENU
            MENUITEM "Tiled"    WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_TILED ) )
            MENUITEM "Stretch"  WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_STRETCH ) )
            MENUITEM "Fill"     WHEN ! Empty( oBrw:oBrush:hBitmap ) ;
                                ACTION ( oBrw:SetBackGround( , BCK_FILL ) )
         ENDMENU
      ENDMENU

      MENUITEM "Font"        ACTION ( oBrw:SelFont(), oBrw:SetFocus() )
      MENUITEM "Stretch"
      MENU
         MENUITEM "None"     ACTION ( oBrw:nStretchCol := STRETCHCOL_NONE, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Last"     ACTION ( oBrw:nStretchCol := STRETCHCOL_LAST, oBrw:Refresh(), oBrw:SetFocus() )
         MENUITEM "Widest"   ACTION ( oBrw:nStretchCol := STRETCHCOL_WIDEST, oBrw:Refresh(), oBrw:SetFocus() )
      ENDMENU
      MENUITEM "NoFreeze"    WHEN ( oBrw:nFreeze > 0 ) ;
                             ACTION ( oBrw:nFreeze := 0, oBrw:Refresh(), oBrw:SetFocus() )

   ENDMENU

return oPop
//----------------------------------------------------------------------------//

static function SetBmpBack( oBrw )

   local cImage

   if ! Empty( cImage := cGetFile( "Image File (*.bmp,jpg,png)|*.bmp;*.png;*.jpg|", ;
                                 "Select Image file ", 1, ;
                                 "\fwh\bitmaps" ) )
      oBrw:SetBackGround( cImage )
   endif
   oBrw:SetFocus()

return nil

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

static function ViewCode( oBrw )

   local aCode    := Array( 4 )
   local aGet     := Array( 4 )
   local oDlg, oFolder
   local oFont

#define DLGWD  350 //250
#define DLGHT  250

   aCode := oBrw:PrgCode()

   DEFINE FONT oFont NAME 'LUCIDA CONSOLE' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE DLGWD*2, DLGHT*2 PIXEL ;
      TITLE oBrw:oWnd:cTitle + " ( Source)" ;
      FONT WndMain():oFont

   @ 05,05 FOLDER oFolder ;
      PROMPTS 'ListBox Style', 'CommandStyle', 'Oops Style', 'Report Code' ;
      SIZE DLGWD - 10, DLGHT - 27 PIXEL ;
      OF oDlg ; // ADJUST
      FONT WndMain():oFont

   @ 10,10 GET aGet[ 1 ] VAR aCode[ 1 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 1 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 2 ] VAR aCode[ 2 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 2 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 3 ] VAR aCode[ 3 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 3 ] ;
      FONT oFont

   @ 10,10 GET aGet[ 4 ] VAR aCode[ 4 ] TEXT ;
      SIZE DLGWD-30,DLGHT-57 PIXEL ;
      OF oFolder:aDialogs[ 4 ] ;
      FONT oFont


   @ DLGHT-20,05 BUTTONBMP BITMAP 'COPY3' SIZE 16,16 PIXEL OF oDlg ;
      ACTION CopyToClip( aCode[ oFolder:nOption ] )
   @ DLGHT-20,23 BUTTONBMP BITMAP 'SAVE2' SIZE 16,16 PIXEL OF oDlg ;
      ACTION SaveCode( aCode[ oFolder:nOption ] )
   @ DLGHT-20,41 BUTTONBMP BITMAP 'RUN'   SIZE 16,16 PIXEL OF oDlg ;
      ACTION CompileAndRun( aCode[ oFolder:nOption ] )

   @ DLGHT-20,DLGWD-21 BUTTONBMP BITMAP 'CLOSE2' ;
      SIZE 16,16 PIXEL OF oDlg ;
      ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//
static function CopyToClip( cText )

   local oClip

   oClip := TClipBoard():New()
   if oClip:Open()
      oClip:SetText( cText )
      oClip:Close()
   endif
   oClip:End()

return nil
//----------------------------------------------------------------------------//

static function SaveCode( cText )

   local cFile

   if ! Empty( cFile := cGetFile(   "Prg File (*.PRG)|*.PRG|",          ;
                                    "Select PRG File to Save",       ;
                                    CurDir(), .t. ) )


      if ! MemoWrit( cFile, cText )
         MsgInfo( 'Write Failure' )
      endif

   endif

return nil
//----------------------------------------------------------------------------//

static function CompileAndRun( cText )

#ifdef __XHARBOUR__
   MemoWrit( 'test_x.prg', cText )
   WinExec( 'buildx.bat test_x' )
#else
   MemoWrit( 'test_x.prg', cText )
   WinExec( 'buildh.bat test_x' )
#endif

return nil

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


function dbfbuild()

   local oDlg, oGet, oGet1, oType, oLen, oDec, oLbx, oBtnAdd, oBtnEdit
   local cName    := Space( 9 ) // Limit to 9 instead of 10 for TDatabase
   local cType    := "C"
   local nLen     := 10
   local nDec     :=  0
   local cField   := Space( 20 )
   local cTypes   := "CNLDM"
   local aLens    := { 10, 10, 1, 8, 8 }
   local cDbfName := Space( 12 )
   local lEditing := .f.

   cDbfName:= padr("TEST",12)

   DEFINE DIALOG oDlg RESOURCE "DbfBuild" TITLE "FiveWin - DbfBuilder"

   REDEFINE GET oGet VAR cName ID 110 OF oDlg picture "@!XXXXXXXXX"

   REDEFINE COMBOBOX oType VAR cType  ITEMS { "C", "N", "L", "D", "M" } ;
      ON CHANGE ( nLen := aLens[ At( cType, cTypes ) ], oLen:Refresh() );
      ID 120 OF oDlg

   REDEFINE GET oLen VAR nLen PICTURE "9999" ID 130 OF oDlg

   REDEFINE GET oDec VAR nDec PICTURE "9"    ID 140 OF oDlg

   REDEFINE BUTTON oBtnAdd ID 150 OF oDlg ;
      ACTION (AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
                       @cName, cType, nLen, nDec, @lEditing ), oBtnAdd:oJump:= oGet, oDlg:refresh() )

   REDEFINE BUTTON ID 160 OF oDlg ACTION oDlg:End()

   REDEFINE LISTBOX oLbx VAR cField ID 170 OF oDlg

   oLbx:blDblClick:={|| EditField( oBtnAdd, oBtnEdit,;
                        cField, @cName, @cType, @nLen, @nDec, @lEditing,;
                        oGet, oType, oLen, oDec )}

   REDEFINE BUTTON oBtnEdit ID 180 OF oDlg ;
      ACTION EditField( oBtnAdd, oBtnEdit,;
                        cField, @cName, @cType, @nLen, @nDec, @lEditing,;
                        oGet, oType, oLen, oDec )

   REDEFINE BUTTON ID 190 OF oDlg ACTION oLbx:Del()

   REDEFINE BUTTON ID 112 OF oDlg ACTION oLbx:swapUp()

   REDEFINE BUTTON ID 113 OF oDlg action oLbx:swapDown()

   REDEFINE BUTTON ID 111 OF oDlg ;
      ACTION (cDbfName:=padr(cFileNoPath(OPEN(oLbx, cName)),12), oGet1:refresh() )

   REDEFINE GET oGet1 var cDbfName ID 210 OF oDlg

   REDEFINE BUTTON ID 220 OF oDlg ;
      ACTION BuildDbf( trim(cDbfName), oLbx )

   ACTIVATE DIALOG oDlg CENTERED ;
      //on init  import( cDbfName, oLbx )


return nil

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

static function AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
                          cName, cType, nLen, nDec, lEditing )

   if Empty( cName )
      MsgInfo( "I need a field name", "Sorry" )
   else
      if ! lEditing
         oLbx:Add( xPadR( cName, 100 )  + cType + ;
                   xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
                   oLbx:GetPos() )
            else
         oLbx:Modify( xPadR( cName, 100 ) + cType + ;
                      xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ) )
         oBtnAdd:SetText( "&Add" )
         oBtnEdit:Enable()
         lEditing = .f.
      endif
      cName = Space( 10 )
      oGet:Refresh()
      oGet:SetFocus( .t. )
   endif

return nil

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

static function BuildDbf( cDbfName, oLbx )

   local aFields := {}
   local n
   local cTempFile:=""

   if Empty( cDbfName )
      MsgAlert( "I need a DBF name", "Sorry" )
      return nil
   endif

   if Len( oLbx:aItems ) == 0
      MsgAlert( "No fields defined", "Sorry" )
      return nil
   endif

   if At( ".", cDbfName ) == 0
      cDbfName += ".dbf"
   endif

   for n = 1 to Len( oLbx:aItems )
      AAdd( aFields, _FieldInfo( AllTrim( oLbx:aItems[ n ] ) ) )
   next

   if File( cDbfName )
      if MsgYesNo( "DBF already exists, update structure?", "Info" )
         cTempFile:= tempFile("dbf")
         DbCreate( cTempFile, aFields )
         use (cTempFile)
         append from (cDbfName)
         use
         ferase( cDbfName )
         rename ( cTempFile ) to (cDbfName)

         // Handle memo field(s)
         // There is a problem when this file already exists--it doesn't get renamed for some reason.
         if file( cFileNoExt( cTempFile ) +".dbt" )
         //msgInfo( "memo file found")
         //cOld := cFileNoExt(cTempFile)+".dbt"
         //cNew := cFileNoExt( cDbfName )+".dbt"
         //msgInfo( cOld, "cOld")
         //msgInfo( cNew, "cNew")
            rename ( cFileNoExt(cTempFile)+".dbt") to ( cFileNoExt( cDbfName )+".dbt")
            //rename (cOld) to (cNew)
         endif

         return nil
      endif
   endif

   DbCreate( cDbfName, aFields )
   MsgInfo( "DBF created!", "AllRight" )

return nil

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

// Fixed function in dbfbuild.prg
static function _FieldInfo( cItem )

return { AllTrim( StrToken( cItem, 1 ) ),;
         AllTrim( StrToken( cItem, 2 ) ),;
         Val( StrToken( cItem, 3 ) ),;
         Val( StrToken( cItem, 4 ) ) }

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

static function EditField( oBtnAdd, oBtnEdit, cField,;
                           cName, cType, nLen, nDec, lEditing,;
                           oName, oType, oLen, oDec )

   if ! Empty( cField )
      oBtnAdd:SetText( "&Replace" )
      oBtnEdit:Disable()
      lEditing = .t.

      cName = padr(StrToken( cField, 1 ),9)

      cType = StrToken( cField, 2 )
      nLen  = Val( StrToken( cField, 3 ) )
      nDec  = Val( StrToken( cField, 4 ) )

      oName:Refresh()
      oType:Refresh()
      oLen:Refresh()
      oDec:Refresh()
   else
      MsgInfo( "Select a field to edit", "Please" )
   endif

return nil

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

static function import( cFile, oLbx )

   local aStruct,i:=0
   local cName,cType,nLen,nDec
   cFile:= trim(cFile)
   use (cFile)
   aStruct := dbstruct()

   for i:=1 to len( aStruct )

      cName := aStruct[i,1]
      cType := aStruct[i,2]
      nLen  := aStruct[i,3]
      nDec  := aStruct[i,4]

      oLbx:Add( xPadR( cName, 100 ) + cType + ;
              xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
              oLbx:GetPos() )

    next

    use

return cName

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

STATIC FUNCTION OPEN(oLbx)
   local cFile
   local cFileMask := "Database (DBF) | *.dbf |"
   local cInitialDirectory
   local lSave:= .f.
   local lLongNames:= .t.


   cFile:= cGetFile32( cFileMask, , , cInitialDirectory, lSave, lLongNames )

   if ! empty(cFile)
       import( cFile, oLbx )
   endif

return cFile

// Returns an unused filename with cExtension.
// cPath is optional. Defaults to current directory.
FUNCTION tempFile(cExtension,cPath)
   local cFile
   default cPath:=""
   cExtension:= strtran(cExtension,".","")
   // loop until you find a name that doesn't exist
   do while .t.
      cFile:="AAA"+trim(str(seconds(),5,0))+"."+upper(cExtension)
      cFile:=strtran(cFile," ","0") // fix for hours between 00:00 & 01:00
      cFile:= cPath + cFile
      if .not. file( cFile )
         exit
      endif
   enddo
return cPath + cFile

CLASS TDbfWnd

   DATA  oBrowse, oWnd
   DATA  cAlias
   DATA  lExclusive INIT .F.
   
   METHOD New( oWndChild, oBrw )
   METHOD DelRec()
   METHOD EditRec()
   METHOD AppRec()
   METHOD Refresh() INLINE ::oBrowse:Refresh()

ENDCLASS

METHOD New( oWndChild, oBrw ) CLASS TDbfWnd

   ::oWnd    = oWndChild
   ::oBrowse = oBrw
   ::oWnd:Cargo = Self
   ::oWnd:bGotFocus = { || oDbfWnd := ::oWnd:Cargo }
   ::cAlias = Alias()
   
   oDbfWnd = Self

return Self

METHOD DelRec() CLASS TDbfWnd

     /*
     IF ! ::oItemDelReg:lActive

          ::oBrowse:Setfocus()

          RETU NIL

     ENDIF
     */


     Select(::cAlias)

     IF ! ::lExclusive

          IF !(::cAlias)->(DbRLock())

               MsgRun({|| SysWait(1) }, "Record lock error")

               RETU NIL

          ENDIF

     ENDIF

     IF Deleted()
          DbRecall()
     ELSE
          DbDelete()
     ENDIF

     IF ! ::lExclusive
        ( ::cAlias )->( DbUnlock() )
     ENDIF

     IF Set( _SET_DELETED )
          DO WHILE Deleted() .AND. !Bof()
               DbSkip( -1 )
          ENDDO
          ::Refresh()
     ENDIF

     // SayInfo(Self)

     ::oBrowse:Setfocus()
     
return nil    
//----------------------------------------------------------------------------//

METHOD EditRec()  CLASS TDbfWnd

  MsgInfo( " EditRec ")
RETURN NIL

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

METHOD AppRec() CLASS TDbfWnd

   //  LOCAL cIndex := ::cIndex

     Select(::cAlias)

     APPEND BLANK

     IF NetErr()
          MsgRun({|| SysWait(1) },;
                 "Record append error")
          RETU NIL
    ENDIF

   //  ::cIndex := "<None> "
   //  ::ChangeOrder()
     ::oBrowse:GoBottom()
   //  ::EditFld()

RETURN NIL
//----------------------------------------------------------------------------//
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: WDBU clone - xbrDBU

Postby Demont Brecht » Wed Aug 31, 2011 10:25 am

Otto,

I downloaded wbrDBU and noticed that there is not yet a inputroutine for a dbf.

Last month i worked on a routine that maybe can be helpfull . It doen't use the build in edit features from xbrowse , but uses normal control's (defined in the dialiog) to edit the fields . Each control is possible as Dtpicker , checkbox , button , ......

The source has less as 500 lines in the code , i try it to send to you on a adress from some years ago , i hope it arrives

Frank Demont
Demont Brecht
 
Posts: 55
Joined: Fri Jul 08, 2011 6:43 am

Re: WDBU clone - xbrDBU

Postby Antonio Linares » Wed Aug 31, 2011 10:42 am

Frank,

Could you post a screenshot to see how it looks ? thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WDBU clone - xbrDBU

Postby Demont Brecht » Wed Aug 31, 2011 11:01 am

Sorry , i don't know how to give a screenshot.
Sending the source to otto has failed , here is the code

Antonio Linares wrote:Frank,

Could you post a screenshot to see how it looks ? thanks! :-)


Code: Select all  Expand view

# include "fivewin.ch"
# include "xbrowse.ch"
# include "Common.ch"
# include "dtpicker.ch"
# define CLR_1 nRGB( 190, 215, 190 )
# define CLR_2 nRGB( 230, 230, 230 )
# xTranslate EditObject(<Obj>)    => ( IsObject(<Obj>)  .AND. IIF(IsBlock(<Obj>:bWhen),EVAL(<Obj>:bWhen),.T.))
//# define TODEMO   // Demo.dbf is supposed to be used , no start parameter can be used

FUNCTION MAIN(cDbfFile)
***********************
LOCAL aStruct
LOCAL i , j
LOCAL aCountry
LOCAL oWnd , oBmp
LOCAL cText := ""
SET DATE FRENCH
SET CENTURY ON
SET DELETED ON
# ifdef TODEMO
  IF ! IsNil(cDbfFile)
    ? "To use a dbf-file the program must be compiled without '# define TODEMO'"
  END
  cDbfFile := nil
# endif
IF IsNil(cDbfFile)
  cDbfFile := "Demo.Dbf"
END
IF ! "." IN cDbfFile
  cDbfFile += ".dbf"
END
IF ! File(cDbfFile)
  aStruct := {{"Name","C",25,0},{"Number","N",10,2},{"Country","C",3,0},{"Maried","L",1,0},{"Date","D",8,0},{"Name1","C",25,0},{"Name2","C",25,0},{"Name3","C",25,0}}
  DbCreate(cDbfFile,aStruct)
  USE (cDbfFile)
  j := 1
  aCountry := {"BE ","FR ","NL "}
  FOR i := 1 TO 20
    APPEND BLANK
    REPL FIELD->Name WITH PAD("Name " + LTRIM(STR(i)),25)
    REPL FIELD->Number WITH i*1000
    REPL FIELD->Country WITH aCountry[j++]
    REPL FIELD->Maried  WITH ( i%2 == 0 )
    REPL FIELD->Date    WITH Date() + i
    REPL FIELD->Name1 WITH PAD("Name 1 " + LTRIM(STR(i)),25)
    REPL FIELD->Name2 WITH PAD("Name 2 " + LTRIM(STR(i)),25)
    REPL FIELD->Name3 WITH PAD("Name 3 " + LTRIM(STR(i)),25)
    IF j > 3
      j := 1
    END
  NEXT
  USE
END
USE (cDbfFile) SHARED
# ifdef TODEMO
i := ASCAN(DbStruct(),{|a|UPPER(a[1]) = "COUNTRY" .AND. a[2]="C" .AND. a[3]=3})
IF i = 0
  ? "Demo.dbf has wrong structure. When erased the program will create demo.dbf "
  RETURN nil
END
# endif
EditDbf()
RETURN  nil
*******************************************************************
PROC EditDbf()
**************
LOCAL Arr[0]
LOCAL oDlg , oBrw , oButExit
LOCAL i
LOCAL oGroup
LOCAL oRadMenu , nRad := 2
LOCAL nWd := 600 , nHt := 600
LOCAL cAlias := Alias()
LOCAL aStruct
LOCAL oCol
LOCAL lOk := .F. , lNieuw := .F.
# ifdef TODEMO
LOCAL hCountry := Hash() , cCountry
# endif
GO TOP
aStruct := (cAlias)->(DbStruct())
# ifdef TODEMO
// Field Country must be combobox , we add a array element in aStruct[3] and change second item
aStruct[3,2] := "B" // ComboBox
AADD(aStruct[3],{"BE ","FR ","NL "})
# endif
TXBrows( {|| MyBrowse() } )                                              // oDlg:aControls[1] !!!!!!!!
//DEFINE DIALOG oDlg SIZE 800,400 //FONT WndMain():oFont
DEFINE DIALOG oDlg From 0,0 TO nWd,nHt+100 PIXEL
nWd  /= 2
nHt  /= 2
oBrw := TXBrows():New( oDlg )
oBrw:lHScroll := .T.
oBrw:CreateFromCode(  )
WITH OBJECT oBrw
  :nTop                := 10
  :nLeft               := 10
  :nBottom             := :nTop + nHt - 30
  :nRight              := :nLeft + nWd - 30               //270
  :nMarqueeStyle       := MARQSTYLE_HIGHLCELL
  :lHScroll            := .T.
  :nColDividerStyle    := LINESTYLE_BLACK
  :nRowDividerStyle    := LINESTYLE_BLACK
  :bClrStd := {|| {CLR_BLACK, iif( (cAlias)->(Recno()) % 2 = 0, CLR_1, CLR_2  ) } }
  :bClrSelFocus := {||{CLR_WHITE, CLR_GREEN}}
  :nRowHeight := 25
  :lFastEdit := .T.
  (cAlias)->(:SetRdd())
  FOR i := 1 TO FCOUNT()
    IF IsLogical(Fieldget(i))
      :aCols[ i ]:nWidth = 20
      MakeBitmapCol(oBrw,i)
    END
  NEXT
END
// Trigger inputfield
@ 10 , oBrw:nRight + 2 CHECKBOX oCheckOk VAR lOk PROMPT "OK" OF oDlg PIXEL SIZE 25 ,10
                        oCheckOk:bGotFocus := {||SaveoBrwDlg(oBrw,@lNieuw)}
@ 90 , oBrw:nRight + 15 GROUP oGroup TO 150 , oBrw:nRight + 65 LABEL "Browse direction" OF oDlg PIXEL
@ 100 ,oBrw:nRight + 20 RADIO oRadMenu VAR nRad ITEMS "UP","RIGHT","DOWN","LEFT" SIZE 30 , 10 OF oDlg ;
                        WHEN oBrw:lActive VALID (oBrw:nDirection := nRad , .T.) PIXEL
BuildColObjects(oBrw , aStruct )
# ifdef TODEMO
  oBrw:oCol("NUMBER"):oEditGet:bValid := {|self|::Varget() > 1000}
  oBrw:oCol("NAME2"):oEditGet:bWhen := {||.F.}
  hCountry["BE "] := "Belgium"
  hCountry["FR "] := "France "
  hCountry["NL "] := "Holland"
  ADD COLUMN oCol TO oBrw AT 4 DATA {||IIF((cAlias)->(Fieldget(3)) IN hCountry , hCountry[(cAlias)->(Fieldget(3))] , Space(7))} HEADER "Country Name" WIDTH 60
# endif
OBrw:bPastEof() := {|| IIF( NewoBrwDlg(oBrw , @lNieuw ) , (lNieuw := .T. , ActivateoBrwDlg( , , , oBrw:aCols[1] )) , ) }
oBrw:bkeyDown := { | nkey |IIF(nkey==13 , ActivateoBrwDlg( , , , oBrw:SelectedCol() , nKey ) , ;
                           IIF(nKey==VK_DELETE , WisoBrwDlg(oBrw ) , ) ) }
@ nHt - 15 ,250 BUTTON oButExit PROMPT "EXIT" OF oDlg ACTION oDlg:End() PIXEL
 ACTIVATE DIALOG oDlg ;
  ON INIT ( Activate_Dlg(oBrw , oCheckOk , oButExit));
  VALID  IIF(GETKEYSTATE(VK_ESCAPE) , ( IIF(lNieuw , WisoBrwDlg(oBrw , @lNieuw ), ) , Activate_Dlg(oBrw) , .F.) , .T. )
RETURN
*******************************************************************
PROC   BuildColObjects(oBrw , aStruct)
*****************************************
LOCAL oDlg := oBrw:oWnd
LOCAL aFld
LOCAL i , j
LOCAL Inp[FCOUNT()]
LOCAL nFactor := 9
FOR EACH aFld IN aStruct
  i := Hb_EnumIndex()
  Inp[i] := FieldGet(i)
  WITH OBJECT oBrw:aCols[i]
  DO CASE
      CASE aFld[2] == "B"
      :oEditGet := SetCombo(:oEditGet,Inp[i],"@K " + REPL("X",aFld[3]),oDlg,aFld[6])
      :nEditType := 1            // Fastedit !!!
      :nWidth := aFld[3]*nFactor + 20
    CASE aFld[2] $ "CM"
      :oEditGet := SetGet(:oEditGet,Inp[i],"@K " + REPL("X",aFld[3]),oDlg)
      :nEditType := 1         // Fastedit works only when set!!!
      :nWidth := aFld[3]*nFactor
    CASE aFld[2] == "L"
      :oEditGet := SetCheck(:oEditGet,Inp[i],oDlg)
      :nWidth = 40
    CASE aFld[2] == "D"
      :oEditGet := SetDtePick(:oEditGet,Inp[i],oDlg)
      :nEditType := 1            // Fastedit !!!
      :nWidth = 85
    CASE aFld[2] == "N"
      :oEditGet := SetGet(:oEditGet,Inp[i],"@K " + NumPict( aFld[3] , aFld[4] , .F. , .F.),oDlg)
      :nEditType := 1         // Fastedit works only when set!!!
      :nWidth := aFld[3]*nFactor
  ENDCASE
  :nWidth := MIN(MAX(:nWidth,LEN(aFld[1])*nFactor),2*oBrw:BrwWidth - 30)
  END
  SetPostEdit(oBrw:aCols[i],i)
NEXT
oBrw:aCols[1]:oEditGet:lClrFocus := .T.
RETURN
******************************
Func SetCombo(Obj,Inp,cPict,oDlg,aValues)
  @ 0,0 COMBOBOX Obj VAR Inp PICTURE cPict ITEMS aValues OF oDlg PIXEL
RETURN Obj
Func SetGet(obj,Inp,cPict,oDlg)
  @ 0,0 GET obj VAR Inp OF oDlg PICTURE cPict PIXEL
RETURN Obj
Func SetCheck(obj,Inp,oDlg)
  @ 0,0 CHECKBOX obj VAR Inp PROMPT "  " OF oDlg PIXEL
RETURN Obj
Func SetDtePick(Obj,Inp,oDlg)
  @ 0,0 DTPICKER Obj VAR Inp OF oDlg PIXEL //VALID TestOk(oGet,oBrw)
RETURN Obj
*******************************************************************
PROC SetPostEdit(Self,j)    // j : Field Index
LOCAL x
::bOnPostEdit  := {|o , lTest| IIF(! IsNil(lTest) .AND. lTest , (x := o:oEditGet:Varget() , IIF(IsNil(j),,FieldPut(j,x))) , ) }
RETURN
*******************************************************************
STATIC PROC MakeBitmapCol(oBrw,i)
LOCAL oCol
LOCAL x , y
oCol := oBrw:aCols[i]
oCol:AddBmpFile( "BITMAP\Checkon.bmp" )
oCol:AddBmpFile( "BITMAP\Checkoff.bmp" )
x := LEN(oCol:aBitMaps)
oCol:bBmpData   := {||y := EVAL(oCol:bEditValue) , IIF(IsLogical(y) , IIF(y,x-1,x),0)}
oCol:bStrData   := {||" "}
RETURN
*******************************************************************
FUNC NewoBrwDlg(oBrw , lNieuw )
LOCAL Arr := {}
LOCAL x
LOCAL i
IF lNieuw
  RETURN .F.
END
IF ! DbAppend(.F.)
  RETURN .F.
END
FOR i := 1 TO FCOUNT()
  x := Fieldget(i)
  IF ValType(x) = "D"
    x := Date()
    FieldPut( i , x)
  END
NEXT
oBrw:GoBottom()
oBrw:Refresh()
RETURN .T.
*******************************************************************
PROC WisoBrwDlg(oBrw,lNieuw)
IF RLOCK()
  DbDelete()
  DbUnlock()
  DbSkip(-1)
  oBrw:Refresh()
  lNieuw := .F.
END
RETURN
**********************************************************
PROC SaveoBrwDlg(oBrw , lNieuw )
LOCAL Self := oBrw
LOCAL oCol , i
LOCAL lOk := .F.
LOCAL oLastcol
IF ! rLock()
  RETURN
END
oCol := ::SelectedCol()
WITH OBJECT ::SelectedCol()
  IF IsObject(:oEditGet) .AND. IsBlock(:bOnPostEdit)
    EVAL(:bOnPostEdit,oCol,.T.) // Only with second parameter it will be executed
  END
END
oBrw:DrawLine(.t.)
DbCommit()
lNieuw := .F.
DBUNLOCK()
Activate_Dlg(oBrw)
GoNextCell(oBrw)
ActivateoBrwDlg( ,  ,  , oBrw:SelectedCol(), ,.T.)
RETURN
*******************************************************************
PROC GoLeftMost(oBrw)
LOCAl Self := oBrw
LOCAL oLastcol    := ::aCols[ ATail( ::aDisplay ) ]
::GoLeftMost()
DO WHIL .T.
  IF EditObject(::ColAtPos( ::nColsel ):oEditGet)
    SysRefresh()
    RETURN
  END
  ::GoRight()
  if ::SelectedCol():nCreationOrder == oLastCol:nCreationOrder
    EXIT
  END
END
SysRefresh()
RETURN
*******************************************************************
PROC GoNextCell(oBrw,nDirection)
LOCAL oCol , j , i
LOCAL nFirst := 0 , nLeft := 0 , nRight := 0 , nLast := 0
LOCAL Self := oBrw
LOCAL oLastcol    := ::aCols[ ATail( ::aDisplay ) ]
DEFAULT nDirection := ::nDirection
IF nDirection == 2
  Do WHIL .T.
    if ::SelectedCol():nCreationOrder == oLastCol:nCreationOrder
      ::GoDown()  // Prevent bPastEof() : LOCAL bPostEOf := ::bPastEof() ; .... ; ::bPastEof() := nil ; ::GoDown() ; ::bPastEof := bPastEof
      GoLeftMost(oBrw)
      EXIT
    endif
    ::GoRight(,.T.)
    IF EditObject(::ColAtPos( ::nColsel ):oEditGet)
      EXIT
    END
  END
  Sysrefresh()
  RETURN
END
IF nDirection == 4
  Do WHIL .T.
    oCol := ::SelectedCol()
    oBrw:GoLeft()
    IF oCol == ::SelectedCol()
      IF ! ::Bof()
        ::GoUp()
      END
      ::GoRightMost()
    END
    IF EditObject(::ColAtPos( ::nColsel ):oEditGet)
      EXIT
    END
  END
  Sysrefresh()
  RETURN
END
IF nDirection == 3    // DOWN
  IF ! ::Eof()
    oBrw:GoDown()
  END
END
IF nDirection == 1    // UP
  IF ! ::Bof()
    ::GoUp()
  END
END
Sysrefresh()
RETURN
*******************************************************************
PROC ActivateoBrwDlg(nRw , nCl , nKeyFlags , oColBrw , nKey , lTest)
LOCAL   nRow
LOCAL   nCol
lOCAL nWidth
LOCAL nHeight
LOCAL x
LOCAL i , Obj , Gehi
LOCAL aDisPlay
LOCAL Self := oColBrw , cKey //Key
LOCAL bValid
LOCAL aControls , oCol , oBrw , oDlg
LOCAL Nr , nKol
oBrw := ::oBrw
oDlg := oBrw:oWnd
IF isnumber(nKey)
   cKey := Chr( nKey )
END
IF ! EditObject(oColBrw:oEditget)
  GoNextCell(oBrw,4)  // To Left
  oColBrw := oBrw:SelectedCol()
  nKey := cKey := nil
END
IF ! oBrw:IsDisplayPosVisible( oColBrw:nPos, .T. )
  oCol := oColBrw
  DO WHILE ! oBrw:IsDisplayPosVisible( oColBrw:nPos, .T. )
    oBrw:GoRight()
    SysRefresh()
    IF oCol == oBrw:SelectedCol()
      EXIT
    END
    oCol := oBrw:SelectedCol()
  END
  oBrw:SelectCol(oColBrw:nPos)
END
nKol := oBrw:nColSel
IF ! RLOCK()
  RETURN
END
FOR EACH Obj IN oDlg:aControls
  Obj:Disable()
NEXT
nRow    := ( ( oBrw:nRowSel - 1 ) * oBrw:nRowHeight ) + oBrw:HeaderHeight() + 2 + oBrw:nTop
nHeight := oBrw:nRowHeight - 4
WITH OBJECT oColBrw
  nCol    := :nDisPlayCol + 2 + oBrw:nLeft
  nWidth  := :nWidth - 4
  x := EVAL(:bEditValue)
  IF __ObjHasMethod(:oEditGet,"VARPUT")  // BUTTON ???
    :oEditGet:Varput(x)
    :oEditGet:Refresh()
  END
  :oEditGet:Enable()
  :oEditGet:Move(nRow, nCol, nWidth, nHeight, .t. )
  :oEditGet:Show( )
  IF IsNil(:bOnPostEdit)
    SetPostEdit(oColBrw,i)
  END
END
WITH OBJECT oBrw:oCheckOk
  nCol := oBrw:nWidth + oBrw:nLeft + 2
  :Move(nRow , nCol , nWidth , nHeight , .t. )
  :Enable()
  :Show()
END
IF IsNumber(nKey)
  oCol := oColBrw
  If oBrw:lFastEdit .and. oBrw:nMarqueeStyle <= MARQSTYLE_HIGHLCELL .and. ;
    oCol:nEditType > 0 .and. ;
    ( oCol:IsEditKey( cKey ) .or. IsDigit( cKey ) .or. cKey == "-" )
    IF __ObjHasMethod(oCol:oEditGet,"VARPUT")  // BUTTON ???
        x := EVAL(oCol:bEditValue)//oBrw:aArrayData[Nr,oCol:nCreationOrder]
        IF IsCharacter(x)
          IF oCol:oEditGet:CLASSNAME = "TGET"
            oCol:oEditGet:bGotFocus := {|self|Self:cText( SPACE(LEN(Self:Varget())) ) , Self:Keychar(cKey) ,;
                                              Self:oGet:Pos := 2 , Self:EditUpdate() , self:Setpos(2),Self:bGotFocus:=nil}
          ELSEIF oCol:oEditGet:CLASSNAME = "TCOMBOBOX"
            oCol:oEditGet:bGotFocus := {|self|Self:lIncSearch := .T. ,Self:Keychar(cKey) , Self:bGotFocus:=nil}
          END
          x[1] := cKey
        ELSEIF IsNumber(x)
          IF (48<=nKey .AND. nKey <= 57) .or. cKey == "-"
            oCol:oEditGet:bGotFocus := {|self|Self:Keychar(cKey) , Self:oGet:Pos := 2 ,;
                                              Self:EditUpdate() , self:Setpos(2),Self:bGotFocus:=nil}
          END
        END
        oCol:oEditGet:Refresh()
    end
  END
END
IF EditObject(ocolBrw:oEditGet)
  oColBrw:oEditGet:Setfocus()
ELSE
  GoLeftMost(oBrw)
  IF EditObject(oBrw:SelectedCol():oEditGet)
    oBrw:SelectedCol():oEditGet:SetFocus()
  END
END
RETURN
*******************************************************************
PROC Activate_Dlg(oBrw,oCheckOk,oBut)
LOCAL oCol , i , Obj , oDlg
oDlg := oBrw:oWnd
IF PCOUNT() == 3
  oBrw:oCheckOk := oCheckOk
  oBrw:oButExit := oBut
ELSE
  oCheckOk := oBrw:oCheckOk
  oBut     := oBrw:oButExit
END
FOR EACH Obj IN oDlg:aControls
  IF IsNil(Obj:bWhen) .OR. EVAL(Obj:bWhen)
    Obj:Enable()
  END
NEXT
FOR EACH oCol IN oBrw:aCols
  IF IsObject(oCol:oEditGet)
    oCol:oEditGet:DisAble()
    oCol:oEditGet:Hide()
  END
NEXT
oCheckOk:Hide()
oCheckOk:DisAble()
DbUnlock()
oBrw:Refresh()
oBrw:setFocus()
RETURN
**************************************************
Class MyBrowse FROM TxBrowse
  CLASSDATA lRegistered AS LOGICAL // This is compulsory for derived classes
  DATA bColClass INIT { || MyXBrCol() }
  DATA lCell AS LOGICAL INIT .F.
  DATA nDirection AS NUMERIC INIT 2
  DATA oCheckOk
  DATA oButExit
  METHOD New( oWnd ) CONSTRUCTOR // optional
ENDCLASS
***************************************************
METHOD New( oWnd ) CLASS MyBrowse
Super:New( oWnd )
return Self
***************************************************
CLASS MyXbrCol FROM TXBrwColumn
METHOD Edit()
ENDCLASS
****************************************************
METHOD Edit(nKey) CLASS MyXBrCol
ActivateoBrwDlg( , , , Self , nKey)
return Self
*******************************************************************
function xSetFocus( oObx )
// function from local.fivewin.english 4/1/2003 Kleyber Derick
local oTempo:=""
local lGet := oObx:ClassName $ "TGET TMULTIGET"
define timer oTempo interval 10 of oObx:oWnd ;
  action (oObx:SetFocus(), IIF(lGet , oObx:SetPos(0) , ), oTempo:Deactivate() )
activate timer oTempo
return nil
 
Last edited by Demont Brecht on Wed Aug 31, 2011 11:26 am, edited 1 time in total.
Demont Brecht
 
Posts: 55
Joined: Fri Jul 08, 2011 6:43 am

Re: WDBU clone - xbrDBU

Postby Antonio Linares » Wed Aug 31, 2011 11:26 am

Frank,

Please email me the screenshot and I will post it, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Jimmy and 76 guests