How to create "TScrollBox" and "TRadioButton".

TheyCallMeTim13

Wiki Monster
Talents
Fearless Donors
Mar 3, 2017
418
46
28
#1
@corroder posted a script on CEF and I found it to be neat and did some messing around came up with a script, but now I need to figure out how to script the createion of "TScrollBox" and "TRadioButton" classes (I could just use "createClass" but wanted to see if I could find a standard constructor first). But I don't create trainers and I'm not finding much in the "celua.txt" file for these classes.

This code coverts a CE form into a Lua script.

Lua:
local format = string.format
local strE = string.empty or STRING_EMPTY or ''
local t = translate


local LineEnd = '\r\n'

local StringDel = { '\'', '\'' }
local controlPropertyList = {
    Tag = true,
    Left = true,
    Height = true,
    Hint = true,
    Top = true,
    Width = true,
    HelpType = true,
    HelpKeyword = true,
    HelpContext = true,
    Align = true,
    AllowDropFiles = true,
    AlphaBlend = true,
    AlphaBlendValue = true,
    Anchors = true,
    AutoScroll = true,
    AutoSize = true,
    BiDiMode = true,
    BorderIcons = true,
    BorderStyle = true,
    BorderWidth = true,
    Caption = true,
    ClientHeight = true,
    ClientWidth = true,
    Color = true,
    Constraints = true,
    MaxWidth = true,
    MinHeight = true,
    MinWidth = true,
    DefaultMonitor = true,
    DockSite = true,
    DragKind = true,
    DragMode = true,
    Font = true,
    Name = true,
    Orientation = true,
    Pitch = true,
    Quality = true,
    Size = true,
    Style = true,
    FormStyle = true,
    KeyPreview = true,
    Menu = true,
    ParentBiDiMode = true,
    ParentFont = true,
    PixelsPerInch = true,
    PopupMenu = true,
    Position = true,
    ShowInTaskBar = true,
    Visible = true,
    WindowState = true,
    DoNotSaveInTable = true,
    BidiMode = true,
    BorderSpacing = true,
    Cancel = true,
    Default = true,
    Enabled = true,
    ModalResult = true,
    ParentShowHint = true,
    ShowHint = true,
    TabOrder = true,
    TabStop = true,
    Alignment = true,
    Layout = true,
    ParentBidiMode = true,
    ParentColor = true,
    ShowAccelChar = true,
    Transparent = true,
    WordWrap = true,
    OptimalFill = true,
    AllowGrayed = true,
    Checked = true,
    DragCursor = true,
    State = true,
    AutoFill = true,
    ColumnLayout = true,
    ItemIndex = true,
    ClickOnSelChange = true,
    ExtendedSelect = true,
    IntegralHeight = true,
    ItemHeight = true,
    MultiSelect = true,
    Sorted = true,
    TopIndex = true,
    ArrowKeysTraverseList = true,
    AutoComplete = true,
    AutoCompleteText = true,
    AutoDropDown = true,
    AutoSelect = true,
    CharCase = true,
    DropDownCount = true,
    ItemWidth = true,
    MaxLength = true,
    ReadOnly = true,
    Text = true,
    Max = true,
    Min = true,
    Smooth = true,
    Step = true,
    BarShowText = true,
    Frequency = true,
    LineSize = true,
    PageSize = true,
    Reversed = true,
    ScalePos = true,
    SelEnd = true,
    SelStart = true,
    ShowSelRange = true,
    TickMarks = true,
    TickStyle = true,
    AutoExpand = true,
    BackgroundColor = true,
    DefaultItemHeight = true,
    ExpandSignColor = true,
    ExpandSignType = true,
    HideSelection = true,
    HotTrack = true,
    Indent = true,
    MultiSelectStyle = true,
    RightClickSelect = true,
    RowSelect = true,
    ScrollBars = true,
    SelectionColor = true,
    SelectionFontColor = true,
    SelectionFontColorUsed = true,
    SeparatorColor = true,
    ShowButtons = true,
    ShowLines = true,
    ShowRoot = true,
    SortType = true,
    StateImages = true,
    ToolTips = true,
    Options = true,
    TreeLineColor = true,
    TreeLinePenStyle = true,
    AllocBy = true,
    AutoSort = true,
    Checkboxes = true,
    ColumnClick = true,
    OwnerData = true,
    ShowColumnHeaders = true,
    SortColumn = true,
    SortDirection = true,
    ViewStyle = true,
    BevelInner = true,
    BevelOuter = true,
    BevelWidth = true,
    FullRepaint = true,
    UseDockManager = true,
    AutoSnap = true,
    Beveled = true,
    MinSize = true,
    ResizeAnchor = true,
    ResizeStyle = true,
    Center = true,
    Proportional = true,
    Stretch = true,
    -------------------------
    AnchorSideLeft = false,
    AnchorSideTop = false,
    AnchorSideRight = false,
    AnchorSideBottom = false,
    HorzScrollBar = false,
    VertScrollBar = false,
    ChildSizing = false,
    Cursor = false,
    Icon = false,
    IconOptions = false,
    Picture = false,
    Images = false,
    Columns = false,
    Items = false,
}
local controlPropertyStrings = {
    Name = true,
    Hint = true,
    HelpKeyword = true,
    Caption = true,
    Anchors = true,
    BorderIcons = true,
    Style = true,
    AutoCompleteText = true,
    MultiSelectStyle = true,
    Options = true,
}
local controlPropertyGroups = {
    Font = true,
    Constraints = true,
    BorderSpacing = true,
}

local controlCreators = {
    TRadioButton = 'createRadioGroup',
}

local usedKeys = {}
local printUnusedKeys = false


local function getCreator(control)
    ---- Could use 'createClass'
    local action = 'create' .. control.ClassName:gsub('TCE', strE)
    if controlCreators[control.ClassName] then
        action = controlCreators[control.ClassName]
    end
    local call = '()'
    if control.Parent ~= nil then
        call = format('(%s)', control.Parent.Name)
    end
    return action .. call
end

local function getPropertiesScript(control, parentStr)
    local script = strE
    local pl = getPropertyList(control)
    if pl then
        for i = 1, pl.Count - 1 do
            if controlPropertyGroups[pl[i]] then
                script = script .. getPropertiesScript(control[pl[i]], format('%s.%s', parentStr, pl[i]))
            elseif controlPropertyList[pl[i]] then
                if control[pl[i]] ~= nil then
                    local v = control[pl[i]]
                    if controlPropertyStrings[pl[i]] then
                        v = format('%s%s%s', StringDel[1], v, StringDel[2])
                    end
                    script = script .. format('%s.%s = %s', parentStr, pl[i], v) .. LineEnd
                end
            else
                if printUnusedKeys and not usedKeys[pl[i]]
                and controlPropertyList[pl[i]] ~= false then
                    usedKeys[pl[i]] = true
                    print(format('---- Key Not Used: "%s"', pl[i]))
                end
            end
        end
    end
    return script
end

local function getControlComponentScript(control)
    local script = strE
    if control.ControlCount ~= nil then
        for i = 0, control.ComponentCount - 1 do
            if control.Component[i].ClassName ~= 'TJvDesignHandle' then
                script = script .. '--' .. LineEnd .. '---- ' .. control.Component[i].Name .. LineEnd
                script = script .. '--------------------' .. LineEnd
                script = script .. format('%s = %s', control.Component[i].Name, getCreator(control.Component[i])) .. LineEnd
                script = script .. getPropertiesScript(control.Component[i], control.Component[i].Name)
                if control.Component[i].ComponentCount then
                    script = script .. getControlComponentScript(control.Component[i])
                end
                script = script .. '--------------------' .. LineEnd
            end
        end
    end
    return script
end

local function getControlScript(control)
    local parentStr = control.Name
    local script = '--' .. LineEnd .. '----' .. LineEnd .. '---- FORM: ' .. control.Name .. LineEnd
    script = script .. '------------------------------' .. LineEnd
    script = script .. format('%s = %s', parentStr, getCreator(control)) .. LineEnd
    script = script .. getPropertiesScript(control, parentStr)
    script = script .. '------------------------------' .. LineEnd
    script = script .. '---- ' .. control.Name .. ' : Components' .. LineEnd
    script = script .. '------------------------------' .. LineEnd
    script = script .. getControlComponentScript(control)
    script = script .. '------------------------------' .. LineEnd
    script = script .. '---- END FORM: ' .. control.Name .. LineEnd .. '---- ' .. LineEnd .. '--' .. LineEnd
    return script
end

function CEForm2Lua(form, noPrint)
    local vis = form.Visible
    form.Visible = true
    local s = getControlScript(form)
    form.Visible = vis
    if not noPrint then
        print(s)
    end
    return s
end
CEA:
CEForm2Lua(UDF1)
Example output:
Lua:
--
---- UDF1
UDF1 = createForm()
UDF1.Tag = 0
UDF1.Left = 321
UDF1.Height = 458
UDF1.Hint = ''
UDF1.Top = 93
UDF1.Width = 728
UDF1.HelpType = htContext
UDF1.HelpKeyword = ''
UDF1.HelpContext = 0
UDF1.Align = alNone
UDF1.AllowDropFiles = false
UDF1.AlphaBlend = false
UDF1.AlphaBlendValue = 255
UDF1.Anchors = '[akTop,akLeft]'
UDF1.AutoScroll = false
UDF1.AutoSize = false
UDF1.BiDiMode = bdLeftToRight
UDF1.BorderIcons = '[biSystemMenu,biMinimize,biMaximize]'
UDF1.BorderStyle = bsSizeable
UDF1.BorderWidth = 0
UDF1.Caption = 'UDF1'
UDF1.ClientHeight = 458
UDF1.ClientWidth = 728
UDF1.Color = 536870912
UDF1.Constraints.MaxWidth = 0
UDF1.Constraints.MinHeight = 0
UDF1.Constraints.MinWidth = 0
UDF1.DefaultMonitor = dmActiveForm
UDF1.DockSite = false
UDF1.DragKind = dkDrag
UDF1.DragMode = dmManual
UDF1.Font.Color = 536870912
UDF1.Font.Height = -13
UDF1.Font.Name = 'Lucida Console'
UDF1.Font.Orientation = 0
UDF1.Font.Pitch = fpFixed
UDF1.Font.Quality = fqDefault
UDF1.Font.Size = 10
UDF1.Font.Style = '[]'
UDF1.FormStyle = fsNormal
UDF1.KeyPreview = false
UDF1.ParentBiDiMode = true
UDF1.ParentFont = false
UDF1.PixelsPerInch = 96
UDF1.Position = poDesigned
UDF1.ShowInTaskBar = stDefault
UDF1.Visible = true
UDF1.WindowState = wsNormal
UDF1.DoNotSaveInTable = false
--
---- CEButton1
CEButton1 = createButton(UDF1)
CEButton1.Tag = 0
CEButton1.Left = 17
CEButton1.Height = 25
CEButton1.Hint = ''
CEButton1.Top = 16
CEButton1.Width = 75
CEButton1.HelpType = htContext
CEButton1.HelpKeyword = ''
CEButton1.HelpContext = 0
CEButton1.Align = alNone
CEButton1.Anchors = '[akTop,akLeft]'
CEButton1.AutoSize = false
CEButton1.BidiMode = bdLeftToRight
CEButton1.Cancel = false
CEButton1.Caption = 'CEButton1'
CEButton1.Constraints.MaxWidth = 0
CEButton1.Constraints.MinHeight = 0
CEButton1.Constraints.MinWidth = 0
CEButton1.Default = false
CEButton1.Enabled = true
CEButton1.Font.Color = 536870912
CEButton1.Font.Height = -13
CEButton1.Font.Name = 'Lucida Console'
CEButton1.Font.Orientation = 0
CEButton1.Font.Pitch = fpFixed
CEButton1.Font.Quality = fqDefault
CEButton1.Font.Size = 10
CEButton1.Font.Style = '[]'
CEButton1.ModalResult = 0
CEButton1.ParentFont = true
CEButton1.ParentShowHint = true
CEButton1.ShowHint = false
CEButton1.TabOrder = 0
CEButton1.TabStop = true
CEButton1.Visible = true
--
---- CELabel1
CELabel1 = createLabel(UDF1)
CELabel1.Tag = 0
CELabel1.Left = 26
CELabel1.Height = 13
CELabel1.Hint = ''
CELabel1.Top = 52
CELabel1.Width = 64
CELabel1.HelpType = htContext
CELabel1.HelpKeyword = ''
CELabel1.HelpContext = 0
CELabel1.Align = alNone
CELabel1.Alignment = taLeftJustify
CELabel1.Anchors = '[akTop,akLeft]'
CELabel1.AutoSize = true
CELabel1.BidiMode = bdLeftToRight
CELabel1.Caption = 'CELabel1'
CELabel1.Color = 536870911
CELabel1.Constraints.MaxWidth = 0
CELabel1.Constraints.MinHeight = 0
CELabel1.Constraints.MinWidth = 0
CELabel1.Enabled = true
CELabel1.Font.Color = 536870912
CELabel1.Font.Height = -13
CELabel1.Font.Name = 'Lucida Console'
CELabel1.Font.Orientation = 0
CELabel1.Font.Pitch = fpFixed
CELabel1.Font.Quality = fqDefault
CELabel1.Font.Size = 10
CELabel1.Font.Style = '[]'
CELabel1.Layout = tlTop
CELabel1.ParentBidiMode = true
CELabel1.ParentColor = false
CELabel1.ParentFont = true
CELabel1.ParentShowHint = true
CELabel1.ShowAccelChar = true
CELabel1.ShowHint = false
CELabel1.Transparent = true
CELabel1.Visible = true
CELabel1.WordWrap = false
CELabel1.OptimalFill = false
--
---- CEToggleBox1
CEToggleBox1 = createToggleBox(UDF1)
CEToggleBox1.Tag = 0
CEToggleBox1.Left = 22
CEToggleBox1.Height = 23
CEToggleBox1.Hint = ''
CEToggleBox1.Top = 85
CEToggleBox1.Width = 90
CEToggleBox1.HelpType = htContext
CEToggleBox1.HelpKeyword = ''
CEToggleBox1.HelpContext = 0
CEToggleBox1.AllowGrayed = false
CEToggleBox1.Align = alNone
CEToggleBox1.Anchors = '[akTop,akLeft]'
CEToggleBox1.AutoSize = false
CEToggleBox1.BidiMode = bdLeftToRight
CEToggleBox1.Caption = 'CEToggleBox1'
CEToggleBox1.Checked = false
CEToggleBox1.Color = 536870912
CEToggleBox1.Constraints.MaxWidth = 0
CEToggleBox1.Constraints.MinHeight = 0
CEToggleBox1.Constraints.MinWidth = 0
CEToggleBox1.DragCursor = -12
CEToggleBox1.DragKind = dkDrag
CEToggleBox1.DragMode = dmManual
CEToggleBox1.Enabled = true
CEToggleBox1.Font.Color = 536870912
CEToggleBox1.Font.Height = -13
CEToggleBox1.Font.Name = 'Lucida Console'
CEToggleBox1.Font.Orientation = 0
CEToggleBox1.Font.Pitch = fpFixed
CEToggleBox1.Font.Quality = fqDefault
CEToggleBox1.Font.Size = 10
CEToggleBox1.Font.Style = '[]'
CEToggleBox1.ParentBidiMode = true
CEToggleBox1.ParentFont = true
CEToggleBox1.ParentShowHint = true
CEToggleBox1.ShowHint = false
CEToggleBox1.State = 0
CEToggleBox1.TabOrder = 1
CEToggleBox1.TabStop = true
CEToggleBox1.Visible = true
--
---- CECheckbox1
CECheckbox1 = createCheckBox(UDF1)
CECheckbox1.Tag = 0
CECheckbox1.Left = 29
CECheckbox1.Height = 19
CECheckbox1.Hint = ''
CECheckbox1.Top = 128
CECheckbox1.Width = 108
CECheckbox1.HelpType = htContext
CECheckbox1.HelpKeyword = ''
CECheckbox1.HelpContext = 0
CECheckbox1.Align = alNone
CECheckbox1.AllowGrayed = false
CECheckbox1.Anchors = '[akTop,akLeft]'
CECheckbox1.AutoSize = true
CECheckbox1.BidiMode = bdLeftToRight
CECheckbox1.Caption = 'CECheckbox1'
CECheckbox1.Checked = false
CECheckbox1.Color = 536870912
CECheckbox1.Constraints.MaxWidth = 0
CECheckbox1.Constraints.MinHeight = 0
CECheckbox1.Constraints.MinWidth = 0
CECheckbox1.Enabled = true
CECheckbox1.Font.Color = 536870912
CECheckbox1.Font.Height = -13
CECheckbox1.Font.Name = 'Lucida Console'
CECheckbox1.Font.Orientation = 0
CECheckbox1.Font.Pitch = fpFixed
CECheckbox1.Font.Quality = fqDefault
CECheckbox1.Font.Size = 10
CECheckbox1.Font.Style = '[]'
CECheckbox1.ParentColor = true
CECheckbox1.ParentFont = true
CECheckbox1.ParentShowHint = true
CECheckbox1.ParentBidiMode = true
CECheckbox1.ShowHint = false
CECheckbox1.State = 0
CECheckbox1.TabOrder = 2
CECheckbox1.TabStop = true
CECheckbox1.Visible = true
--
---- CERadioGroup1
CERadioGroup1 = createRadioGroup(UDF1)
CERadioGroup1.Tag = 0
CERadioGroup1.Left = 26
CERadioGroup1.Height = 105
CERadioGroup1.Hint = ''
CERadioGroup1.Top = 164
CERadioGroup1.Width = 185
CERadioGroup1.HelpType = htContext
CERadioGroup1.HelpKeyword = ''
CERadioGroup1.HelpContext = 0
CERadioGroup1.Align = alNone
CERadioGroup1.Anchors = '[akTop,akLeft]'
CERadioGroup1.AutoFill = true
CERadioGroup1.AutoSize = false
CERadioGroup1.BidiMode = bdLeftToRight
CERadioGroup1.Caption = 'CERadioGroup1'
CERadioGroup1.ClientHeight = 87
CERadioGroup1.ClientWidth = 181
CERadioGroup1.Color = 536870912
CERadioGroup1.ColumnLayout = clHorizontalThenVertical
CERadioGroup1.Constraints.MaxWidth = 0
CERadioGroup1.Constraints.MinHeight = 0
CERadioGroup1.Constraints.MinWidth = 0
CERadioGroup1.Enabled = true
CERadioGroup1.Font.Color = 536870912
CERadioGroup1.Font.Height = -13
CERadioGroup1.Font.Name = 'Lucida Console'
CERadioGroup1.Font.Orientation = 0
CERadioGroup1.Font.Pitch = fpFixed
CERadioGroup1.Font.Quality = fqDefault
CERadioGroup1.Font.Size = 10
CERadioGroup1.Font.Style = '[]'
CERadioGroup1.ItemIndex = -1
CERadioGroup1.ParentBidiMode = true
CERadioGroup1.ParentFont = true
CERadioGroup1.ParentColor = true
CERadioGroup1.ParentShowHint = true
CERadioGroup1.ShowHint = false
CERadioGroup1.TabOrder = 3
CERadioGroup1.TabStop = false
CERadioGroup1.Visible = true
--
---- RadioButton1
RadioButton1 = createRadioGroup(CERadioGroup1)
RadioButton1.Tag = 0
RadioButton1.Left = 6
RadioButton1.Height = 87
RadioButton1.Hint = ''
RadioButton1.Top = 0
RadioButton1.Width = 169
RadioButton1.HelpType = htContext
RadioButton1.HelpKeyword = ''
RadioButton1.HelpContext = 0
RadioButton1.Align = alNone
RadioButton1.Alignment = taRightJustify
RadioButton1.Anchors = '[akTop,akLeft]'
RadioButton1.AutoSize = true
RadioButton1.BidiMode = bdLeftToRight
RadioButton1.Caption = 'RadioButton1'
RadioButton1.Checked = false
RadioButton1.Color = 536870912
RadioButton1.Constraints.MaxWidth = 0
RadioButton1.Constraints.MinHeight = 0
RadioButton1.Constraints.MinWidth = 0
RadioButton1.DragCursor = -12
RadioButton1.DragKind = dkDrag
RadioButton1.DragMode = dmManual
RadioButton1.Enabled = true
RadioButton1.Font.Color = 536870912
RadioButton1.Font.Height = -13
RadioButton1.Font.Name = 'Lucida Console'
RadioButton1.Font.Orientation = 0
RadioButton1.Font.Pitch = fpFixed
RadioButton1.Font.Quality = fqDefault
RadioButton1.Font.Size = 10
RadioButton1.Font.Style = '[]'
RadioButton1.ParentBidiMode = true
RadioButton1.ParentColor = true
RadioButton1.ParentFont = true
RadioButton1.ParentShowHint = true
RadioButton1.ShowHint = false
RadioButton1.TabOrder = 0
RadioButton1.TabStop = false
RadioButton1.Visible = true
--
---- CEGroupBox1
CEGroupBox1 = createGroupBox(UDF1)
CEGroupBox1.Tag = 0
CEGroupBox1.Left = 174
CEGroupBox1.Height = 113
CEGroupBox1.Hint = ''
CEGroupBox1.Top = 26
CEGroupBox1.Width = 305
CEGroupBox1.HelpType = htContext
CEGroupBox1.HelpKeyword = ''
CEGroupBox1.HelpContext = 0
CEGroupBox1.Align = alNone
CEGroupBox1.Anchors = '[akTop,akLeft]'
CEGroupBox1.AutoSize = false
CEGroupBox1.BidiMode = bdLeftToRight
CEGroupBox1.Caption = 'CEGroupBox1'
CEGroupBox1.ClientHeight = 95
CEGroupBox1.ClientWidth = 301
CEGroupBox1.Color = 536870912
CEGroupBox1.Constraints.MaxWidth = 0
CEGroupBox1.Constraints.MinHeight = 0
CEGroupBox1.Constraints.MinWidth = 0
CEGroupBox1.Enabled = true
CEGroupBox1.Font.Color = 536870912
CEGroupBox1.Font.Height = -13
CEGroupBox1.Font.Name = 'Lucida Console'
CEGroupBox1.Font.Orientation = 0
CEGroupBox1.Font.Pitch = fpFixed
CEGroupBox1.Font.Quality = fqDefault
CEGroupBox1.Font.Size = 10
CEGroupBox1.Font.Style = '[]'
CEGroupBox1.ParentBidiMode = true
CEGroupBox1.ParentColor = true
CEGroupBox1.ParentFont = true
CEGroupBox1.ParentShowHint = true
CEGroupBox1.ShowHint = false
CEGroupBox1.TabOrder = 4
CEGroupBox1.TabStop = false
CEGroupBox1.Visible = true
--
---- CEListBox1
CEListBox1 = createListBox(CEGroupBox1)
CEListBox1.Tag = 0
CEListBox1.Left = 16
CEListBox1.Height = 80
CEListBox1.Hint = ''
CEListBox1.Top = 6
CEListBox1.Width = 100
CEListBox1.HelpType = htContext
CEListBox1.HelpKeyword = ''
CEListBox1.HelpContext = 0
CEListBox1.Align = alNone
CEListBox1.Anchors = '[akTop,akLeft]'
CEListBox1.BidiMode = bdLeftToRight
CEListBox1.BorderStyle = bsSingle
CEListBox1.ClickOnSelChange = true
CEListBox1.Color = 536870912
CEListBox1.Constraints.MaxWidth = 0
CEListBox1.Constraints.MinHeight = 0
CEListBox1.Constraints.MinWidth = 0
CEListBox1.ExtendedSelect = true
CEListBox1.Enabled = true
CEListBox1.Font.Color = 536870912
CEListBox1.Font.Height = -13
CEListBox1.Font.Name = 'Lucida Console'
CEListBox1.Font.Orientation = 0
CEListBox1.Font.Pitch = fpFixed
CEListBox1.Font.Quality = fqDefault
CEListBox1.Font.Size = 10
CEListBox1.Font.Style = '[]'
CEListBox1.IntegralHeight = false
CEListBox1.ItemHeight = 0
CEListBox1.MultiSelect = false
CEListBox1.ParentBidiMode = true
CEListBox1.ParentColor = false
CEListBox1.ParentShowHint = true
CEListBox1.ParentFont = true
CEListBox1.ShowHint = false
CEListBox1.Sorted = false
CEListBox1.Style = 'lbStandard'
CEListBox1.TabOrder = 0
CEListBox1.TabStop = true
CEListBox1.TopIndex = 0
CEListBox1.Visible = true
--
---- CEComboBox1
CEComboBox1 = createComboBox(UDF1)
CEComboBox1.Tag = 0
CEComboBox1.Left = 19
CEComboBox1.Height = 21
CEComboBox1.Hint = ''
CEComboBox1.Top = 287
CEComboBox1.Width = 100
CEComboBox1.HelpType = htContext
CEComboBox1.HelpKeyword = ''
CEComboBox1.HelpContext = 0
CEComboBox1.Align = alNone
CEComboBox1.Anchors = '[akTop,akLeft]'
CEComboBox1.ArrowKeysTraverseList = true
CEComboBox1.AutoComplete = false
CEComboBox1.AutoCompleteText = '[cbactEndOfLineComplete,cbactSearchAscending]'
CEComboBox1.AutoDropDown = false
CEComboBox1.AutoSelect = true
CEComboBox1.AutoSize = true
CEComboBox1.BidiMode = bdLeftToRight
CEComboBox1.CharCase = ecNormal
CEComboBox1.Color = 536870912
CEComboBox1.Constraints.MaxWidth = 0
CEComboBox1.Constraints.MinHeight = 0
CEComboBox1.Constraints.MinWidth = 0
CEComboBox1.DropDownCount = 8
CEComboBox1.Enabled = true
CEComboBox1.Font.Color = 536870912
CEComboBox1.Font.Height = -13
CEComboBox1.Font.Name = 'Lucida Console'
CEComboBox1.Font.Orientation = 0
CEComboBox1.Font.Pitch = fpFixed
CEComboBox1.Font.Quality = fqDefault
CEComboBox1.Font.Size = 10
CEComboBox1.Font.Style = '[]'
CEComboBox1.ItemHeight = 13
CEComboBox1.ItemIndex = -1
CEComboBox1.ItemWidth = 0
CEComboBox1.MaxLength = 0
CEComboBox1.ParentColor = false
CEComboBox1.ParentFont = true
CEComboBox1.ParentShowHint = true
CEComboBox1.ReadOnly = false
CEComboBox1.ShowHint = false
CEComboBox1.Sorted = false
CEComboBox1.Style = 'csDropDown'
CEComboBox1.TabOrder = 5
CEComboBox1.TabStop = true
CEComboBox1.Text = CEComboBox1
CEComboBox1.Visible = true
--
---- CEProgressbar1
CEProgressbar1 = createProgressBar(UDF1)
CEProgressbar1.Tag = 0
CEProgressbar1.Left = 38
CEProgressbar1.Height = 20
CEProgressbar1.Hint = ''
CEProgressbar1.Top = 340
CEProgressbar1.Width = 100
CEProgressbar1.HelpType = htContext
CEProgressbar1.HelpKeyword = ''
CEProgressbar1.HelpContext = 0
CEProgressbar1.Align = alNone
CEProgressbar1.Anchors = '[akTop,akLeft]'
CEProgressbar1.BorderWidth = 0
CEProgressbar1.Constraints.MaxWidth = 0
CEProgressbar1.Constraints.MinHeight = 0
CEProgressbar1.Constraints.MinWidth = 0
CEProgressbar1.Enabled = true
CEProgressbar1.Max = 100
CEProgressbar1.Min = 0
CEProgressbar1.Position = 0
CEProgressbar1.Orientation = pbHorizontal
CEProgressbar1.ParentShowHint = true
CEProgressbar1.ShowHint = false
CEProgressbar1.Smooth = false
CEProgressbar1.Step = 10
CEProgressbar1.Style = 'pbstNormal'
CEProgressbar1.TabOrder = 6
CEProgressbar1.TabStop = false
CEProgressbar1.Visible = true
CEProgressbar1.BarShowText = false
--
---- CETrackBar1
CETrackBar1 = createTrackBar(UDF1)
CETrackBar1.Tag = 0
CETrackBar1.Left = 50
CETrackBar1.Height = 25
CETrackBar1.Hint = ''
CETrackBar1.Top = 384
CETrackBar1.Width = 100
CETrackBar1.HelpType = htContext
CETrackBar1.HelpKeyword = ''
CETrackBar1.HelpContext = 0
CETrackBar1.Frequency = 1
CETrackBar1.LineSize = 1
CETrackBar1.Max = 10
CETrackBar1.Min = 0
CETrackBar1.Orientation = trHorizontal
CETrackBar1.PageSize = 2
CETrackBar1.Position = 0
CETrackBar1.Reversed = false
CETrackBar1.ScalePos = trTop
CETrackBar1.SelEnd = 0
CETrackBar1.SelStart = 0
CETrackBar1.ShowSelRange = true
CETrackBar1.TabStop = true
CETrackBar1.TickMarks = tmBottomRight
CETrackBar1.TickStyle = tsAuto
CETrackBar1.Align = alNone
CETrackBar1.Anchors = '[akTop,akLeft]'
CETrackBar1.Constraints.MaxWidth = 0
CETrackBar1.Constraints.MinHeight = 0
CETrackBar1.Constraints.MinWidth = 0
CETrackBar1.Enabled = true
CETrackBar1.ParentShowHint = true
CETrackBar1.ShowHint = false
CETrackBar1.TabOrder = 7
CETrackBar1.Visible = true
--
---- CETreeview1
CETreeview1 = createTreeview(UDF1)
CETreeview1.Tag = 0
CETreeview1.Left = 515
CETreeview1.Height = 97
CETreeview1.Hint = ''
CETreeview1.Top = 40
CETreeview1.Width = 121
CETreeview1.HelpType = htContext
CETreeview1.HelpKeyword = ''
CETreeview1.HelpContext = 0
CETreeview1.TabStop = true
CETreeview1.Align = alNone
CETreeview1.Anchors = '[akTop,akLeft]'
CETreeview1.AutoExpand = false
CETreeview1.BackgroundColor = -2147483643
CETreeview1.BorderStyle = bsSingle
CETreeview1.BorderWidth = 0
CETreeview1.Color = 536870912
CETreeview1.Constraints.MaxWidth = 0
CETreeview1.Constraints.MinHeight = 0
CETreeview1.Constraints.MinWidth = 0
CETreeview1.DefaultItemHeight = 16
CETreeview1.DragKind = dkDrag
CETreeview1.DragCursor = -12
CETreeview1.DragMode = dmManual
CETreeview1.Enabled = true
CETreeview1.ExpandSignColor = -2147483642
CETreeview1.ExpandSignType = tvestTheme
CETreeview1.Font.Color = 536870912
CETreeview1.Font.Height = -13
CETreeview1.Font.Name = 'Lucida Console'
CETreeview1.Font.Orientation = 0
CETreeview1.Font.Pitch = fpFixed
CETreeview1.Font.Quality = fqDefault
CETreeview1.Font.Size = 10
CETreeview1.Font.Style = '[]'
CETreeview1.HideSelection = true
CETreeview1.HotTrack = false
CETreeview1.Indent = 15
CETreeview1.MultiSelect = false
CETreeview1.MultiSelectStyle = '[msControlSelect]'
CETreeview1.ParentColor = false
CETreeview1.ParentFont = true
CETreeview1.ParentShowHint = true
CETreeview1.ReadOnly = false
CETreeview1.RightClickSelect = false
CETreeview1.RowSelect = false
CETreeview1.ScrollBars = ssBoth
CETreeview1.SelectionColor = -2147483635
CETreeview1.SelectionFontColor = 16777215
CETreeview1.SelectionFontColorUsed = false
CETreeview1.SeparatorColor = 8421504
CETreeview1.ShowButtons = true
CETreeview1.ShowHint = false
CETreeview1.ShowLines = true
CETreeview1.ShowRoot = true
CETreeview1.SortType = stNone
CETreeview1.TabOrder = 8
CETreeview1.ToolTips = true
CETreeview1.Visible = true
CETreeview1.Options = '[tvoAutoItemHeight,tvoHideSelection,tvoKeepCollapsedNodes,tvoShowButtons,tvoShowLines,tvoShowRoot,tvoToolTips,tvoThemedDraw]'
CETreeview1.TreeLineColor = -2147483642
CETreeview1.TreeLinePenStyle = psPattern
--
---- CEListView1
CEListView1 = createListView(UDF1)
CEListView1.Tag = 0
CEListView1.Left = 400
CEListView1.Height = 150
CEListView1.Hint = ''
CEListView1.Top = 163
CEListView1.Width = 250
CEListView1.HelpType = htContext
CEListView1.HelpKeyword = ''
CEListView1.HelpContext = 0
CEListView1.Align = alNone
CEListView1.AllocBy = 0
CEListView1.Anchors = '[akTop,akLeft]'
CEListView1.AutoSort = true
CEListView1.BorderStyle = bsSingle
CEListView1.BorderWidth = 0
CEListView1.Checkboxes = false
CEListView1.Color = 536870912
CEListView1.ColumnClick = true
CEListView1.Constraints.MaxWidth = 0
CEListView1.Constraints.MinHeight = 0
CEListView1.Constraints.MinWidth = 0
CEListView1.Enabled = true
CEListView1.Font.Color = 536870912
CEListView1.Font.Height = -13
CEListView1.Font.Name = 'Lucida Console'
CEListView1.Font.Orientation = 0
CEListView1.Font.Pitch = fpFixed
CEListView1.Font.Quality = fqDefault
CEListView1.Font.Size = 10
CEListView1.Font.Style = '[]'
CEListView1.HideSelection = true
CEListView1.MultiSelect = false
CEListView1.OwnerData = false
CEListView1.ParentColor = false
CEListView1.ParentFont = true
CEListView1.ParentShowHint = true
CEListView1.ReadOnly = false
CEListView1.RowSelect = false
CEListView1.ScrollBars = ssBoth
CEListView1.ShowColumnHeaders = true
CEListView1.ShowHint = false
CEListView1.SortColumn = -1
CEListView1.SortType = stNone
CEListView1.SortDirection = sdAscending
CEListView1.TabStop = true
CEListView1.TabOrder = 9
CEListView1.ToolTips = true
CEListView1.Visible = true
CEListView1.ViewStyle = vsList
--
---- CEPanel1
CEPanel1 = createPanel(UDF1)
CEPanel1.Tag = 0
CEPanel1.Left = 232
CEPanel1.Height = 50
CEPanel1.Hint = ''
CEPanel1.Top = 169
CEPanel1.Width = 142
CEPanel1.HelpType = htContext
CEPanel1.HelpKeyword = ''
CEPanel1.HelpContext = 0
CEPanel1.Align = alNone
CEPanel1.Alignment = 2
CEPanel1.Anchors = '[akTop,akLeft]'
CEPanel1.AutoSize = false
CEPanel1.BevelInner = 0
CEPanel1.BevelOuter = 2
CEPanel1.BevelWidth = 1
CEPanel1.BidiMode = bdLeftToRight
CEPanel1.BorderWidth = 0
CEPanel1.BorderStyle = bsNone
CEPanel1.Caption = 'CEPanel1'
CEPanel1.ClientHeight = 50
CEPanel1.ClientWidth = 142
CEPanel1.Color = 536870912
CEPanel1.Constraints.MaxWidth = 0
CEPanel1.Constraints.MinHeight = 0
CEPanel1.Constraints.MinWidth = 0
CEPanel1.DockSite = false
CEPanel1.Enabled = true
CEPanel1.Font.Color = 536870912
CEPanel1.Font.Height = -13
CEPanel1.Font.Name = 'Lucida Console'
CEPanel1.Font.Orientation = 0
CEPanel1.Font.Pitch = fpFixed
CEPanel1.Font.Quality = fqDefault
CEPanel1.Font.Size = 10
CEPanel1.Font.Style = '[]'
CEPanel1.FullRepaint = true
CEPanel1.ParentBidiMode = true
CEPanel1.ParentColor = true
CEPanel1.ParentFont = true
CEPanel1.ParentShowHint = true
CEPanel1.ShowHint = false
CEPanel1.TabOrder = 10
CEPanel1.TabStop = false
CEPanel1.UseDockManager = true
CEPanel1.Visible = true
--
---- CESplitter1
CESplitter1 = createSplitter(CEPanel1)
CESplitter1.Tag = 0
CESplitter1.Left = 1
CESplitter1.Height = 48
CESplitter1.Hint = ''
CESplitter1.Top = 1
CESplitter1.Width = 5
CESplitter1.HelpType = htContext
CESplitter1.HelpKeyword = ''
CESplitter1.HelpContext = 0
CESplitter1.Align = alLeft
CESplitter1.Anchors = '[akTop,akLeft,akBottom]'
CESplitter1.AutoSnap = true
CESplitter1.Beveled = false
CESplitter1.Color = 536870912
CESplitter1.Constraints.MaxWidth = 0
CESplitter1.Constraints.MinHeight = 0
CESplitter1.Constraints.MinWidth = 0
CESplitter1.MinSize = 30
CESplitter1.ParentColor = true
CESplitter1.ParentShowHint = true
CESplitter1.ResizeAnchor = akLeft
CESplitter1.ResizeStyle = rsUpdate
CESplitter1.ShowHint = false
CESplitter1.Visible = true
--
---- CEImage1
CEImage1 = createImage(UDF1)
CEImage1.Tag = 0
CEImage1.Left = 231
CEImage1.Height = 102
CEImage1.Hint = ''
CEImage1.Top = 261
CEImage1.Width = 102
CEImage1.HelpType = htContext
CEImage1.HelpKeyword = ''
CEImage1.HelpContext = 0
CEImage1.Align = alNone
CEImage1.Anchors = '[akTop,akLeft]'
CEImage1.AutoSize = false
CEImage1.Center = false
CEImage1.Constraints.MaxWidth = 0
CEImage1.Constraints.MinHeight = 0
CEImage1.Constraints.MinWidth = 0
CEImage1.Enabled = true
CEImage1.ParentShowHint = true
CEImage1.Proportional = false
CEImage1.ShowHint = false
CEImage1.Stretch = false
CEImage1.Transparent = false
CEImage1.Visible = true
--
---- CEButton2
CEButton2 = createButton(CEGroupBox1)
CEButton2.Tag = 0
CEButton2.Left = 138
CEButton2.Height = 25
CEButton2.Hint = ''
CEButton2.Top = 7
CEButton2.Width = 75
CEButton2.HelpType = htContext
CEButton2.HelpKeyword = ''
CEButton2.HelpContext = 0
CEButton2.Align = alNone
CEButton2.Anchors = '[akTop,akLeft]'
CEButton2.AutoSize = false
CEButton2.BidiMode = bdLeftToRight
CEButton2.Cancel = false
CEButton2.Caption = 'CEButton2'
CEButton2.Constraints.MaxWidth = 0
CEButton2.Constraints.MinHeight = 0
CEButton2.Constraints.MinWidth = 0
CEButton2.Default = false
CEButton2.Enabled = true
CEButton2.Font.Color = 536870912
CEButton2.Font.Height = -13
CEButton2.Font.Name = 'Lucida Console'
CEButton2.Font.Orientation = 0
CEButton2.Font.Pitch = fpFixed
CEButton2.Font.Quality = fqDefault
CEButton2.Font.Size = 10
CEButton2.Font.Style = '[]'
CEButton2.ModalResult = 0
CEButton2.ParentFont = true
CEButton2.ParentShowHint = true
CEButton2.ShowHint = false
CEButton2.TabOrder = 1
CEButton2.TabStop = true
CEButton2.Visible = true
--
---- CELabel2
CELabel2 = createLabel(CEGroupBox1)
CELabel2.Tag = 0
CELabel2.Left = 222
CELabel2.Height = 13
CELabel2.Hint = ''
CELabel2.Top = 12
CELabel2.Width = 64
CELabel2.HelpType = htContext
CELabel2.HelpKeyword = ''
CELabel2.HelpContext = 0
CELabel2.Align = alNone
CELabel2.Alignment = taLeftJustify
CELabel2.Anchors = '[akTop,akLeft]'
CELabel2.AutoSize = true
CELabel2.BidiMode = bdLeftToRight
CELabel2.Caption = 'CELabel2'
CELabel2.Color = 536870911
CELabel2.Constraints.MaxWidth = 0
CELabel2.Constraints.MinHeight = 0
CELabel2.Constraints.MinWidth = 0
CELabel2.Enabled = true
CELabel2.Font.Color = 536870912
CELabel2.Font.Height = -13
CELabel2.Font.Name = 'Lucida Console'
CELabel2.Font.Orientation = 0
CELabel2.Font.Pitch = fpFixed
CELabel2.Font.Quality = fqDefault
CELabel2.Font.Size = 10
CELabel2.Font.Style = '[]'
CELabel2.Layout = tlTop
CELabel2.ParentBidiMode = true
CELabel2.ParentColor = false
CELabel2.ParentFont = true
CELabel2.ParentShowHint = true
CELabel2.ShowAccelChar = true
CELabel2.ShowHint = false
CELabel2.Transparent = true
CELabel2.Visible = true
CELabel2.WordWrap = false
CELabel2.OptimalFill = false
--
---- CECheckbox2
CECheckbox2 = createCheckBox(CEGroupBox1)
CECheckbox2.Tag = 0
CECheckbox2.Left = 142
CECheckbox2.Height = 19
CECheckbox2.Hint = ''
CECheckbox2.Top = 51
CECheckbox2.Width = 108
CECheckbox2.HelpType = htContext
CECheckbox2.HelpKeyword = ''
CECheckbox2.HelpContext = 0
CECheckbox2.Align = alNone
CECheckbox2.AllowGrayed = false
CECheckbox2.Anchors = '[akTop,akLeft]'
CECheckbox2.AutoSize = true
CECheckbox2.BidiMode = bdLeftToRight
CECheckbox2.Caption = 'CECheckbox2'
CECheckbox2.Checked = false
CECheckbox2.Color = 536870912
CECheckbox2.Constraints.MaxWidth = 0
CECheckbox2.Constraints.MinHeight = 0
CECheckbox2.Constraints.MinWidth = 0
CECheckbox2.Enabled = true
CECheckbox2.Font.Color = 536870912
CECheckbox2.Font.Height = -13
CECheckbox2.Font.Name = 'Lucida Console'
CECheckbox2.Font.Orientation = 0
CECheckbox2.Font.Pitch = fpFixed
CECheckbox2.Font.Quality = fqDefault
CECheckbox2.Font.Size = 10
CECheckbox2.Font.Style = '[]'
CECheckbox2.ParentColor = true
CECheckbox2.ParentFont = true
CECheckbox2.ParentShowHint = true
CECheckbox2.ParentBidiMode = true
CECheckbox2.ShowHint = false
CECheckbox2.State = 0
CECheckbox2.TabOrder = 2
CECheckbox2.TabStop = true
CECheckbox2.Visible = true
 

corroder

Novice Cheater
Mar 3, 2017
18
0
1
#2
I just add this script to manipulating create scrollbox error (I think it can be same way for radio button) :

Lua:
scrbox_script = [[
function createTScrollBox(Parent)
local box = createComponentClass('TScrollBox', Parent)
box.Parent = Parent
return box
end

]]


--- and add print here :


function CEForm2Lua(form, noPrint)
    local vis = form.Visible
    form.Visible = true
    local s = getControlScript(form)
    form.Visible = vis
    if not noPrint then
        print(scrbox_script)
        print(s)
    end
    return s
end
 

TheyCallMeTim13

Wiki Monster
Talents
Fearless Donors
Mar 3, 2017
418
46
28
#3
So now, I just need to figure out the MainMenu and MenuItems.

Lua:
local format = string.format
local strE = string.empty or STRING_EMPTY or ''
local t = translate


local LineEnd = '\r\n'

local CreateMainFormMenuItems = true
local MainMenuItemName = 'ools1' --'miTools' -- 'ools1'
local MainMenuItemCaption = t('Tools')
local ToolMenuItemCaption = t('CE Form to LUA')
local ToolFormCaption = t('Convert CE Form to Lua script')

local StringDel = { '\'', '\'' }

local controlPropertyList = {
    Tag = true, 
    Left = true,
    Height = true,
    Hint = true,
    Top = true,
    Width = true,
    HelpType = true,
    HelpKeyword = true,
    HelpContext = true,
    Align = true,
    AllowDropFiles = true,
    AlphaBlend = true,
    AlphaBlendValue = true,
    Anchors = true,
    AutoScroll = true,
    AutoSize = true,
    BiDiMode = true,
    BorderIcons = true,
    BorderStyle = true,
    BorderWidth = true,
    Caption = true,
    ClientHeight = true,
    ClientWidth = true,
    Color = true,
    Constraints = true,
    MaxWidth = true,
    MinHeight = true,
    MinWidth = true,
    DefaultMonitor = true,
    DockSite = true,
    DragKind = true,
    DragMode = true,
    Font = true,
    Name = true,
    Orientation = true,
    Pitch = true,
    Quality = true,
    Size = true,
    Style = true,
    FormStyle = true,
    KeyPreview = true,
    Menu = true,
    ParentBiDiMode = true,
    ParentFont = true,
    PixelsPerInch = true,
    PopupMenu = true,
    Position = true,
    ShowInTaskBar = true,
    Visible = true,
    WindowState = true,
    DoNotSaveInTable = true,
    BidiMode = true,
    BorderSpacing = true,
    Cancel = true,
    Default = true,
    Enabled = true,
    ModalResult = true,
    ParentShowHint = true,
    ShowHint = true,
    TabOrder = true,
    TabStop = true,
    Alignment = true,
    Layout = true,
    ParentBidiMode = true,
    ParentColor = true,
    ShowAccelChar = true,
    Transparent = true,
    WordWrap = true,
    OptimalFill = true,
    AllowGrayed = true,
    Checked = true,
    DragCursor = true,
    State = true,
    AutoFill = true,
    ColumnLayout = true,
    ItemIndex = true,
    ClickOnSelChange = true,
    ExtendedSelect = true,
    IntegralHeight = true,
    ItemHeight = true,
    MultiSelect = true,
    Sorted = true,
    TopIndex = true,
    ArrowKeysTraverseList = true,
    AutoComplete = true,
    AutoCompleteText = true,
    AutoDropDown = true,
    AutoSelect = true,
    CharCase = true,
    DropDownCount = true,
    ItemWidth = true,
    MaxLength = true,
    ReadOnly = true,
    Text = true,
    Max = true,
    Min = true,
    Smooth = true,
    Step = true,
    BarShowText = true,
    Frequency = true,
    LineSize = true,
    PageSize = true,
    Reversed = true,
    ScalePos = true,
    SelEnd = true,
    SelStart = true,
    ShowSelRange = true,
    TickMarks = true,
    TickStyle = true,
    AutoExpand = true,
    BackgroundColor = true,
    DefaultItemHeight = true,
    ExpandSignColor = true,
    ExpandSignType = true,
    HideSelection = true,
    HotTrack = true,
    Indent = true,
    MultiSelectStyle = true,
    RightClickSelect = true,
    RowSelect = true,
    ScrollBars = true,
    SelectionColor = true,
    SelectionFontColor = true,
    SelectionFontColorUsed = true,
    SeparatorColor = true,
    ShowButtons = true,
    ShowLines = true,
    ShowRoot = true,
    SortType = true,
    StateImages = true,
    ToolTips = true,
    Options = true,
    TreeLineColor = true,
    TreeLinePenStyle = true,
    AllocBy = true,
    AutoSort = true,
    Checkboxes = true,
    ColumnClick = true,
    OwnerData = true,
    ShowColumnHeaders = true,
    SortColumn = true,
    SortDirection = true,
    ViewStyle = true,
    BevelInner = true,
    BevelOuter = true,
    BevelWidth = true,
    FullRepaint = true,
    UseDockManager = true,
    AutoSnap = true,
    Beveled = true,
    MinSize = true,
    ResizeAnchor = true,
    ResizeStyle = true,
    Center = true,
    Proportional = true,
    Stretch = true,
    AnchorSideLeft = true,
    AnchorSideTop = true,
    AnchorSideRight = true,
    AnchorSideBottom = true,
    Side = true,
    Page = true,
    Smooth = true,
    Position = true,
    Range = true,
    Tracking = true,
    Visible = true,
    Center = true,
    HorzScrollBar = true,
    VertScrollBar = true,
    -------------------------
    ChildSizing = false,
    Cursor = false,
    Icon = false,
    IconOptions = false,
    Picture = false,
    Images = false,
    Columns = false,
    Items = false,
    Menu = false,
}
local controlPropertyStrings = {
    Name = true,
    Hint = true,
    HelpKeyword = true,
    Caption = true,
    Anchors = true,
    BorderIcons = true,
    Style = true,
    AutoCompleteText = true,
    MultiSelectStyle = true,
    Options = true,
}
local controlPropertyGroups = {
    Font = true,
    Constraints = true,
    BorderSpacing = true,
    AnchorSideLeft = true,
    AnchorSideTop = true,
    AnchorSideRight = true,
    AnchorSideBottom = true,
    HorzScrollBar = true,
    VertScrollBar = true,
}

local controlConstructors = {
    TMainMenu = 'createMainMenu',
    TMenuItem = 'createMenuItem',
}

local usedKeys = {}
local printUnusedKeys = false

local FormName = nil


function createTScrollBox(Parent)
    local control = createComponentClass('TScrollBox', Parent)
    control.Parent = Parent
    return control
end
function createTRadioButton(Parent)
    local control = createComponentClass('TRadioButton', Parent)
    control.Parent = Parent
    return control
end

local function getConstructor(control)
    ---- Could use 'createComponentClass'
    local action = 'create' .. control.ClassName:gsub('TCE', strE)
    local callStr = '(%s)'
    local parentStr = (control.Parent and control.Parent.Name) or strE
    if type(controlConstructors[control.ClassName]) == 'string' then
        action = controlConstructors[control.ClassName]
        if action == 'createMainMenu' then
            parentStr = FormName
        elseif action == 'createMenuItem' then
            if parentStr == nil or parentStr == strE then
                parentStr = FormName .. '.Menu'
            end
        end
    end
    return action .. format(callStr, parentStr)
end


local function getPropertiesScript(control, parentStr)
    local script = strE
    local pl = getPropertyList(control)
    if pl then
        for i = 1, pl.Count - 1 do
            if controlPropertyGroups[pl[i]] then
                script = script .. getPropertiesScript(control[pl[i]], format('%s.%s', parentStr, pl[i]))
            elseif controlPropertyList[pl[i]] then
                if control[pl[i]] ~= nil then
                    local v = control[pl[i]]
                    if controlPropertyStrings[pl[i]] then
                        v = format('%s%s%s', StringDel[1], v, StringDel[2])
                    end
                    script = script .. format('%s.%s = %s', parentStr, pl[i], v) .. LineEnd
                end
            else
                if printUnusedKeys and not usedKeys[pl[i]]
                and controlPropertyList[pl[i]] ~= false then
                    usedKeys[pl[i]] = true
                    print(format('---- Key Not Used: "%s"', pl[i]))
                end
            end
        end
    end
    return script
end


local function getControlComponentScript(control)
    local script = strE
    if control.ControlCount ~= nil then
        for i = 0, control.ComponentCount - 1 do
            if control.Component[i].ClassName ~= 'TJvDesignHandle' then
                script = script .. '--' .. LineEnd .. '---- ' .. control.Component[i].Name .. LineEnd
                script = script .. '--------------------' .. LineEnd
                script = script .. format('%s = %s', control.Component[i].Name, getConstructor(control.Component[i])) .. LineEnd
                script = script .. getPropertiesScript(control.Component[i], control.Component[i].Name)
                if control.Component[i].ComponentCount then
                    script = script .. getControlComponentScript(control.Component[i])
                end
                script = script .. '--------------------' .. LineEnd
            end
        end
    end
    return script
end


local function getControlScript(control)
    local parentStr = control.Name
    local script = '--' .. LineEnd .. '----' .. LineEnd .. '---- FORM: ' .. control.Name .. LineEnd
    script = script .. '------------------------------' .. LineEnd
    script = script .. format('%s = %s', parentStr, getConstructor(control)) .. LineEnd
    script = script .. getPropertiesScript(control, parentStr)
    script = script .. '------------------------------' .. LineEnd
    script = script .. '---- ' .. control.Name .. ' : Components' .. LineEnd
    script = script .. '------------------------------' .. LineEnd
    script = script .. getControlComponentScript(control)
    script = script .. '------------------------------' .. LineEnd
    script = script .. '---- END FORM: ' .. control.Name .. LineEnd .. '---- ' .. LineEnd .. '--' .. LineEnd
    return script
end


function CEForm2Lua(form, noPrint)
    if form == nil then return end
    if type(form) == 'string' then
        form = _G[form]
    end
    FormName = form.Name
    local vis = form.Visible
    form.Visible = true
    local s = getControlScript(form)
    form.Visible = vis
    if not noPrint then
        print(s)
    end
    return s
end

--
----
---- GUI
local function showModalForm()
    local fW = 400 -- Form width
    local lPush = 90 -- Label width
    local sX = fW - (lPush + 10) -- Size X
    local sY = 23 -- Size Y
    local pX = 3 -- Position X
    local pY = 3 -- Position Y
    local bW = 75 -- Button Width
    local bH = 24 -- Button Hight
    local padF = 5 -- Form Padding

    local pad1 = 3
    local pad2 = 1
    local row = 0

    local frmGenerate = createForm(false)
    frmGenerate.centerScreen()
    frmGenerate.setSize(fW, fH)
    frmGenerate.Name = 'frmGenerate'
    frmGenerate.Caption = t(ToolFormCaption)

    local lblFormName = createLabel(frmGenerate)
    lblFormName.Name = 'lblFormName'
    lblFormName.setPosition(pX, pY + sY * row + pad1)
    lblFormName.Caption = 'Form Name' .. ':'
    local edFormName = createEdit(frmGenerate)
    edFormName.Name ='edFormName'
    edFormName.setSize(sX, sY)
    edFormName.setPosition(pX + lPush, pY + sY * row + pad2)
    edFormName.Text = strE
    row = row + 1

    local btnOk = createButton(frmGenerate)
    btnOk.Name = 'btnOk'
    btnOk.Caption = 'OK'
    btnOk.setSize(bW, bH)
    btnOk.setPosition((fW / 3) - (bW / 2), pY + sY * row + pad2)
    btnOk.ModalResult = mrOK
    btnOk.Default = true
    local btnCancel = createButton(frmGenerate)
    btnCancel.Name = 'btnCancel'
    btnCancel.Caption = 'Cancel'
    btnCancel.setSize(bW, bH)
    btnCancel.setPosition(((fW / 3) * 2) - (bW / 2), pY + sY * row + pad2)
    btnCancel.ModalResult = mrCancel
    btnCancel.Cancel = true
    row = row + 1

    frmGenerate.setSize(fW, pY + sY * row + padF)

    local mr = frmGenerate.showModal()
    local dt = {
        Result = mr,
        Name = edFormName.Text,
        Form = _G[edFormName.Text],
    }
    return dt
end


local function form2LuaTool( ... )
    local rdt = showModalForm()
    if rdt.Result == mrOK then
        CEForm2Lua(rdt.Form)
    end
end


--
----
---- Setup and load
local function addMenuItem(parent, caption)
    if parent == nil then return nil end
    local newItem = createMenuItem(parent)
    parent.add(newItem)
    newItem.Caption = caption
    return newItem
end

local function createMainFormMenu()
    if MainForm.Menu == nil then return end
    local menuItems = MainForm.Menu.Items
    local miTools = nil
    for i = 0, menuItems.Count - 1 do
        if menuItems[i].Name == MainMenuItemName then
            miTools = menuItems[i]
            miTools.visible = true
            -- addMenuItem(miTools, '-')
        end
    end
    if miTools == nil then
        miTools = createMenuItem(MainForm)
        miTools.Name = MainMenuItemName
        miTools.Caption = MainMenuItemCaption
        menuItems.insert(menuItems.Count - 2, miTools)
    end
    return miTools
end

local function loadMenuAddCEForm2Lua()
    local function loadloadMenuAddCEForm2LuaTimer_tick(timer)
        timer.destroy()
        if CreateMainFormMenuItems then
            local miTools = createMainFormMenu()
            addMenuItem(miTools, t(ToolMenuItemCaption)).setOnClick(form2LuaTool)
        end
    end
    local intervals = 100
    local timer = createTimer(MainForm)
    timer.Interval = intervals
    timer.OnTimer = loadloadMenuAddCEForm2LuaTimer_tick
end

loadMenuAddCEForm2Lua()
 
Top Bottom