// Compile this program to get stand alone query tool for Visual DataFlex

#HEADER
Use APS          // Auto Positioning and Sizing classes for VDF

Use LangSymb.pkg // Language symbols
//define lng_default for lng_portuguese // <-- Change default language here
//define lng_default for lng_french // <-- Change default language here
define lng_default for lng_english // <-- Change default language here
//define lng_default for lng_dutch // <-- Change default language here

Use Splash.utl   // Graphic splish-splash
Use About.utl    // About dialog

set AppInfo AI_TITLE       to "DBQuery"
set AppInfo AI_SUBTITLE    to "for Windows"
set AppInfo AI_VERSION     to "2.1"
set AppInfo AI_REVISION    to ""
set AppInfo AI_AUTHOR      to "Sture ApS"
set AppInfo AI_WATERMARK   to ""
set AppInfo AI_RELEASEDATE to ""

object oSplash is a cGraphicSplash
end_object
send activate to (oSplash(self))

Use MdiExt.utl
Use OpenStat.nui // cTablesOpenStatus class (formely cFileAllFiles)

Use Version.nui

Use cApplication.pkg
Object oApplication is a cApplication
    Set pbEnterKeyAsTabKey to DFTRUE
    Set psAutoOpenWorkspace to ""
End_Object // oApplication
#ENDHEADER

// If you use WinPrint:
//Use VDFQuery.utl // DFQUERY for Visual DataFlex (WinPrint version)

// If you use VPE:
define VPE_USE_EMBEDDED_PREVIEW for 1
Use VpeQuery.utl // DFQUERY for Visual DataFlex (VPE version)

use OpenStat.pkg
Use Login.utl

Use SelectWorkspace.dg
Use WorkSpc.utl
register_object Main
register_object Client_Area
Procedure Do_Select_WorkSpace
  integer hoWorkspace eOpened
  string sWorkspace
  get phoWorkspace of ghoApplication To hoWorkspace
  get WorkSpc_SelectWS to sWorkspace
  If (sWorkspace<>"") Begin
    Send DoClearPaths of hoWorkspace
    Get OpenWorkspace of hoWorkspace sWorkspace To eOpened
    If (eOpened <> WSWORKSPACEOPENED) Begin
      send stop_box "The current default workspace is invalid."
    End
    broadcast recursive send Close_Query_View to desktop
    broadcast recursive send delete_fieldinfo_data to desktop // Clears some arrays in fieldinf.pkg
    send OpenStat_CloseAllFiles
    send Open_A_View_Please to (Client_Area(Main(Self)))
  End
end_procedure

Object Main is a Panel
  set label to "DBQuery" // "Rapportgenerator"
  DFCreate_Menu Main_Menu
    DFCreate_Menu "&File" FilePullDown is a ViewPopupMenu
      on_item "Sort"             send Activate_Sort_Vw
      on_item "New Query"        send Activate_Query_Vw
      on_item ""                 send none
      on_item "Select workspace" send Do_Select_WorkSpace
      on_item ""                 send none
      on_item "Login"            send DoLogin
      on_item "Display open"     send OpenStat.DisplayFileLocations
      on_item ""                 send none
      on_item "Exit \aAlt+F4"    send exit_application
    End_Menu
    #include Win_PM.inc     // Window of available views
  End_Menu

  Object Client_Area IS A AppClientArea
    procedure Open_A_View_Please
      send Activate_Query_Vw
    end_procedure
    procedure DoLogin
      get DBMS_GetDriverLogin 0 to windowindex
    end_procedure
    Use VdfQuery.rv // VDFQuery
    #IFDEF VPE_USE_EMBEDDED_PREVIEW
     move self to glMainClientId#
    #ENDIF
    // This is used here simply to make sure that the packages
    // will be in the upload. You may comment the next line to
    // save size on the compiled file.
    Use VdfSort.vw  // Reindexing routines
  End_Object  // Client_Area

  Object Status_Bar is a cSturesStatusBar
  End_Object
End_Object // Main
send deactivate to (oSplash(self))
send Open_A_View_Please to (Client_Area(Main(self)))

Start_UI

