Posted: Thu Oct 15, 2020 11:52 pm Post subject: Get form component names from other form
How?.
Let say:
1. Form1 created using form designer/Lua with some components.
2. Form1 save as CT file
3, Form2, which created using Lua script and save as a Lua file and add as Table File on form1.CT
4. There are a function to call form2 from form1 using readStringLocal and loadString.
5. On form2 there are a function to listing form1 component names, but this function return error since form1 name return as nil value.
To list all components name on a form, I use:
Code:
for i = 0, formName.ComponentCount - 1 do
local compName = formName.Component[i].Name
print(compName)
end
--- this is work if call from form1.CT
But not work if call from form2.
So, how to get form1 components names call from form2? _________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Thanks DB for the details, I try it and find if components name and set parent for the components is important in case to initialize the components and their owner; which usually ignored by trainer creator.
This example just work fine.
Code:
if f1 then f1.Destroy() end
if f2 then f2.Destroy() end
----- Create Parent Form
f1 = createForm()
f1.setPosition(400,200)
b2.OnClick = function()
for i = 0, f1.ComponentCount-1 do
cb.Items.Add(f1.Component[i].Name)
end
end
f2.Hide()
And also I try to adopt Delphi function to get a control parent.
Code:
function GetParentForm(Control, TopForm)
TopForm = true
while (TopForm or not Control == 'TCEForm')and (Control.Parent ~= nil) do
Control = Control.Parent
if Control == 'TCEForm' then
Result = TCEForm(Control)
else
Result = nil
end
end
end
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum