Use DfAllEnt.pkg
//#Replace CURRENT$WORKSPACE   "CMOS"

// Project Object Structure
//   oApplication is a cApplication
//   oMain is a Panel
//     oClientArea is a AppClientArea
//     oHtmlHelp is a cHtmlHelpNew

// Register all objects
Register_Object oApplication
Register_Object oClientArea
Register_Object oHtmlHelp
Register_Object oMain
//AB-IgnoreEnd


//AB-StoreTopStart
// COPYRIGHT (c) 2003-2007 RDC Tools International
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; (See the GPL.txt file in the Help directory) if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Use RdsStartup.pkg
Compiler_Desktop_Method_Warnings On

//  Set date attributes as needed
Set_Date_Attribute SysDate4_State To True
Set_Date_Attribute Date4_State    To True
Set_Date_Attribute Epoch_Value    To 30

Set_Attribute DF_HIGH_DATA_INTEGRITY To True
Send Ignore_Error Of Error_Info_Object 4255 // "Can't load DLL"

Use Help_Ids.inc // Developer should provide this file of help context links.
//Use Std_Help.pkg
Use cHtmlHelpNew.pkg
Use vsYNCconfirm.pkg  // Better data_loss message. Yes/No/Cancel.
//Use cApplication.pkg
//Use dfPanel.pkg
//Use DfAClnt.pkg

Object oApplication is a cApplication

    Property Handle  phoSynchGrid 0 // Only set by the Engine program.
    Property Integer piUsers  1     // Will contain the decrypted max number of allowed concurrent users.
    Property String  psSerial ""    // Will contain the decrypted serial number from CrossMerge license file.
    Property String  psName   ""    // Decrypted license name.
    Property Integer piLicenseType 0
    Property String  psLicenseType "OPEN SOURCE VERSION"
    Property String  psActivationDaysText ""
    Property Integer piDaysLeft 0
    Property Integer piUserCode1 0
    Property Integer piUserCode2 0
    Property Boolean pbActivated False
    Property Integer piActivationDaysLeft 0
    Property Handle  phoLfile 0
    Property Handle  phoXmlHttpTransfer   0
    Property Handle  phoClient  0
    Property Handle  phoSDIView 0   // Set by SDI view object

    Set psCompany  to "RDC Tools International"
    Set psProduct  to "CrossMerge"
    Set psVersion  to "4.0"
    Set psProgram  to "Builder"
    Set psHelpFile to "CrossMerge.chm"
    Set peHelpType to htHtmlHelp
    Set pbPreserveEnvironment to FALSE

//    Procedure OnCreate
//        Send DoOpenWorkspace CURRENT$WORKSPACE
//    End_Procedure

End_Object    // oApplication

Object oMain is a Panel

    Use xxSoftwareKey.pkg     // Modified Software key plus software protection package.
    Use Cli.pkg               // DAW CLI commands/functions for Connectivity kit drivers.
    Use Working.pkg           // RDC "Working..." panel object
    Use SyncFuncs.pkg         // Misc. global functions and other stuff.
    Use ShellExecute.pkg      // Interface to Windows ShellExecute function for starting documents et.al via their file extention.
    Use Start_UIExcl.pkg      // Do only allow one instance of this program running.
    
    // Rebar and toolbar properties:
    Property Handle  phoFindToolBar        0
    Property Handle  phoSearchToolBar      0
    Property Handle  phoSaveToolBar        0
    Property Handle  phoCutToolBar         0
    Property Handle  phoWizardToolBar      0
    Property Handle  phoConnectToolBar     0
    Property Handle  phoPropertiesToolBar  0
    Property Handle  phoFirst              0
    Property Handle  phoNext               0
    Property Handle  phoLast               0
    Property Handle  phoFind               0
    Property Handle  phoPrevious           0
    Property Handle  phoPrompt             0
    Property Handle  phoClear              0
    Property Handle  phoSave               0
    Property Handle  phoDelete             0
    Property Handle  phoCut                0
    Property Handle  phoCopy               0
    Property Handle  phoPaste              0
    Property Integer piVerRebar            0
    Property Integer piVerToolbar          0
    Property Integer piViewSize            0
    Property Integer piVerStatBar          0

    Set Label to "CrossMerge Builder"
    Set Locate_Mode to Center_On_Screen
    Set Location to 4 3
    Set Size to 323 515
    Use RDCRebar.pkg  //  Tool-Bar object.
    
    Object oClientArea is a AppClientArea
        Use ViewData.DG
        Use Password.dg
        Use DeletePassword.DG
        Use RDCAboutNew.dg
        Use RDC.VW
        Use Append.DG
        Use PropertiesNew.DG

        Set phoClient Of ghoApplication To Self
        Set Client_ScrollBar_State      To False
        
    End_Object    // oClientArea

    Use SDIStatusbar.pkg  //  Status-Bar object.
    

    Procedure Activate_About
      Send Popup Of (oAboutDialog(oClientArea(Self)))
    End_Procedure // Activate_About
    
    // Function override.
    // This has been changed into getting data_loss confirmation of the
    // SDI view of this application. This is needed since the
    // Procedure Request_Cancel has been killed in the view to avoid
    // user closing the view, which makes no sense in a SDI application.
    Function Verify_Exit_Application Returns Integer
      Integer iRetval
      Get xExit_Loss_Confirmation Of (oRdcView(oClientArea(Self))) To iRetval
      Function_Return iRetval
    End_Function // Verify_Exit_Application
    
    Object oHtmlHelp Is A cHtmlHelpNew
      Set psHelpFile          To "CrossMerge.chm"
    End_Object // oHtmlHelp
    
    // View is not activated yet and value is needed by the resize package, so set it here.
    Set piViewSize            To (39256901)
    Use DoReGuiSize.pkg // This will properly size the application after the size of the view.
    
End_Object    // oMain


// We need this right after Main panel has been activated.
// For some reason it jumps a bit to the lower right, hence the adjustment.
Send DoReLocateSplashScreen Of (oSplashScreen(Self))
Send Activate_oRdcView      Of (oClientArea(oMain(Self)))
Send Destroy                Of (oSplashScreen(Self))  // Remove splash screen.

//If (phoLfile(ghoApplication) = 0) Begin
//  Send Info_Box "A reboot of the machine is necessary if this is the first time CrossMerge is started after installation. Else an important component of CrossMerge is missing and the program will be aborted and you will need to re-install CrossMerge."
//  Abort
//End // If (phoLfile(ghoApplication) = 0) Begin

Procedure DoInitLabel Global
  String  sText
  Set Label Of oMain To ;
    (psProduct(ghoApplication) * psProgram(ghoApplication))
//     * "-" * psLicenseType(ghoApplication) * ;
//    "*** Registered to" * psName(ghoApplication) * "***" * "Serial number" * String(psSerial(ghoApplication)))
End_Procedure // DoInitLabel
Send DoInitLabel

If (SncSys.UseLogin = 1) Send Popup Of (oPassword_dg(oClientArea(oMain(Self))))
//Send DoPopupNagScreen Of (oClientArea(oMain(Self))) True

// About dialog update procedure.
// Must be placed after activation of the main view because it is there
// the Protection Plus logic is activated and info from there is used
// in the about object:
Send DoUpdateAbout    Of (oClientArea(oMain(Self)))

// Only allow one instance of the program running on a machine. Auto-close the second instance.
Start_UI_Exclusive //(oRdcView(oClientArea(oMain(Self))))
