Jump to content

need help with debugging


 Share

Recommended Posts

Hi folks

I have hit a wall in coding and simply have no idea what I am doing wrong.

Since we don't have vertical tabs in Autoit, i tried to simulate the looks and functionality using bigass buttons.

now the problem was that i needed to create a different child UI based off on the button clicked.

Basic idea behind the UI is;

First the $MainGUI gui is created.

the GUI has a few buttons.

If button 1 is clicked, control paases to a while do, select loop.

in the first case, it calls a function. This function disables the press button to make it look like a selected tab. The function also deletes all the child GUIs if they exist.

Once the function ends, the control is passed back to the case statement. now i recreate the GUI.

in theory this seems very easy. but i keep on getting error popup messages which don't really make sense to me. they are because of the GUIdelete statements i have in the function.

the function in question is called _ChangeModules and is at the end. the other points of interest in the code will be the first two case statements in the While do loop. in the code, currently the two guidelete statements are commented.

uncomment them to get the problem. also, once the statements are uncommented, my gui disappears on clicking the welcome button. >_<

the following code just creates a simple gui which doesn't do anything at this moment.

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.1.1 (beta)
    Author:         Rishav Sharan

    Script Function:
    GUI to create simple import test cases

#ce ----------------------------------------------------------------------------


#cs ----------------------------------------------------------------------------
    Includes
#ce ----------------------------------------------------------------------------

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <GuiDateTimePicker.au3>
#include <GuiTab.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiTab.au3>
#include <GuiComboBox.au3>
#include <GuiToolTip.au3>
;~ #include <GDIPlus.au3>

#cs ----------------------------------------------------------------------------
    Program Options
#ce ----------------------------------------------------------------------------
#NoTrayIcon

#cs ----------------------------------------------------------------------------
    Declarations
#ce ----------------------------------------------------------------------------
Opt("MustDeclareVars", 1)

; Global declare file attributes
Global $d, $szDrive, $szDir, $szFName, $szExt

; Global declare temporary variable
Global $AboutScreen_GUI = 0

; Declare GUIs
Global $MainGUI, $MainImportGUI, $ControlGUI, $MainWelcomeGUI

; Declare Module buttons
Global $Welcome_Module_button, $Setup_Module_button, $Smoke_Module_button, $Import_Module_button, $System_Module_button, $Summary_Module_button, $Options_Module_button

; Declare constants
Dim Const $x1 = 150, $y1 = 10, $x2 = 75, $y2 = 10, $x3 = 10, $y3 = 20

; Declare temporary variable
Dim $GenericTempValue = "temp value"

; Declare fields
Dim $TestType_field, $TCName_field, $TCPassNo_field, $CarrierName_field, $ImportFileLocation_field, $RefDefFileLocation_field, $AdditionalDetails_field, $Destnination_field
Dim $Rate_field, $DialCode_field, $EffDate_datefield, $ExpDate_datefield, $ServerDetails_field, $UidPass_field, $IncrDate_datefield, $DecrDate_datefield

; Declare labels
Dim $TCName_label, $TCPassNo_label, $TestType_label, $CarrierName_label, $AboutScreen_label, $RefDefFileLocation_label, $IncrDate_label, $DecrDate_label, $AdditionalDetails_label
Dim $Destnination_label, $DialCode_label, $ImportFileLocation_label, $Rate_label, $EffDate_label, $ExpDate_label, $ServerDetails_label, $UidPass_label

; Declare buttons
Dim $AddtoBatch_button, $RemFromGrid_button, $MoveUp_button, $MoveDown_button, $AddSeparator_button, $GridToFile_button, $RunBatch_button
Dim $Tab_TCSuite, $BatchList

; Declare grid columns
Dim $Grid_serial_col, $Grid_sequence_col, $Grid_Timestamp_col, $Grid_Status_col, $Grid_OverallResult_col, $Grid_TCName_col, $Grid_PassNo_col, $Grid_Carrier_col
Dim $Grid_TestType_col, $Grid_Details_col, $Grid_ServerDetails_col, $Grid_AutoExpire_col, $Grid_IncrDate_col, $Grid_DecrDate_col, $Grid_DestName_col, $Grid_DialCode_col
Dim $Grid_UidPass_col, $Grid_Rate_col, $Grid_EffectievDate_col, $Grid_ExpiryDate_col, $Grid_RSFile_col, $Grid_RefFile_col

; Declare data variables
Dim $TestType_data, $SectionNumber_data, $Timestamp_data, $TestCaseStatus_data, $OverallResult_data, $TCName_data, $TCPassNo_data, $CarrierName_data, $AdditionalDetails_data
Dim $ServerDetails_data, $IncrDate_data, $DecrDate_data, $Destnination_data, $DialCode_data, $UidPass_data, $Rate_data, $EffDate_data, $ImportFileLocation_data
Dim $RefDefFileLocation_data, $AutoExpire_data, $Grid_All_listdata, $EffDate_data, $ExpDate_data

; Declare handles
Dim $EffDate_handle, $ExpDate_handle, $IncrDate_handle, $DecrDate_handle, $BatchList_handle

; Display arrays
Dim $ProfilesIniFileList_array, $ImportIniFileList_array, $RefDefIniFileList_array

; Declare misc variables
Dim $IconsFolder, $ProfilesINI, $ProfilesINI_NewName, $ProfilesINI_OnlyFileName, $ImportCombo_Insert_Name, $Grid_listdata_sections, $SelectedRow, $Ini_Section_delete
Dim $Selected_section, $Above_section, $Below_section, $Tab_Insert_Name, $RefDefCombo_Insert_Name, $Tab_Name, $ClickedModule_button

; Declare indices
Dim $msg, $current, $iIndex, $temp, $tDate


#cs ----------------------------------------------------------------------------
    Main GUI
#ce ----------------------------------------------------------------------------


;~ GUI Backend data file. This is the temp ini file which saves all the data till a specific new file is created.
; This is to save the data in case of system failure.
; If we added the data directly to the grid, in case of accidental closure or power failure, the data will be lost.
$IconsFolder = @ScriptDir & "\System\Icons\"
HotKeySet("{F1}", "_AboutScreen")

; MAIN GUI
$MainGUI = GUICreate("Optima Rate Import Test Case Creator", 1250, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP))
GUISetIcon(@SystemDir & "\system\Donkey.ico", 0)
GUISetBkColor(0xFFFFFF)


; MODULE SELECTOR. LATER NEED TO MOVE IT TO A MASTER GUI
$Welcome_Module_button = GUICtrlCreateButton("Welcome Module", $x3, $y3, 130, 100, $WS_BORDER)
$Setup_Module_button = GUICtrlCreateButton("Setup Module", $x3, $y3 + 100, 130, 100, BitOR($BS_FLAT, $WS_BORDER))
$Smoke_Module_button = GUICtrlCreateButton("Smoke Module", $x3, $y3 + 200, 130, 100, BitOR($BS_ICON, $WS_BORDER))
$Import_Module_button = GUICtrlCreateButton("Import Module", $x3, $y3 + 300, 130, 100, BitOR($BS_ICON, $WS_BORDER))
;~ GUICtrlSetFont($Import_Module_button, 11, 800)
;~ GUICtrlSetBkColor($Import_Module_button, 0xFFFFFF)
$System_Module_button = GUICtrlCreateButton("System Module", $x3, $y3 + 400, 130, 100, BitOR($BS_ICON, $WS_BORDER))
$Summary_Module_button = GUICtrlCreateButton("Summary Module", $x3, $y3 + 500, 130, 100, BitOR($BS_ICON, $WS_BORDER))
$Options_Module_button = GUICtrlCreateButton("Options Module", $x3, $y3 + 600, 130, 100, BitOR($BS_ICON, $WS_BORDER))
GUISetState()

;~ -----------------------------------------------------------------------------------------------------------------

; Capture and execute all button clicks
While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $Welcome_Module_button
            _ChangeModules($Welcome_Module_button)


            ; WELCOME MODULE GUI
            $MainWelcomeGUI = GUICreate("Welcome Module", 1250, 900, 0, 0, $WS_CHILD, -1, $MainGUI)
            ;$WS_EX_LAYERED
            GUISetState()

        Case $Import_Module_button
            _ChangeModules($Import_Module_button)



            ; IMPORT MODULE GUI
            $MainImportGUI = GUICreate("Import Module", 1250, 900, 0, 0, $WS_CHILD, -1, $MainGUI)
            GUISwitch($MainImportGUI)

            ; DETAILS FIELDS
            $TCName_label = GUICtrlCreateLabel("Test Case Name", $x1 + 10, $y1 + 23, 90, 15)
            $TCName_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 23, 170, 20, $ES_UPPERCASE)
            $TCPassNo_label = GUICtrlCreateLabel("Pass Number", $x1 + 320, $y1 + 23, 90, 15)
            $TCPassNo_field = GUICtrlCreateInput("1", $x1 + 420, $y1 + 23, 170, 20, $ES_NUMBER)
            $TestType_label = GUICtrlCreateLabel("Test Type", $x1 + 630, $y1 + 23, 90, 15)
            $TestType_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 23, 170, 20, $CBS_DROPDOWNLIST)
            GUICtrlSetData($TestType_field, "Import Rates to Pending|Import Rates to Active|Edit Carrier Rates|Add Analysis Stage|Run SQL File|Run Win Batch File", "Import Rates to Pending")

            ; TC SUITE TABS
            $Tab_TCSuite = _GUICtrlTab_Create($MainImportGUI, $x1, $y1 + 242, 1090, 650)
            _RefreshTabBar()

            ; SET PROFILES INI BASED ON THE TAB SELECTED
            $current = _GUICtrlTab_GetCurSel($Tab_TCSuite)
            $Tab_Name = _GUICtrlTab_GetItemText($Tab_TCSuite, $current)
            $ProfilesINI = @ScriptDir & "\Profiles\" & $Tab_Name & ".ini"

            ; GROUP FOR BUTTONS
            GUICtrlCreateGroup("", $x1 + 925, $y1, 160, 230)

            ; BUTTONS
            $AddtoBatch_button = GUICtrlCreateButton("Add to Grid", $x1 + 940, $y1 + 10, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($AddtoBatch_button, $IconsFolder & "\Add_to_Grid.ico")
            GUICtrlSetTip($AddtoBatch_button, "Add to Grid", "", 1, 1)
            $RemFromGrid_button = GUICtrlCreateButton("Remove from Grid", $x1 + 1010, $y1 + 10, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($RemFromGrid_button, $IconsFolder & "\Remove_from_Grid.ico")
            GUICtrlSetTip($RemFromGrid_button, "Remove from Grid", "", 1, 1)
            $MoveUp_button = GUICtrlCreateButton("Move up Item", $x1 + 940, $y1 + 65, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($MoveUp_button, $IconsFolder & "\Move_Up.ico")
            GUICtrlSetTip($MoveUp_button, "Move up Item", "", 1, 1)
            $MoveDown_button = GUICtrlCreateButton("Move Down Item", $x1 + 1010, $y1 + 65, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($MoveDown_button, $IconsFolder & "\Move_Down.ico")
            GUICtrlSetTip($MoveDown_button, "Move Down Item", "", 1, 1)
            $AddSeparator_button = GUICtrlCreateButton("Add Separator", $x1 + 940, $y1 + 120, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($AddSeparator_button, $IconsFolder & "\Add_Separator.ico")
            GUICtrlSetTip($AddSeparator_button, "Add Separator", "", 1, 1)
            $GridToFile_button = GUICtrlCreateButton("Save Grid to file", $x1 + 1010, $y1 + 120, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($GridToFile_button, $IconsFolder & "\Save_to_File.ico")
            GUICtrlSetTip($GridToFile_button, "Save Grid to file", "", 1, 1)
            $RunBatch_button = GUICtrlCreateButton("Run Batch", $x1 + 940, $y1 + 175, 130, 45, $BS_DEFPUSHBUTTON)
            GUICtrlSetTip($RunBatch_button, "Run Batch", "", 1, 1)

            ; DISABLE ALL EXTRA BUTTONS CURRENTLY
            GUICtrlSetState($RunBatch_button, $GUI_DISABLE)
            ; GUICtrlSetState($Welcome_Module_button, $GUI_DISABLE)
            ; GUICtrlSetState($Setup_Module_button, $GUI_DISABLE)
            ; GUICtrlSetState($Smoke_Module_button, $GUI_DISABLE)
            GUICtrlSetState($Import_Module_button, $GUI_DISABLE)
            ; GUICtrlSetState($System_Module_button, $GUI_DISABLE)
            ; GUICtrlSetState($Summary_Module_button, $GUI_DISABLE)



            ; LIST VIEW
            $BatchList = GUICtrlCreateListView("", $x1 + 5, $y1 + 270, 1075, 620, BitOR(-1, $LVS_NOSORTHEADER, $WS_VSCROLL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
            $BatchList_handle = GUICtrlGetHandle($BatchList)
            $Grid_serial_col = _GUICtrlListView_AddColumn($BatchList, "Serial No.")
            $Grid_sequence_col = _GUICtrlListView_AddColumn($BatchList, "Sequence")
            $Grid_Timestamp_col = _GUICtrlListView_AddColumn($BatchList, "Timestamp", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_Status_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Status", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_OverallResult_col = _GUICtrlListView_AddColumn($BatchList, "Overall Result", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_TCName_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Name", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_PassNo_col = _GUICtrlListView_AddColumn($BatchList, "Pass No.", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_Carrier_col = _GUICtrlListView_AddColumn($BatchList, "Carrier Name", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_TestType_col = _GUICtrlListView_AddColumn($BatchList, "Test Type", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_Details_col = _GUICtrlListView_AddColumn($BatchList, "Details", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_ServerDetails_col = _GUICtrlListView_AddColumn($BatchList, "Server Details", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_AutoExpire_col = _GUICtrlListView_AddColumn($BatchList, "Autoexpire", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_IncrDate_col = _GUICtrlListView_AddColumn($BatchList, "Increase Date", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_DecrDate_col = _GUICtrlListView_AddColumn($BatchList, "Decrease Date", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_DestName_col = _GUICtrlListView_AddColumn($BatchList, "Destination", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_DialCode_col = _GUICtrlListView_AddColumn($BatchList, "Dial Code", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_UidPass_col = _GUICtrlListView_AddColumn($BatchList, "UserId/Password", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_Rate_col = _GUICtrlListView_AddColumn($BatchList, "Rate", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_EffectievDate_col = _GUICtrlListView_AddColumn($BatchList, "Effective Date", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_ExpiryDate_col = _GUICtrlListView_AddColumn($BatchList, "Expiry Date", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_RSFile_col = _GUICtrlListView_AddColumn($BatchList, "Template File", $LVSCW_AUTOSIZE)
            $Grid_RefFile_col = _GUICtrlListView_AddColumn($BatchList, "Reference File", $LVSCW_AUTOSIZE)
            GUISetState()

;~ -----------------------------------------------------------------------------------------------------------------

            ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
            $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
            GUISetBkColor(0xFFFFFF)
            GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)

            ; DETAILS FIELDS
            $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x2 + 10, $y2 + 45, 90, 15)
            $CarrierName_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 45, 170, 20, $ES_UPPERCASE)
            $RefDefFileLocation_label = GUICtrlCreateLabel("Reference File", $x2 + 630, $y2 + 45, 90, 15)
            $RefDefFileLocation_field = GUICtrlCreateCombo("", $x2 + 730, $y2 + 45, 170, 20)

            ; COLLECT REF FILES IN ARRARY
            $RefDefIniFileList_array = _FileListToArray(@ScriptDir & "\Reference Files\", "*.ini", 1)

            ; Add Entries to the Reference field
            If @error = 0 Then
                For $e = 1 To $RefDefIniFileList_array[0]
                    $RefDefCombo_Insert_Name = StringTrimRight($RefDefIniFileList_array[$e], 4)
                    _GUICtrlComboBox_InsertString($RefDefFileLocation_field, $RefDefCombo_Insert_Name)
                Next
            EndIf
            $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x2 + 10, $y2 + 80, 90, 15)
            $ImportFileLocation_field = GUICtrlCreateCombo("", $x2 + 110, $y2 + 80, 170, 20)
            $ImportIniFileList_array = _FileListToArray(@ScriptDir & "\Import Files\", "*.ini", 1)

            ; Add Entries to the Import field
            If @error = 0 Then
                For $e = 1 To $ImportIniFileList_array[0]
                    $ImportCombo_Insert_Name = StringTrimRight($ImportIniFileList_array[$e], 4)
                    _GUICtrlComboBox_InsertString($ImportFileLocation_field, $ImportCombo_Insert_Name)
                Next
            EndIf

            ; DATES
            $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x2 + 320, $y2 + 80, 90, 20)
            $IncrDate_datefield = GUICtrlCreateDate("", $x2 + 420, $y2 + 80, 170, 20)
            $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
            _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")
            $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x2 + 630, $y2 + 80, 90, 20)
            $DecrDate_datefield = GUICtrlCreateDate("", $x2 + 730, $y2 + 80, 170, 20)
            $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
            _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")
            GUISetState()
            _RefreshGridData()
        Case $TestType_field
            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)
            Switch $TestType_data
                Case "Import Rates to Pending"
                    GUIDelete($ControlGUI)
                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x2 + 10, $y2 + 45, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 45, 170, 20, $ES_UPPERCASE)
                    $RefDefFileLocation_label = GUICtrlCreateLabel("Reference File", $x2 + 630, $y2 + 45, 90, 15)
                    $RefDefFileLocation_field = GUICtrlCreateCombo("", $x2 + 730, $y2 + 45, 170, 20)

                    ; COLLECT REF FILES IN ARRARY
                    $RefDefIniFileList_array = _FileListToArray(@ScriptDir & "\Reference Files\", "*.ini", 1)

                    ; Add Entries to the Reference field
                    If @error = 0 Then
                        For $e = 1 To $RefDefIniFileList_array[0]
                            $RefDefCombo_Insert_Name = StringTrimRight($RefDefIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($RefDefFileLocation_field, $RefDefCombo_Insert_Name)
                        Next
                    EndIf
                    $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x2 + 10, $y2 + 80, 90, 15)
                    $ImportFileLocation_field = GUICtrlCreateCombo("", $x2 + 110, $y2 + 80, 170, 20)

                    ; GET ALL INI FILES IN THE IMPORT FOLDER IN AN ARRAY
                    $ImportIniFileList_array = _FileListToArray(@ScriptDir & "\Import Files\", "*.ini", 1)
                    ; Add Entries to the Import field
                    If @error = 0 Then
                        For $e = 1 To $ImportIniFileList_array[0]
                            $ImportCombo_Insert_Name = StringTrimRight($ImportIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($ImportFileLocation_field, $ImportCombo_Insert_Name)
                        Next
                    EndIf

                    ; DATES
                    $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x2 + 320, $y2 + 80, 90, 20)
                    $IncrDate_datefield = GUICtrlCreateDate("", $x2 + 420, $y2 + 80, 170, 20)
                    $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
                    _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")
                    $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x2 + 630, $y2 + 80, 90, 20)
                    $DecrDate_datefield = GUICtrlCreateDate("", $x2 + 730, $y2 + 80, 170, 20)
                    $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
                    _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")
                    GUISetState()
                Case "Import Rates to Active"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x2 + 10, $y2 + 45, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 45, 170, 20, $ES_UPPERCASE)
                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x2 + 320, $y2 + 45, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x2 + 420, $y2 + 45, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Don't Autoexpire Old Data|Autoexpire Old Data", "Don't Autoexpire Old Data")
                    $RefDefFileLocation_label = GUICtrlCreateLabel("Reference File", $x2 + 630, $y2 + 45, 90, 15)
                    $RefDefFileLocation_field = GUICtrlCreateCombo("", $x2 + 730, $y2 + 45, 170, 20)

                    ; COLLECT REF FILES IN ARRARY
                    $RefDefIniFileList_array = _FileListToArray(@ScriptDir & "\Reference Files\", "*.ini", 1)

                    ; Add Entries to the Reference field
                    If @error = 0 Then
                        For $e = 1 To $RefDefIniFileList_array[0]
                            $RefDefCombo_Insert_Name = StringTrimRight($RefDefIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($RefDefFileLocation_field, $RefDefCombo_Insert_Name)
                        Next
                    EndIf
                    $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x2 + 10, $y2 + 80, 90, 15)
                    $ImportFileLocation_field = GUICtrlCreateCombo("", $x2 + 110, $y2 + 80, 170, 20)

                    ; ADD FILES FROM IMPORT FOLDER TO ARRAY
                    $ImportIniFileList_array = _FileListToArray(@ScriptDir & "\Import Files\", "*.ini", 1)

                    ; Add Entries to the Import field
                    If @error = 0 Then
                        For $e = 1 To $ImportIniFileList_array[0]
                            $ImportCombo_Insert_Name = StringTrimRight($ImportIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($ImportFileLocation_field, $ImportCombo_Insert_Name)
                        Next
                    EndIf

                    ; DATES
                    $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x2 + 320, $y2 + 80, 90, 20)
                    $IncrDate_datefield = GUICtrlCreateDate("", $x2 + 420, $y2 + 80, 170, 20)
                    $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
                    _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")
                    $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x2 + 630, $y2 + 80, 90, 20)
                    $DecrDate_datefield = GUICtrlCreateDate("", $x2 + 730, $y2 + 80, 170, 20)
                    $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
                    _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")
                    GUISetState()
                Case "Edit Carrier Rates"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x2 + 10, $y2 + 45, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 45, 170, 20, $ES_UPPERCASE)
                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x2 + 320, $y2 + 45, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x2 + 420, $y2 + 45, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Refresh Grid|Edit Entry|Delete Entry|Clear All", "Refresh Grid")
                    $RefDefFileLocation_label = GUICtrlCreateLabel("Reference File", $x2 + 630, $y2 + 45, 90, 15)
                    $RefDefFileLocation_field = GUICtrlCreateCombo("", $x2 + 730, $y2 + 45, 170, 20)

                    ; COLLECT REF FILES IN ARRARY
                    $RefDefIniFileList_array = _FileListToArray(@ScriptDir & "\Reference Files\", "*.ini", 1)

                    ; Add Entries to the Reference field
                    If @error = 0 Then
                        For $e = 1 To $RefDefIniFileList_array[0]
                            $RefDefCombo_Insert_Name = StringTrimRight($RefDefIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($RefDefFileLocation_field, $RefDefCombo_Insert_Name)
                        Next
                    EndIf

                    ; DETAILS FIELDS
                    $Destnination_label = GUICtrlCreateLabel("Destination Name", $x2 + 10, $y2 + 110, 90, 15)
                    $Destnination_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 110, 170, 20)
                    $DialCode_label = GUICtrlCreateLabel("Dial Code", $x2 + 320, $y2 + 110, 90, 15)
                    $DialCode_field = GUICtrlCreateInput("", $x2 + 420, $y2 + 110, 170, 20, $ES_NUMBER)
                    $Rate_label = GUICtrlCreateLabel("Rate", $x2 + 630, $y2 + 110, 90, 15)
                    $Rate_field = GUICtrlCreateInput("", $x2 + 730, $y2 + 110, 170, 20, $ES_NUMBER)

                    ; CHECKBOXED DATE
                    $tDate = 0
                    $EffDate_label = GUICtrlCreateLabel("Use Effective Date", $x2 + 320, $y2 + 140, 90, 20)
                    $EffDate_datefield = GUICtrlCreateDate("", $x2 + 420, $y2 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
                    $EffDate_handle = GUICtrlGetHandle($EffDate_datefield)
                    _GUICtrlDTP_SetFormat($EffDate_handle, "ddd, dd/MMM/yy")
                    _GUICtrlDTP_SetSystemTimeEx($EffDate_handle, $tDate, True)
                    $ExpDate_label = GUICtrlCreateLabel("Use Expiry Date", $x2 + 630, $y2 + 140, 90, 20)
                    $ExpDate_datefield = GUICtrlCreateDate("", $x2 + 730, $y2 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
                    $ExpDate_handle = GUICtrlGetHandle($ExpDate_datefield)
                    _GUICtrlDTP_SetFormat($ExpDate_handle, "ddd, dd/MMM/yy")
                    _GUICtrlDTP_SetSystemTimeEx($ExpDate_handle, $tDate, True)
                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")

                    ;RESET THE TEST TYPE TO INITIAL CHOICE
                    ControlSend("Optima Rate Import Test Case Creator", "Test Type", $TestType_field, "i")
                Case "Add Analysis Stage"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)
                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x2 + 320, $y2 + 45, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x2 + 420, $y2 + 45, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Run All Scripts|Run Script A001|Run Script A002|Run Script A003|Run Script A004|", "Run All Scripts")
                    GUISetState()
                Case "Run SQL File"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)
                    $ServerDetails_label = GUICtrlCreateLabel("Server Details Name", $x2 + 10, $y2 + 170, 90, 15)
                    $ServerDetails_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 170, 170, 20)
                    $UidPass_label = GUICtrlCreateLabel("User Id/Password", $x2 + 320, $y2 + 170, 90, 15)
                    $UidPass_field = GUICtrlCreateInput("", $x2 + 420, $y2 + 170, 170, 20)
                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")

                    ;RESET THE TEST TYPE TO INITIAL CHOICE
                    ControlSend("Optima Rate Import Test Case Creator", "Test Type", $TestType_field, "i")
                Case "Run Win Batch File"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)
                    $ServerDetails_label = GUICtrlCreateLabel("Server Details Name", $x2 + 10, $y2 + 170, 90, 15)
                    $ServerDetails_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 170, 170, 20)
                    $UidPass_label = GUICtrlCreateLabel("User Id/Password", $x2 + 320, $y2 + 170, 90, 15)
                    $UidPass_field = GUICtrlCreateInput("", $x2 + 420, $y2 + 170, 170, 20)
                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")

                    ;RESET THE TEST TYPE TO INITIAL CHOICE
                    ControlSend("Optima Rate Import Test Case Creator", "Test Type", $TestType_field, "i")
            EndSwitch

;~ -----------------------------------------------------------------------------------------------------------------

;~ Case $GUI_EVENT_CLOSE
;~ SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
;~ GUIDelete()
;~ Exit
        Case $GUI_EVENT_CLOSE
            If $msg[1] = $AboutScreen_GUI Then
                GUIDelete($AboutScreen_GUI)
                $AboutScreen_GUI = 0
            Else
                SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
                Exit
            EndIf
        Case $AddtoBatch_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")
            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)
            $TestCaseStatus_data = ""
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)
            $OverallResult_data = "Queued"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)
            $TCName_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Case Name", $TCName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)
            $TCPassNo_data = ControlGetText("Optima Rate Import Test Case Creator", "Pass Number", $TCPassNo_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)
            $CarrierName_data = ControlGetText("Optima Rate Import Test Case Creator", "Carrier Name", $CarrierName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)
            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)
            $AdditionalDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "Additional Details", $AdditionalDetails_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)
            $ServerDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "Server Details Name", $ServerDetails_field)
            If @error = 1 Then
                IniWrite($ProfilesINI, $SectionNumber_data, "Server Details", "")
            Else
                IniWrite($ProfilesINI, $SectionNumber_data, "Server Details", $ServerDetails_data)
            EndIf
            $IncrDate_data = GUICtrlRead($IncrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)
            $DecrDate_data = GUICtrlRead($DecrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)
            $Destnination_data = ControlGetText("Optima Rate Import Test Case Creator", "Destination Nam", $Destnination_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)
            $DialCode_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $DialCode_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)
            $UidPass_data = ControlGetText("Optima Rate Import Test Case Creator", "User Id/Password", $UidPass_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)
            $Rate_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $Rate_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)
            $EffDate_data = GUICtrlRead($EffDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)
            $ExpDate_data = GUICtrlRead($ExpDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)
            $ImportFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Import File", $ImportFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $ImportFileLocation_data)
            $RefDefFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Reference File", $RefDefFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDefFileLocation_data)
            _RefreshGridData()
        Case $RemFromGrid_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            If $SelectedRow > 1 Then
                $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
                $Ini_Section_delete = $Grid_listdata_sections[$SelectedRow]
                IniDelete($ProfilesINI, $Ini_Section_delete)
                For $c = $Grid_listdata_sections[$SelectedRow] To $Grid_listdata_sections[0]
                    IniRenameSection($ProfilesINI, $Grid_listdata_sections[$c], $Grid_listdata_sections[$c] - 1)
                Next
            EndIf
            _RefreshGridData()
        Case $MoveUp_button
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow > 1 Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Above_section = $Grid_listdata_sections[$SelectedRow - 1]
                $temp = 9999999
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Above_section, $Grid_listdata_sections[$SelectedRow])
                IniRenameSection($ProfilesINI, $temp, $Grid_listdata_sections[$SelectedRow - 1])
            EndIf
            _RefreshGridData()
        Case $MoveDown_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow < $Grid_listdata_sections[0] Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Below_section = $Grid_listdata_sections[$SelectedRow + 1]
                MsgBox(0, $Selected_section, $Below_section)
                $temp = "xxx"
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Below_section, $Selected_section)
                IniRenameSection($ProfilesINI, $temp, $Below_section)
            EndIf
            _RefreshGridData()
        Case $AddSeparator_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")
            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)
            $TestCaseStatus_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)
            $OverallResult_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)
            $TCName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)
            $TCPassNo_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)
            $CarrierName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)
            $TestType_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)
            $AdditionalDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)
            $ServerDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "Server Details", $ServerDetails_data)
            $AutoExpire_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "AUTOEXPIRE", $AutoExpire_data)
            $IncrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)
            $DecrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)
            $Destnination_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)
            $DialCode_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)
            $UidPass_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)
            $Rate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)
            $EffDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)
            $ExpDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)
            $ImportFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $ImportFileLocation_data)
            $RefDefFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDefFileLocation_data)
            _RefreshGridData()
        Case $GridToFile_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $ProfilesIniFileList_array = _FileListToArray(@ScriptDir & "\Profiles\", "*.ini", 1)
;~ MsgBox(0,"",$ProfilesINI)
            $ProfilesINI_NewName = FileSaveDialog("Save the Grid data to an INI File", @ScriptDir & "\Profiles", "INI Files (*.ini)", 16, "Profile Number " & $ProfilesIniFileList_array[0])
;~ MsgBox(0,"",$ProfilesINI_NewName)
            FileCopy($ProfilesINI, $ProfilesINI_NewName & ".ini")
            $ProfilesINI_OnlyFileName = _PathSplit($ProfilesINI_NewName & ".ini", $szDrive, $szDir, $szFName, $szExt)
            MsgBox(8192, "Task Update", "The grid data has been saved to the File: " & $szFName & $szExt)
            _RefreshTabBar()
            $iIndex = _GUICtrlTab_FindTab($Tab_TCSuite, $szFName)
            _GUICtrlTab_ClickTab($Tab_TCSuite, $iIndex)
        Case $RunBatch_button
            ; First set all the ini file statuses to Pending.
            ; Refrsh Grid
            ; Pass over Control to Main







;~ -----------------------------------------------------------------------------------------------------------------
        Case $msg = $Tab_TCSuite
            $current = _GUICtrlTab_GetCurSel($Tab_TCSuite)
            $Tab_Name = _GUICtrlTab_GetItemText($Tab_TCSuite, $current)
            $ProfilesINI = @ScriptDir & "\Profiles\" & $Tab_Name & ".ini"
            ; This here is a temp solution to stop the contineous refrsh problem.
            If $current <> $GenericTempValue Then
                _RefreshGridData()
            EndIf
            $GenericTempValue = $current
    EndSwitch
WEnd

#cs -----------------------------------------------------------------------------------------------------------------

    Functions

#CE -----------------------------------------------------------------------------------------------------------------


; FUNCTION TO REFRESH THE GRID DATA
Func _RefreshGridData()
    $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
    If @error Then
        _GUICtrlListView_DeleteAllItems($BatchList_handle)
    ElseIf $Grid_listdata_sections[0] > 0 Then
        _GUICtrlListView_BeginUpdate($BatchList_handle)
        _GUICtrlListView_DeleteAllItems($BatchList_handle)
        For $a = 1 To $Grid_listdata_sections[0]

;~ _ArrayDisplay($Grid_listdata_sections)
            _ArraySort($Grid_listdata_sections, 0, 1)
;~ _ArrayDisplay($Grid_listdata_sections)
            $Grid_All_listdata = IniReadSection($ProfilesINI, $Grid_listdata_sections[$a])
            If Not @error Then
                If $Grid_All_listdata[0][0] > 0 Then
                    _GUICtrlListView_AddItem($BatchList_handle, $a)
                    _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_listdata_sections[$a], 1)
                    For $b = 2 To $Grid_All_listdata[0][0]
                        _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_All_listdata[$b][1], $b + 1)
                    Next
                EndIf
            EndIf
        Next
        For $a = 0 To _GUICtrlListView_GetColumnCount($BatchList_handle)
            _GUICtrlListView_SetColumnWidth($BatchList_handle, $a, $LVSCW_AUTOSIZE_USEHEADER)
        Next
        _GUICtrlListView_EndUpdate($BatchList_handle)
    EndIf
EndFunc   ;==>_RefreshGridData

;~ -----------------------------------------------------------------------------------------------------------------
; FUNCTION TO REFRESH THE TAB BAR
Func _RefreshTabBar()
    ; DELETE ALL CURRENT TAB ITEMS SO THAT THE TAB BAR CAN BE RECREATED
    _GUICtrlTab_DeleteAllItems($Tab_TCSuite)

    ; GET ALL INI FILES IN THE PROFILES FOLDER IN AN ARRAY
    $ProfilesIniFileList_array = _FileListToArray(@ScriptDir & "\Profiles\", "*.ini", 1)

    ; CREATE THE DEFAULT TAB
    _GUICtrlTab_InsertItem($Tab_TCSuite, 0, "NEW PROFILE")

    ; ADD TABS TO TAB BAR BASED ON THE $IniFileList_array DATA
    If @error = 0 Then
        For $d = 1 To $ProfilesIniFileList_array[0]
            If $ProfilesIniFileList_array[$d] <> "NEW PROFILE.ini" Then
                $Tab_Insert_Name = StringTrimRight($ProfilesIniFileList_array[$d], 4)
                _GUICtrlTab_InsertItem($Tab_TCSuite, $d, $Tab_Insert_Name)
            EndIf
        Next
    EndIf
EndFunc   ;==>_RefreshTabBar


;~ -----------------------------------------------------------------------------------------------------------------
; CREATE THE ABOUT SCREEN WHICH WILL BE LAUCHED BY USING F1
Func _AboutScreen()
    $AboutScreen_GUI = GUICreate("About Automata v0.1 alpha", 500, 300, -1, -1)
    $AboutScreen_label = GUICtrlCreateLabel("Rishav is having his pet gnomes slug it out on a worthwhile About screen - in his infernal dungeon which incidentally is surrounded by miles of lava fields. " & @LF & "That, or he is being lazy. Have patience. One day hitting F1 will bear fruits.", 50, 100, 390, 200)
    GUICtrlSetFont($AboutScreen_label, 12)
    GUISetState()
EndFunc   ;==>_AboutScreen

;~ -----------------------------------------------------------------------------------------------------------------
; CREATE FUNCTION TO DEPRESS THE MODULE BUTTONS AND CREATE RESPECTIVE GUIs
Func _ChangeModules($ClickedModule_button)
    GUICtrlSetState($Welcome_Module_button, $GUI_ENABLE)
    GUICtrlSetState($Setup_Module_button, $GUI_ENABLE)
    GUICtrlSetState($Smoke_Module_button, $GUI_ENABLE)
    GUICtrlSetState($Import_Module_button, $GUI_ENABLE)
    GUICtrlSetState($System_Module_button, $GUI_ENABLE)
    GUICtrlSetState($Summary_Module_button, $GUI_ENABLE)
    GUICtrlSetState($ClickedModule_button, $GUI_DISABLE)
;~  GUIDelete($MainImportGUI)
;~  GUIDelete($MainWelcomeGUI)
EndFunc   ;==>_ChangeModules

thanks and regards

Rishav

ps. I am rather new to programming so if anyone has any generic comments or advices regarding my code, you are welcome.

PPS. DONOT click ok on the error message. better to just close autoit.exe from the taskmanager or ctrlbreak the code. if you click ok, the system will freeze and the display starts flickering. :/

Edited by Rishav
Link to comment
Share on other sites

Don't know if that is what you've meant:

#include <TabConstants.au3>
#include <WindowsConstants.au3>

Global $hGUI, $TabCtrl, $aTabItems[10]

$hGUI = GUICreate('Test', 400, 400)
$TabCtrl = GUICtrlCreateTab(0, 0, 400, 400, BitOR($WS_CHILD, $TCS_VERTICAL))

For $i = 0 To UBound($aTabItems) -1
    $aTabItems[$i] = GUICtrlCreateTabItem('Item ' & $i+1)
    GUICtrlCreateButton('Button of Tab '  & $i+1, 100, 20, 100, 23)
Next

GUISetState()
Do
Until GUIGetMsg() = -3

GUIDelete()
Link to comment
Share on other sites

Don't know if that is what you've meant:

#include <TabConstants.au3>
#include <WindowsConstants.au3>

Global $hGUI, $TabCtrl, $aTabItems[10]

$hGUI = GUICreate('Test', 400, 400)
$TabCtrl = GUICtrlCreateTab(0, 0, 400, 400, BitOR($WS_CHILD, $TCS_VERTICAL))

For $i = 0 To UBound($aTabItems) -1
    $aTabItems[$i] = GUICtrlCreateTabItem('Item ' & $i+1)
    GUICtrlCreateButton('Button of Tab '  & $i+1, 100, 20, 100, 23)
Next

GUISetState()
Do
Until GUIGetMsg() = -3

GUIDelete()

Thanks. the problem with TCS_Vertical is that the text also comes in rotated at 90'. so i decided to use simple buttons instead of tabs. My problem is that with each buttton click, i am trying to show a different GUI. so i thought i will destroy all child GUIs on a button click and then depending on the button click, recreate the specific GUI that was needed. but i am getting weird pop up error messages and i simply cannot find what is wrong in my code. >_<

UPDATE: made some fixes. now i can go from the Welcome screen to the Import screen but not back to the welcome screen.

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.1.1 (beta)
    Author:         Rishav Sharan

    Script Function:
    GUI to create simple import test cases

#ce ----------------------------------------------------------------------------


#cs ----------------------------------------------------------------------------
    Includes
#ce ----------------------------------------------------------------------------

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <GuiDateTimePicker.au3>
#include <GuiTab.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiTab.au3>
#include <GuiComboBox.au3>
#include <GuiToolTip.au3>
#include <GDIPlus.au3>

#cs ----------------------------------------------------------------------------
    Program Options
#ce ----------------------------------------------------------------------------
#NoTrayIcon

#cs ----------------------------------------------------------------------------
    Declarations
#ce ----------------------------------------------------------------------------
Opt("MustDeclareVars", 1)

; Global declare file attributes
Global $d, $szDrive, $szDir, $szFName, $szExt
Global $hGUI, $hImage, $hGraphic, $hImage1

; Global declare temporary variable
Global $AboutScreen_GUI = 0

; Declare GUIs
Global $MainGUI, $MainImportGUI, $ControlGUI, $MainWelcomeGUI, $AboutScreen_GUI

; Declare Module buttons
Global $Welcome_Module_button, $Setup_Module_button, $Smoke_Module_button, $Import_Module_button, $System_Module_button, $Summary_Module_button, $Options_Module_button

; Declare constants
Dim Const $x1 = 150, $y1 = 10, $x2 = 75, $y2 = 10, $x3 = 10, $y3 = 20

; Declare temporary variable
Dim $GenericTempValue = "temp value"

; Declare fields
Dim $TestType_field, $TCName_field, $TCPassNo_field, $CarrierName_field, $ImportFileLocation_field, $RefDefFileLocation_field, $AdditionalDetails_field, $Destnination_field
Dim $Rate_field, $DialCode_field, $EffDate_datefield, $ExpDate_datefield, $ServerDetails_field, $UidPass_field, $IncrDate_datefield, $DecrDate_datefield

; Declare labels
Dim $TCName_label, $TCPassNo_label, $TestType_label, $CarrierName_label, $AboutScreen_label, $RefDefFileLocation_label, $IncrDate_label, $DecrDate_label, $AdditionalDetails_label
Dim $Destnination_label, $DialCode_label, $ImportFileLocation_label, $Rate_label, $EffDate_label, $ExpDate_label, $ServerDetails_label, $UidPass_label, $AboutScreen_label

; Declare buttons
Dim $AddtoBatch_button, $RemFromGrid_button, $MoveUp_button, $MoveDown_button, $AddSeparator_button, $GridToFile_button, $RunBatch_button
Dim $Tab_TCSuite, $BatchList

; Declare grid columns
Dim $Grid_serial_col, $Grid_sequence_col, $Grid_Timestamp_col, $Grid_Status_col, $Grid_OverallResult_col, $Grid_TCName_col, $Grid_PassNo_col, $Grid_Carrier_col
Dim $Grid_TestType_col, $Grid_Details_col, $Grid_ServerDetails_col, $Grid_AutoExpire_col, $Grid_IncrDate_col, $Grid_DecrDate_col, $Grid_DestName_col, $Grid_DialCode_col
Dim $Grid_UidPass_col, $Grid_Rate_col, $Grid_EffectievDate_col, $Grid_ExpiryDate_col, $Grid_RSFile_col, $Grid_RefFile_col

; Declare data variables
Dim $TestType_data, $SectionNumber_data, $Timestamp_data, $TestCaseStatus_data, $OverallResult_data, $TCName_data, $TCPassNo_data, $CarrierName_data, $AdditionalDetails_data
Dim $ServerDetails_data, $IncrDate_data, $DecrDate_data, $Destnination_data, $DialCode_data, $UidPass_data, $Rate_data, $EffDate_data, $ImportFileLocation_data
Dim $RefDefFileLocation_data, $AutoExpire_data, $Grid_All_listdata, $EffDate_data, $ExpDate_data

; Declare handles
Dim $EffDate_handle, $ExpDate_handle, $IncrDate_handle, $DecrDate_handle, $BatchList_handle

; Display arrays
Dim $ProfilesIniFileList_array, $ImportIniFileList_array, $RefDefIniFileList_array

; Declare assets
Dim $WelcomeModule_pic

; Declare misc variables
Dim $IconsFolder, $ProfilesINI, $ProfilesINI_NewName, $ProfilesINI_OnlyFileName, $ImportCombo_Insert_Name, $Grid_listdata_sections, $SelectedRow, $Ini_Section_delete
Dim $Selected_section, $Above_section, $Below_section, $Tab_Insert_Name, $RefDefCombo_Insert_Name, $Tab_Name, $ClickedModule_button

; Declare indices
Dim $msg, $current, $iIndex, $temp, $tDate, $a, $b, $c, $d, $e


#cs ----------------------------------------------------------------------------
    Main GUI. GUI Backend data file. This is the temp ini file which saves all the data till a specific new file is created.
    ; This is to save the data in case of system failure.
    ; If we added the data directly to the grid, in case of accidental closure or power failure, the data will be lost.
#ce ----------------------------------------------------------------------------

$IconsFolder = @ScriptDir & "\System\Icons\"
HotKeySet("{F1}", "_AboutScreen")

; MAIN GUI
$MainGUI = GUICreate("Optima Rate Import Test Case Creator", 1250, 900, -1, -1, BitOR($WS_CAPTION, $WS_POPUPWINDOW))
GUISetIcon(@SystemDir & "\system\Donkey.ico", 0)
GUISetBkColor(0xFFFFFF)


; MODULE SELECTOR. LATER NEED TO MOVE IT TO A MASTER GUI
$Welcome_Module_button = GUICtrlCreateButton("Welcome Module", $x3, $y3, 130, 100, $WS_BORDER)
$Setup_Module_button = GUICtrlCreateButton("Setup Module", $x3, $y3 + 100, 130, 100, BitOR($BS_FLAT, $WS_BORDER))
$Smoke_Module_button = GUICtrlCreateButton("Smoke Module", $x3, $y3 + 200, 130, 100, BitOR($BS_ICON, $WS_BORDER))
$Import_Module_button = GUICtrlCreateButton("Import Module", $x3, $y3 + 300, 130, 100, BitOR($BS_ICON, $WS_BORDER))
;~ GUICtrlSetFont($Import_Module_button, 11, 800)
;~ GUICtrlSetBkColor($Import_Module_button, 0xFFFFFF)
$System_Module_button = GUICtrlCreateButton("System Module", $x3, $y3 + 400, 130, 100, BitOR($BS_ICON, $WS_BORDER))
$Summary_Module_button = GUICtrlCreateButton("Summary Module", $x3, $y3 + 500, 130, 100, BitOR($BS_ICON, $WS_BORDER))
$Options_Module_button = GUICtrlCreateButton("Options Module", $x3, $y3 + 600, 130, 100, BitOR($BS_ICON, $WS_BORDER))
GUISetState()

ControlClick("", "", $Welcome_Module_button)

;~ -----------------------------------------------------------------------------------------------------------------

; Capture and execute all button clicks
While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]

        #cs ----------------------------------------------------------------------------
            Case statements for the modules
        #ce ----------------------------------------------------------------------------

        Case $Welcome_Module_button
            _ChangeModules($Welcome_Module_button)

            GUISwitch($MainWelcomeGUI)
            ; WELCOME MODULE GUI
            $MainWelcomeGUI = GUICreate("Welcome Module", 1250, 900, 300, 200, $WS_CHILD, -1, $MainGUI)

            $hGUI = $MainWelcomeGUI

            _GDIPlus_Startup()
            $hImage = _GDIPlus_ImageLoadFromFile("c:\MAIN3.png")
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            GUIRegisterMsg($WM_PAINT, "_MY_WM_PAINT")

            GUISetState()

        Case $Import_Module_button
            _ChangeModules($Import_Module_button)

            GUIDelete($MainWelcomeGUI)

            ; IMPORT MODULE GUI
            $MainImportGUI = GUICreate("Import Module", 1250, 900, 0, 0, $WS_CHILD, -1, $MainGUI)

            ; DETAILS FIELDS
            $TCName_label = GUICtrlCreateLabel("Test Case Name", $x1 + 10, $y1 + 23, 90, 15)
            $TCName_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 23, 170, 20, $ES_UPPERCASE)
            $TCPassNo_label = GUICtrlCreateLabel("Pass Number", $x1 + 320, $y1 + 23, 90, 15)
            $TCPassNo_field = GUICtrlCreateInput("1", $x1 + 420, $y1 + 23, 170, 20, $ES_NUMBER)
            $TestType_label = GUICtrlCreateLabel("Test Type", $x1 + 630, $y1 + 23, 90, 15)
            $TestType_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 23, 170, 20, $CBS_DROPDOWNLIST)
            GUICtrlSetData($TestType_field, "Import Rates to Pending|Import Rates to Active|Edit Carrier Rates|Add Analysis Stage|Run SQL File|Run Win Batch File", "Import Rates to Pending")

            ; TC SUITE TABS
            $Tab_TCSuite = _GUICtrlTab_Create($MainImportGUI, $x1, $y1 + 242, 1090, 650)
            _RefreshTabBar()

            ; SET PROFILES INI BASED ON THE TAB SELECTED
            $current = _GUICtrlTab_GetCurSel($Tab_TCSuite)
            $Tab_Name = _GUICtrlTab_GetItemText($Tab_TCSuite, $current)
            $ProfilesINI = @ScriptDir & "\Profiles\" & $Tab_Name & ".ini"

            ; GROUP FOR BUTTONS
            GUICtrlCreateGroup("", $x1 + 925, $y1, 160, 230)

            ; BUTTONS
            $AddtoBatch_button = GUICtrlCreateButton("Add to Grid", $x1 + 940, $y1 + 10, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($AddtoBatch_button, $IconsFolder & "\Add_to_Grid.ico")
            GUICtrlSetTip($AddtoBatch_button, "Add to Grid", "", 1, 1)
            $RemFromGrid_button = GUICtrlCreateButton("Remove from Grid", $x1 + 1010, $y1 + 10, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($RemFromGrid_button, $IconsFolder & "\Remove_from_Grid.ico")
            GUICtrlSetTip($RemFromGrid_button, "Remove from Grid", "", 1, 1)
            $MoveUp_button = GUICtrlCreateButton("Move up Item", $x1 + 940, $y1 + 65, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($MoveUp_button, $IconsFolder & "\Move_Up.ico")
            GUICtrlSetTip($MoveUp_button, "Move up Item", "", 1, 1)
            $MoveDown_button = GUICtrlCreateButton("Move Down Item", $x1 + 1010, $y1 + 65, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($MoveDown_button, $IconsFolder & "\Move_Down.ico")
            GUICtrlSetTip($MoveDown_button, "Move Down Item", "", 1, 1)
            $AddSeparator_button = GUICtrlCreateButton("Add Separator", $x1 + 940, $y1 + 120, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($AddSeparator_button, $IconsFolder & "\Add_Separator.ico")
            GUICtrlSetTip($AddSeparator_button, "Add Separator", "", 1, 1)
            $GridToFile_button = GUICtrlCreateButton("Save Grid to file", $x1 + 1010, $y1 + 120, 60, 50, BitOR($BS_ICON, $WS_THICKFRAME))
            GUICtrlSetImage($GridToFile_button, $IconsFolder & "\Save_to_File.ico")
            GUICtrlSetTip($GridToFile_button, "Save Grid to file", "", 1, 1)
            $RunBatch_button = GUICtrlCreateButton("Run Batch", $x1 + 940, $y1 + 175, 130, 45, $BS_DEFPUSHBUTTON)
            GUICtrlSetTip($RunBatch_button, "Run Batch", "", 1, 1)

            ; DISABLE ALL EXTRA BUTTONS CURRENTLY
            GUICtrlSetState($RunBatch_button, $GUI_DISABLE)
            ; GUICtrlSetState($Welcome_Module_button, $GUI_DISABLE)
            ; GUICtrlSetState($Setup_Module_button, $GUI_DISABLE)
            ; GUICtrlSetState($Smoke_Module_button, $GUI_DISABLE)
            GUICtrlSetState($Import_Module_button, $GUI_DISABLE)
            ; GUICtrlSetState($System_Module_button, $GUI_DISABLE)
            ; GUICtrlSetState($Summary_Module_button, $GUI_DISABLE)



            ; LIST VIEW
            $BatchList = GUICtrlCreateListView("", $x1 + 5, $y1 + 270, 1075, 620, BitOR(-1, $LVS_NOSORTHEADER, $WS_VSCROLL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
            $BatchList_handle = GUICtrlGetHandle($BatchList)
            $Grid_serial_col = _GUICtrlListView_AddColumn($BatchList, "Serial No.")
            $Grid_sequence_col = _GUICtrlListView_AddColumn($BatchList, "Sequence")
            $Grid_Timestamp_col = _GUICtrlListView_AddColumn($BatchList, "Timestamp", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_Status_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Status", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_OverallResult_col = _GUICtrlListView_AddColumn($BatchList, "Overall Result", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_TCName_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Name", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_PassNo_col = _GUICtrlListView_AddColumn($BatchList, "Pass No.", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_Carrier_col = _GUICtrlListView_AddColumn($BatchList, "Carrier Name", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_TestType_col = _GUICtrlListView_AddColumn($BatchList, "Test Type", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_Details_col = _GUICtrlListView_AddColumn($BatchList, "Details", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_ServerDetails_col = _GUICtrlListView_AddColumn($BatchList, "Server Details", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_AutoExpire_col = _GUICtrlListView_AddColumn($BatchList, "Autoexpire", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_IncrDate_col = _GUICtrlListView_AddColumn($BatchList, "Increase Date", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_DecrDate_col = _GUICtrlListView_AddColumn($BatchList, "Decrease Date", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_DestName_col = _GUICtrlListView_AddColumn($BatchList, "Destination", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_DialCode_col = _GUICtrlListView_AddColumn($BatchList, "Dial Code", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_UidPass_col = _GUICtrlListView_AddColumn($BatchList, "UserId/Password", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_Rate_col = _GUICtrlListView_AddColumn($BatchList, "Rate", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_EffectievDate_col = _GUICtrlListView_AddColumn($BatchList, "Effective Date", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_ExpiryDate_col = _GUICtrlListView_AddColumn($BatchList, "Expiry Date", $LVSCW_AUTOSIZE_USEHEADER)
            $Grid_RSFile_col = _GUICtrlListView_AddColumn($BatchList, "Template File", $LVSCW_AUTOSIZE)
            $Grid_RefFile_col = _GUICtrlListView_AddColumn($BatchList, "Reference File", $LVSCW_AUTOSIZE)
            GUISetState()

;~ -----------------------------------------------------------------------------------------------------------------

            ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
            $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
            GUISetBkColor(0xFFFFFF)
            GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)

            ; DETAILS FIELDS
            $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x2 + 10, $y2 + 45, 90, 15)
            $CarrierName_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 45, 170, 20, $ES_UPPERCASE)
            $RefDefFileLocation_label = GUICtrlCreateLabel("Reference File", $x2 + 630, $y2 + 45, 90, 15)
            $RefDefFileLocation_field = GUICtrlCreateCombo("", $x2 + 730, $y2 + 45, 170, 20)

            ; COLLECT REF FILES IN ARRARY
            $RefDefIniFileList_array = _FileListToArray(@ScriptDir & "\Reference Files\", "*.ini", 1)

            ; Add Entries to the Reference field
            If @error = 0 Then
                For $e = 1 To $RefDefIniFileList_array[0]
                    $RefDefCombo_Insert_Name = StringTrimRight($RefDefIniFileList_array[$e], 4)
                    _GUICtrlComboBox_InsertString($RefDefFileLocation_field, $RefDefCombo_Insert_Name)
                Next
            EndIf
            $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x2 + 10, $y2 + 80, 90, 15)
            $ImportFileLocation_field = GUICtrlCreateCombo("", $x2 + 110, $y2 + 80, 170, 20)
            $ImportIniFileList_array = _FileListToArray(@ScriptDir & "\Import Files\", "*.ini", 1)

            ; Add Entries to the Import field
            If @error = 0 Then
                For $e = 1 To $ImportIniFileList_array[0]
                    $ImportCombo_Insert_Name = StringTrimRight($ImportIniFileList_array[$e], 4)
                    _GUICtrlComboBox_InsertString($ImportFileLocation_field, $ImportCombo_Insert_Name)
                Next
            EndIf

            ; DATES
            $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x2 + 320, $y2 + 80, 90, 20)
            $IncrDate_datefield = GUICtrlCreateDate("", $x2 + 420, $y2 + 80, 170, 20)
            $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
            _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")
            $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x2 + 630, $y2 + 80, 90, 20)
            $DecrDate_datefield = GUICtrlCreateDate("", $x2 + 730, $y2 + 80, 170, 20)
            $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
            _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")
            GUISetState()
            _RefreshGridData()

        Case $Welcome_Module_button
            _ChangeModules($Welcome_Module_button)

            ; WELCOME MODULE GUI
            $MainWelcomeGUI = GUICreate("Welcome Module", 1250, 900, 300, 200, $WS_CHILD, -1, $MainGUI)

            $hGUI = $MainWelcomeGUI

            _GDIPlus_Startup()
            $hImage = _GDIPlus_ImageLoadFromFile("c:\MAIN3.png")
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            GUIRegisterMsg($WM_PAINT, "_MY_WM_PAINT")

            GUISetState()


            #cs ----------------------------------------------------------------------------
                Case statements for the individual dynamic fields
            #ce ----------------------------------------------------------------------------
        Case $TestType_field
            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)
            Switch $TestType_data
                Case "Import Rates to Pending"
                    GUIDelete($ControlGUI)
                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x2 + 10, $y2 + 45, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 45, 170, 20, $ES_UPPERCASE)
                    $RefDefFileLocation_label = GUICtrlCreateLabel("Reference File", $x2 + 630, $y2 + 45, 90, 15)
                    $RefDefFileLocation_field = GUICtrlCreateCombo("", $x2 + 730, $y2 + 45, 170, 20)

                    ; COLLECT REF FILES IN ARRARY
                    $RefDefIniFileList_array = _FileListToArray(@ScriptDir & "\Reference Files\", "*.ini", 1)

                    ; Add Entries to the Reference field
                    If @error = 0 Then
                        For $e = 1 To $RefDefIniFileList_array[0]
                            $RefDefCombo_Insert_Name = StringTrimRight($RefDefIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($RefDefFileLocation_field, $RefDefCombo_Insert_Name)
                        Next
                    EndIf
                    $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x2 + 10, $y2 + 80, 90, 15)
                    $ImportFileLocation_field = GUICtrlCreateCombo("", $x2 + 110, $y2 + 80, 170, 20)

                    ; GET ALL INI FILES IN THE IMPORT FOLDER IN AN ARRAY
                    $ImportIniFileList_array = _FileListToArray(@ScriptDir & "\Import Files\", "*.ini", 1)
                    ; Add Entries to the Import field
                    If @error = 0 Then
                        For $e = 1 To $ImportIniFileList_array[0]
                            $ImportCombo_Insert_Name = StringTrimRight($ImportIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($ImportFileLocation_field, $ImportCombo_Insert_Name)
                        Next
                    EndIf

                    ; DATES
                    $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x2 + 320, $y2 + 80, 90, 20)
                    $IncrDate_datefield = GUICtrlCreateDate("", $x2 + 420, $y2 + 80, 170, 20)
                    $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
                    _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")
                    $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x2 + 630, $y2 + 80, 90, 20)
                    $DecrDate_datefield = GUICtrlCreateDate("", $x2 + 730, $y2 + 80, 170, 20)
                    $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
                    _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")
                    GUISetState()
                Case "Import Rates to Active"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x2 + 10, $y2 + 45, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 45, 170, 20, $ES_UPPERCASE)
                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x2 + 320, $y2 + 45, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x2 + 420, $y2 + 45, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Don't Autoexpire Old Data|Autoexpire Old Data", "Don't Autoexpire Old Data")
                    $RefDefFileLocation_label = GUICtrlCreateLabel("Reference File", $x2 + 630, $y2 + 45, 90, 15)
                    $RefDefFileLocation_field = GUICtrlCreateCombo("", $x2 + 730, $y2 + 45, 170, 20)

                    ; COLLECT REF FILES IN ARRARY
                    $RefDefIniFileList_array = _FileListToArray(@ScriptDir & "\Reference Files\", "*.ini", 1)

                    ; Add Entries to the Reference field
                    If @error = 0 Then
                        For $e = 1 To $RefDefIniFileList_array[0]
                            $RefDefCombo_Insert_Name = StringTrimRight($RefDefIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($RefDefFileLocation_field, $RefDefCombo_Insert_Name)
                        Next
                    EndIf
                    $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x2 + 10, $y2 + 80, 90, 15)
                    $ImportFileLocation_field = GUICtrlCreateCombo("", $x2 + 110, $y2 + 80, 170, 20)

                    ; ADD FILES FROM IMPORT FOLDER TO ARRAY
                    $ImportIniFileList_array = _FileListToArray(@ScriptDir & "\Import Files\", "*.ini", 1)

                    ; Add Entries to the Import field
                    If @error = 0 Then
                        For $e = 1 To $ImportIniFileList_array[0]
                            $ImportCombo_Insert_Name = StringTrimRight($ImportIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($ImportFileLocation_field, $ImportCombo_Insert_Name)
                        Next
                    EndIf

                    ; DATES
                    $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x2 + 320, $y2 + 80, 90, 20)
                    $IncrDate_datefield = GUICtrlCreateDate("", $x2 + 420, $y2 + 80, 170, 20)
                    $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
                    _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")
                    $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x2 + 630, $y2 + 80, 90, 20)
                    $DecrDate_datefield = GUICtrlCreateDate("", $x2 + 730, $y2 + 80, 170, 20)
                    $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
                    _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")
                    GUISetState()
                Case "Edit Carrier Rates"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x2 + 10, $y2 + 45, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 45, 170, 20, $ES_UPPERCASE)
                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x2 + 320, $y2 + 45, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x2 + 420, $y2 + 45, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Refresh Grid|Edit Entry|Delete Entry|Clear All", "Refresh Grid")
                    $RefDefFileLocation_label = GUICtrlCreateLabel("Reference File", $x2 + 630, $y2 + 45, 90, 15)
                    $RefDefFileLocation_field = GUICtrlCreateCombo("", $x2 + 730, $y2 + 45, 170, 20)

                    ; COLLECT REF FILES IN ARRARY
                    $RefDefIniFileList_array = _FileListToArray(@ScriptDir & "\Reference Files\", "*.ini", 1)

                    ; Add Entries to the Reference field
                    If @error = 0 Then
                        For $e = 1 To $RefDefIniFileList_array[0]
                            $RefDefCombo_Insert_Name = StringTrimRight($RefDefIniFileList_array[$e], 4)
                            _GUICtrlComboBox_InsertString($RefDefFileLocation_field, $RefDefCombo_Insert_Name)
                        Next
                    EndIf

                    ; DETAILS FIELDS
                    $Destnination_label = GUICtrlCreateLabel("Destination Name", $x2 + 10, $y2 + 110, 90, 15)
                    $Destnination_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 110, 170, 20)
                    $DialCode_label = GUICtrlCreateLabel("Dial Code", $x2 + 320, $y2 + 110, 90, 15)
                    $DialCode_field = GUICtrlCreateInput("", $x2 + 420, $y2 + 110, 170, 20, $ES_NUMBER)
                    $Rate_label = GUICtrlCreateLabel("Rate", $x2 + 630, $y2 + 110, 90, 15)
                    $Rate_field = GUICtrlCreateInput("", $x2 + 730, $y2 + 110, 170, 20, $ES_NUMBER)

                    ; CHECKBOXED DATE
                    $tDate = 0
                    $EffDate_label = GUICtrlCreateLabel("Use Effective Date", $x2 + 320, $y2 + 140, 90, 20)
                    $EffDate_datefield = GUICtrlCreateDate("", $x2 + 420, $y2 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
                    $EffDate_handle = GUICtrlGetHandle($EffDate_datefield)
                    _GUICtrlDTP_SetFormat($EffDate_handle, "ddd, dd/MMM/yy")
                    _GUICtrlDTP_SetSystemTimeEx($EffDate_handle, $tDate, True)
                    $ExpDate_label = GUICtrlCreateLabel("Use Expiry Date", $x2 + 630, $y2 + 140, 90, 20)
                    $ExpDate_datefield = GUICtrlCreateDate("", $x2 + 730, $y2 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
                    $ExpDate_handle = GUICtrlGetHandle($ExpDate_datefield)
                    _GUICtrlDTP_SetFormat($ExpDate_handle, "ddd, dd/MMM/yy")
                    _GUICtrlDTP_SetSystemTimeEx($ExpDate_handle, $tDate, True)
                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")

                    ;RESET THE TEST TYPE TO INITIAL CHOICE
                    ControlSend("Optima Rate Import Test Case Creator", "Test Type", $TestType_field, "i")
                Case "Add Analysis Stage"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)
                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x2 + 320, $y2 + 45, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x2 + 420, $y2 + 45, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Run All Scripts|Run Script A001|Run Script A002|Run Script A003|Run Script A004|", "Run All Scripts")
                    GUISetState()
                Case "Run SQL File"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)
                    $ServerDetails_label = GUICtrlCreateLabel("Server Details Name", $x2 + 10, $y2 + 170, 90, 15)
                    $ServerDetails_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 170, 170, 20)
                    $UidPass_label = GUICtrlCreateLabel("User Id/Password", $x2 + 320, $y2 + 170, 90, 15)
                    $UidPass_field = GUICtrlCreateInput("", $x2 + 420, $y2 + 170, 170, 20)
                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")

                    ;RESET THE TEST TYPE TO INITIAL CHOICE
                    ControlSend("Optima Rate Import Test Case Creator", "Test Type", $TestType_field, "i")
                Case "Run Win Batch File"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 1090, 230, $x2, $y2, $WS_CHILD, -1, $MainImportGUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreateGroup("Please set the Test Case parameters", $x2, 0, 910, 230)
                    $ServerDetails_label = GUICtrlCreateLabel("Server Details Name", $x2 + 10, $y2 + 170, 90, 15)
                    $ServerDetails_field = GUICtrlCreateInput("", $x2 + 110, $y2 + 170, 170, 20)
                    $UidPass_label = GUICtrlCreateLabel("User Id/Password", $x2 + 320, $y2 + 170, 90, 15)
                    $UidPass_field = GUICtrlCreateInput("", $x2 + 420, $y2 + 170, 170, 20)
                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")

                    ;RESET THE TEST TYPE TO INITIAL CHOICE
                    ControlSend("Optima Rate Import Test Case Creator", "Test Type", $TestType_field, "i")
            EndSwitch

            #cs ----------------------------------------------------------------------------
                Case Statements for the action buttons
            #ce ----------------------------------------------------------------------------

        Case $AddtoBatch_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")
            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)
            $TestCaseStatus_data = ""
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)
            $OverallResult_data = "Queued"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)
            $TCName_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Case Name", $TCName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)
            $TCPassNo_data = ControlGetText("Optima Rate Import Test Case Creator", "Pass Number", $TCPassNo_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)
            $CarrierName_data = ControlGetText("Optima Rate Import Test Case Creator", "Carrier Name", $CarrierName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)
            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)
            $AdditionalDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "Additional Details", $AdditionalDetails_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)
            $ServerDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "Server Details Name", $ServerDetails_field)
            If @error = 1 Then
                IniWrite($ProfilesINI, $SectionNumber_data, "Server Details", "")
            Else
                IniWrite($ProfilesINI, $SectionNumber_data, "Server Details", $ServerDetails_data)
            EndIf
            $IncrDate_data = GUICtrlRead($IncrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)
            $DecrDate_data = GUICtrlRead($DecrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)
            $Destnination_data = ControlGetText("Optima Rate Import Test Case Creator", "Destination Nam", $Destnination_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)
            $DialCode_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $DialCode_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)
            $UidPass_data = ControlGetText("Optima Rate Import Test Case Creator", "User Id/Password", $UidPass_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)
            $Rate_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $Rate_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)
            $EffDate_data = GUICtrlRead($EffDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)
            $ExpDate_data = GUICtrlRead($ExpDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)
            $ImportFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Import File", $ImportFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $ImportFileLocation_data)
            $RefDefFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Reference File", $RefDefFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDefFileLocation_data)
            _RefreshGridData()
        Case $RemFromGrid_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            If $SelectedRow > 1 Then
                $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
                $Ini_Section_delete = $Grid_listdata_sections[$SelectedRow]
                IniDelete($ProfilesINI, $Ini_Section_delete)
                For $c = $Grid_listdata_sections[$SelectedRow] To $Grid_listdata_sections[0]
                    IniRenameSection($ProfilesINI, $Grid_listdata_sections[$c], $Grid_listdata_sections[$c] - 1)
                Next
            EndIf
            _RefreshGridData()
        Case $MoveUp_button
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow > 1 Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Above_section = $Grid_listdata_sections[$SelectedRow - 1]
                $temp = 9999999
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Above_section, $Grid_listdata_sections[$SelectedRow])
                IniRenameSection($ProfilesINI, $temp, $Grid_listdata_sections[$SelectedRow - 1])
            EndIf
            _RefreshGridData()
        Case $MoveDown_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow < $Grid_listdata_sections[0] Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Below_section = $Grid_listdata_sections[$SelectedRow + 1]
                MsgBox(0, $Selected_section, $Below_section)
                $temp = "xxx"
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Below_section, $Selected_section)
                IniRenameSection($ProfilesINI, $temp, $Below_section)
            EndIf
            _RefreshGridData()
        Case $AddSeparator_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")
            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)
            $TestCaseStatus_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)
            $OverallResult_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)
            $TCName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)
            $TCPassNo_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)
            $CarrierName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)
            $TestType_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)
            $AdditionalDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)
            $ServerDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "Server Details", $ServerDetails_data)
            $AutoExpire_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "AUTOEXPIRE", $AutoExpire_data)
            $IncrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)
            $DecrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)
            $Destnination_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)
            $DialCode_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)
            $UidPass_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)
            $Rate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)
            $EffDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)
            $ExpDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)
            $ImportFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $ImportFileLocation_data)
            $RefDefFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDefFileLocation_data)
            _RefreshGridData()
        Case $GridToFile_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $ProfilesIniFileList_array = _FileListToArray(@ScriptDir & "\Profiles\", "*.ini", 1)
;~ MsgBox(0,"",$ProfilesINI)
            $ProfilesINI_NewName = FileSaveDialog("Save the Grid data to an INI File", @ScriptDir & "\Profiles", "INI Files (*.ini)", 16, "Profile Number " & $ProfilesIniFileList_array[0])
;~ MsgBox(0,"",$ProfilesINI_NewName)
            FileCopy($ProfilesINI, $ProfilesINI_NewName & ".ini")
            $ProfilesINI_OnlyFileName = _PathSplit($ProfilesINI_NewName & ".ini", $szDrive, $szDir, $szFName, $szExt)
            MsgBox(8192, "Task Update", "The grid data has been saved to the File: " & $szFName & $szExt)
            _RefreshTabBar()
            $iIndex = _GUICtrlTab_FindTab($Tab_TCSuite, $szFName)
            _GUICtrlTab_ClickTab($Tab_TCSuite, $iIndex)
        Case $RunBatch_button
            ; First set all the ini file statuses to Pending.
            ; Refrsh Grid
            ; Pass over Control to Main


            #cs ----------------------------------------------------------------------------
                Case statements for the major components
            #ce ----------------------------------------------------------------------------
        Case $msg = $Tab_TCSuite
            $current = _GUICtrlTab_GetCurSel($Tab_TCSuite)
            $Tab_Name = _GUICtrlTab_GetItemText($Tab_TCSuite, $current)
            $ProfilesINI = @ScriptDir & "\Profiles\" & $Tab_Name & ".ini"
            ; This here is a temp solution to stop the contineous refrsh problem.
            If $current <> $GenericTempValue Then
                _RefreshGridData()
            EndIf
            $GenericTempValue = $current

            #cs ----------------------------------------------------------------------------
                Case statements for screen closure
            #ce ----------------------------------------------------------------------------
        Case $GUI_EVENT_CLOSE
            If $msg[1] = $AboutScreen_GUI Then
                GUIDelete($AboutScreen_GUI)
                $AboutScreen_GUI = 0
            Else
                SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
                GUIDelete($MainGUI)
                Exit
            EndIf

    EndSwitch
WEnd

#cs -----------------------------------------------------------------------------------------------------------------

    Functions

#CE -----------------------------------------------------------------------------------------------------------------


; FUNCTION TO REFRESH THE GRID DATA
Func _RefreshGridData()
    $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
    If @error Then
        _GUICtrlListView_DeleteAllItems($BatchList_handle)
    ElseIf $Grid_listdata_sections[0] > 0 Then
        _GUICtrlListView_BeginUpdate($BatchList_handle)
        _GUICtrlListView_DeleteAllItems($BatchList_handle)
        For $a = 1 To $Grid_listdata_sections[0]

;~ _ArrayDisplay($Grid_listdata_sections)
            _ArraySort($Grid_listdata_sections, 0, 1)
;~ _ArrayDisplay($Grid_listdata_sections)
            $Grid_All_listdata = IniReadSection($ProfilesINI, $Grid_listdata_sections[$a])
            If Not @error Then
                If $Grid_All_listdata[0][0] > 0 Then
                    _GUICtrlListView_AddItem($BatchList_handle, $a)
                    _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_listdata_sections[$a], 1)
                    For $b = 2 To $Grid_All_listdata[0][0]
                        _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_All_listdata[$b][1], $b + 1)
                    Next
                EndIf
            EndIf
        Next
        For $a = 0 To _GUICtrlListView_GetColumnCount($BatchList_handle)
            _GUICtrlListView_SetColumnWidth($BatchList_handle, $a, $LVSCW_AUTOSIZE_USEHEADER)
        Next
        _GUICtrlListView_EndUpdate($BatchList_handle)
    EndIf
EndFunc   ;==>_RefreshGridData

;~ -----------------------------------------------------------------------------------------------------------------
; FUNCTION TO REFRESH THE TAB BAR
Func _RefreshTabBar()
    ; DELETE ALL CURRENT TAB ITEMS SO THAT THE TAB BAR CAN BE RECREATED
    _GUICtrlTab_DeleteAllItems($Tab_TCSuite)

    ; GET ALL INI FILES IN THE PROFILES FOLDER IN AN ARRAY
    $ProfilesIniFileList_array = _FileListToArray(@ScriptDir & "\Profiles\", "*.ini", 1)

    ; CREATE THE DEFAULT TAB
    _GUICtrlTab_InsertItem($Tab_TCSuite, 0, "NEW PROFILE")

    ; ADD TABS TO TAB BAR BASED ON THE $IniFileList_array DATA
    If @error = 0 Then
        For $d = 1 To $ProfilesIniFileList_array[0]
            If $ProfilesIniFileList_array[$d] <> "NEW PROFILE.ini" Then
                $Tab_Insert_Name = StringTrimRight($ProfilesIniFileList_array[$d], 4)
                _GUICtrlTab_InsertItem($Tab_TCSuite, $d, $Tab_Insert_Name)
            EndIf
        Next
    EndIf
EndFunc   ;==>_RefreshTabBar


;~ -----------------------------------------------------------------------------------------------------------------
; CREATE THE ABOUT SCREEN WHICH WILL BE LAUCHED BY USING F1
Func _AboutScreen()
    $AboutScreen_GUI = GUICreate("About Automata v0.1 alpha", 500, 300, -1, -1)
    $AboutScreen_label = GUICtrlCreateLabel("Rishav is having his pet gnomes slug it out on a worthwhile About screen - in his infernal dungeon which incidentally is surrounded by miles of lava fields. " & @LF & "That, or he is being lazy. Have patience. One day hitting F1 will bear fruits.", 50, 100, 390, 200)
    GUICtrlSetFont($AboutScreen_label, 12)
    GUISetState()
EndFunc   ;==>_AboutScreen

;~ -----------------------------------------------------------------------------------------------------------------
; CREATE FUNCTION TO DEPRESS THE MODULE BUTTONS AND CREATE RESPECTIVE GUIs
Func _ChangeModules($ClickedModule_button)
    GUICtrlSetState($Welcome_Module_button, $GUI_ENABLE)
    GUICtrlSetState($Setup_Module_button, $GUI_ENABLE)
    GUICtrlSetState($Smoke_Module_button, $GUI_ENABLE)
    GUICtrlSetState($Import_Module_button, $GUI_ENABLE)
    GUICtrlSetState($System_Module_button, $GUI_ENABLE)
    GUICtrlSetState($Summary_Module_button, $GUI_ENABLE)

    GUICtrlSetState($ClickedModule_button, $GUI_DISABLE)



;~  GUIDelete($MainImportGUI)
;~  GUIDelete($MainWelcomeGUI)
EndFunc   ;==>_ChangeModules

; Draw PNG image
Func _MY_WM_PAINT($hWnd, $msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_MY_WM_PAINT
Edited by Rishav
Link to comment
Share on other sites

Here, something nice. I'm sure there must be a much appropriate way to do this:

#include <GDIPlus.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()

Global Const $ODT_TAB           = 101
Global Const $ODA_DRAWENTIRE    = 1
Global Const $ODA_SELECT        = 2
Global Const $ODA_FOCUS         = 4
Global Const $ODS_SELECTED      = 1
Global Const $ODS_GRAYED        = 2
Global Const $ODS_DISABLED      = 4
Global Const $ODS_CHECKED       = 8
Global Const $ODS_FOCUS         = 16
Global Const $ODS_DEFAULT       = 32
Global Const $ODS_HOTLIGHT      = 64
Global Const $ODS_INACTIVE      = 128
Global Const $ODS_NOACCEL       = 256
Global Const $ODS_NOFOCUSRECT   = 512
Global Const $ODS_COMBOBOXEDIT  = 4096
Global Const $iAngle = 270
Global Const $iPI = 4 * ATan(1)

Global Const $tagDRAWITEMSTRUCT = _
    'uint CtlType;' & _
    'uint CtlID;' & _
    'uint itemID;' & _
    'uint itemAction;' & _
    'uint itemState;' & _
    'hwnd hwndItem;' & _
    'hwnd hDC;' & _
    $tagRECT & _
    ';ulong_ptr itemData;'

    
Global $hGUI, $TabCtrl, $aTabItems[10], $sItems[10]

$hGUI = GUICreate('Test', 400, 400)
$TabCtrl = GUICtrlCreateTab(0, 0, 400, 400, BitOR($WS_CHILD, $TCS_FORCEICONLEFT, $TCS_VERTICAL, $TCS_MULTILINE, $TCS_OWNERDRAWFIXED))
GUICtrlSendMsg($TabCtrl, $TCM_SETITEMSIZE, 0, BitOR(50, BitShift(50, -16)))

For $i = 0 To UBound($aTabItems) -1
    $sItems[$i] = 'Item ' & $i+1
    $aTabItems[$i] = GUICtrlCreateTabItem($sItems[$i])
    GUICtrlCreateButton('Button of Tab '  & $i+1, 150, 20, 100, 23)
Next

GUIRegisterMsg($WM_DRAWITEM, '_WM_DRAWITEM')
GUISetState()

Do
Until GUIGetMsg() = -3

GUIDelete()
_GDIPlus_Shutdown()
Exit

Func _WM_DRAWITEM($hWnd, $iMsg, $iwParam, $ilparam)
    Local $tDIS = DllStructCreate($tagDRAWITEMSTRUCT, $ilparam)
    Local $tRect = DllStructCreate($tagRECT)
    Local $hDC, $hGraphics, $hMatrix
    Local $iItem
    
    If DllStructGetData($tDIS, 'CtlType') = $ODT_TAB And DllStructGetData($tDIS, 'itemAction') = $ODA_DRAWENTIRE Then
        $hDC = DllStructGetData($tDIS, 'hDC')
        $iItem = DllStructGetData($tDIS, 'itemID')

        For $i = 8 To 11
            DllStructSetData($tRect, $i-7, DllStructGetData($tDIS, $i))
        Next
        DllStructSetData($tRect, 'Top', DllStructGetData($tRect, 'Top') + 30)
        DllStructSetData($tRect, 'Left', DllStructGetData($tRect, 'Left') + 5)
        
        $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC)
        $hMatrix = _GDIPlus_MatrixCreate()
        _GDIPlus_MatrixRotate($hMatrix, $iAngle)
        _GDIPlus_GraphicsSetTransform($hGraphics, $hMatrix)
        
        VString($sItems[$iItem], DllStructGetData($tRect, 'Left'), DllStructGetData($tRect, 'Top'), 10, $iAngle, $hGraphics)
        
        _GDIPlus_MatrixDispose($hMatrix)
        _GDIPlus_GraphicsDispose($hGraphics)
    EndIf
    Return 'GUI_RUNDEFMSG'
EndFunc




; http://www.autoitscript.com/forum/index.php?showtopic=93289&st=0&p=670844
; Malkey and the crowd.
Func VString($txt, $nx, $ny, $size, $iAngle, $hGraph)
    ;draw string with x,y = upper left corner
    ;Rotation of Coordinate Axes formulae
    $nXt = $nx * Cos($iAngle * $iPI / 180) + $ny * Sin($iAngle * $iPI / 180) ; $nXt - X coordinate before translation
    $nYt = -$nx * Sin($iAngle * $iPI / 180) + $ny * Cos($iAngle * $iPI / 180) ; $nYt - Y coordinate before translation
    _GDIPlus_GraphicsDrawString($hGraph, $txt, $nXt, $nYt, "Arial", $size, 0x0002)
EndFunc   ;==>VString
Link to comment
Share on other sites

Here, something nice. I'm sure there must be a much appropriate way to do this:

#include <GDIPlus.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()

Global Const $ODT_TAB           = 101
Global Const $ODA_DRAWENTIRE    = 1
Global Const $ODA_SELECT        = 2
Global Const $ODA_FOCUS         = 4
Global Const $ODS_SELECTED      = 1
Global Const $ODS_GRAYED        = 2
Global Const $ODS_DISABLED      = 4
Global Const $ODS_CHECKED       = 8
Global Const $ODS_FOCUS         = 16
Global Const $ODS_DEFAULT       = 32
Global Const $ODS_HOTLIGHT      = 64
Global Const $ODS_INACTIVE      = 128
Global Const $ODS_NOACCEL       = 256
Global Const $ODS_NOFOCUSRECT   = 512
Global Const $ODS_COMBOBOXEDIT  = 4096
Global Const $iAngle = 270
Global Const $iPI = 4 * ATan(1)

Global Const $tagDRAWITEMSTRUCT = _
    'uint CtlType;' & _
    'uint CtlID;' & _
    'uint itemID;' & _
    'uint itemAction;' & _
    'uint itemState;' & _
    'hwnd hwndItem;' & _
    'hwnd hDC;' & _
    $tagRECT & _
    ';ulong_ptr itemData;'

    
Global $hGUI, $TabCtrl, $aTabItems[10], $sItems[10]

$hGUI = GUICreate('Test', 400, 400)
$TabCtrl = GUICtrlCreateTab(0, 0, 400, 400, BitOR($WS_CHILD, $TCS_FORCEICONLEFT, $TCS_VERTICAL, $TCS_MULTILINE, $TCS_OWNERDRAWFIXED))
GUICtrlSendMsg($TabCtrl, $TCM_SETITEMSIZE, 0, BitOR(50, BitShift(50, -16)))

For $i = 0 To UBound($aTabItems) -1
    $sItems[$i] = 'Item ' & $i+1
    $aTabItems[$i] = GUICtrlCreateTabItem($sItems[$i])
    GUICtrlCreateButton('Button of Tab '  & $i+1, 150, 20, 100, 23)
Next

GUIRegisterMsg($WM_DRAWITEM, '_WM_DRAWITEM')
GUISetState()

Do
Until GUIGetMsg() = -3

GUIDelete()
_GDIPlus_Shutdown()
Exit

Func _WM_DRAWITEM($hWnd, $iMsg, $iwParam, $ilparam)
    Local $tDIS = DllStructCreate($tagDRAWITEMSTRUCT, $ilparam)
    Local $tRect = DllStructCreate($tagRECT)
    Local $hDC, $hGraphics, $hMatrix
    Local $iItem
    
    If DllStructGetData($tDIS, 'CtlType') = $ODT_TAB And DllStructGetData($tDIS, 'itemAction') = $ODA_DRAWENTIRE Then
        $hDC = DllStructGetData($tDIS, 'hDC')
        $iItem = DllStructGetData($tDIS, 'itemID')

        For $i = 8 To 11
            DllStructSetData($tRect, $i-7, DllStructGetData($tDIS, $i))
        Next
        DllStructSetData($tRect, 'Top', DllStructGetData($tRect, 'Top') + 30)
        DllStructSetData($tRect, 'Left', DllStructGetData($tRect, 'Left') + 5)
        
        $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC)
        $hMatrix = _GDIPlus_MatrixCreate()
        _GDIPlus_MatrixRotate($hMatrix, $iAngle)
        _GDIPlus_GraphicsSetTransform($hGraphics, $hMatrix)
        
        VString($sItems[$iItem], DllStructGetData($tRect, 'Left'), DllStructGetData($tRect, 'Top'), 10, $iAngle, $hGraphics)
        
        _GDIPlus_MatrixDispose($hMatrix)
        _GDIPlus_GraphicsDispose($hGraphics)
    EndIf
    Return 'GUI_RUNDEFMSG'
EndFunc




; http://www.autoitscript.com/forum/index.php?showtopic=93289&st=0&p=670844
; Malkey and the crowd.
Func VString($txt, $nx, $ny, $size, $iAngle, $hGraph)
    ;draw string with x,y = upper left corner
    ;Rotation of Coordinate Axes formulae
    $nXt = $nx * Cos($iAngle * $iPI / 180) + $ny * Sin($iAngle * $iPI / 180) ; $nXt - X coordinate before translation
    $nYt = -$nx * Sin($iAngle * $iPI / 180) + $ny * Cos($iAngle * $iPI / 180) ; $nYt - Y coordinate before translation
    _GDIPlus_GraphicsDrawString($hGraph, $txt, $nXt, $nYt, "Arial", $size, 0x0002)
EndFunc   ;==>VString

thanks Authenticity. that is some neat code. most of it goes over my head though. >_< I will go through it and try and see if i can use it in my UI.

But my problem is not with the tabs themselves. its with the creating and deletion of GUIs.

every time i click a tab, using that event, i will create an appropriate child Ui (with different controls and fields). so every time i click a tab, i have to delete all existing child GUIs and create a new one. and thats where i am stuck. :/

anway, thanks a ton again for taking the time.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...