View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon May 06, 2019 4:08 am Post subject: Unable to create CERadioButton by Lua Script |
|
|
Hi DB,
Just to let you know, CE Version: 6.8.3 32bit
CERadioButton is able to make under form designer, but not in Lua script.
So, I need to add this function to create RadioButton(s).
Code: | function createRadioButton(Parent)
local rb = createComponentClass('TRadioButton', Parent)
rb.Parent = Parent
return rb
end
f = createForm()
rbt = createRadioButton(f)
rbt.setPosition(5,5)
rbt.Caption = 'Test Radio Button'
rbt.Font.Color = '0xFFFFFF'
cbx = createCheckBox(f)
cbx.setPosition(5,25)
cbx.Caption = 'Test Checkbox'
cbx.Font.Color = '0xFFFFFF' |
But, no way to change the Font Color for CECheckBox and CERadioButton, both in form designer or Lua script. Yes, I know CECheckBox and CERadioButton depending to Enable Runtime Themes (in Delphi) or in winAPI must intercept the WM_PAINT windows message and implement the code to draw the control, but this is not a simple way.
Any chance to change Font Caption Color in CE Lua script?.
By now, I use a trick by making CERadioButton/CECheckBox and separate with CELabel as their captions.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Last edited by Corroder on Mon May 06, 2019 8:03 am; edited 1 time in total |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25291 Location: The netherlands
|
Posted: Mon May 06, 2019 4:23 am Post subject: |
|
|
Checkboxes and radiobuttons can not have their color changed. It's a windows thing.
To create a checkbox or radiobox with a custom font you have to draw your own control. I recommend a paintbox and in it's onPaint draw a square or circle followed by the text in whatever font and color you like, or as you mention, just a checkbox with no text and a label behind it
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon May 06, 2019 4:37 am Post subject: |
|
|
Thanks, DB. It's a clear answer.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25291 Location: The netherlands
|
Posted: Mon May 06, 2019 5:55 am Post subject: |
|
|
Perhaps one tip you hadn't thought about yet:
set the AutoSize property of the checkbox to false, set it so it's width encompasses the label, and then use bringToFront() to make the checkbox on top.
That way when you click on the label it'll also click on the checkbox, and tabbing through the form will also show a highlight around the label then
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25291 Location: The netherlands
|
Posted: Mon May 06, 2019 10:13 am Post subject: |
|
|
Code: |
f=createForm()
cb=createCheckBox(f)
lbl=createLabel(f)
lbl.caption='Something'
lbl.left=cb.left+cb.Height
lbl.Font.Color=0xff0000
cb.AutoSize=false
cb.Width=lbl.Width+cb.Height
cb.bringToFront()
|
This works for me
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon May 06, 2019 1:50 pm Post subject: |
|
|
I am sorry DB, yes it works for the checkbox. But since can't create RadioButton via Lua script:
Code: | f=createForm()
rbt = createRadioButton(f)
|
will give an error: ':2: attempt to call a nil value (global 'createRadioButton')'
With helper function:
Code: | function createRadioButton(Parent)
local rb = createComponentClass('TRadioButton', Parent)
rb.Parent = Parent
return rb
end
f = createForm()
rbt = createRadioButton(f) -- RadioButton created on the form
lbl=createLabel(f)
lbl.caption='Something'
lbl.left=rbt.left+rbt.Height
lbl.Font.Color=0xff0000
rbt.AutoSize=false
rbt.Width=lbl.Width+rbt.Height
rbt.bringToFront() |
Yes, it works.
This does not work when my first try, so this is my fault:
Code: | function createRadioButton(Parent)
local rb = createComponentClass('TRadioButton', Parent)
rb.Parent = Parent
return rb
end
f = createForm()
rbt = createRadioButton(f) -- RadioButton created on the form
rbt.AutoSize=false
rbt.bringToFront()
lbl=createLabel(f)
lbl.caption='Something'
lbl.left=rbt.left+rbt.width + 2 |
Thanks again
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
|