Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Unable to create CERadioButton by Lua Script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 06, 2019 4:08 am    Post subject: Unable to create CERadioButton by Lua Script Reply with quote

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
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25291
Location: The netherlands

PostPosted: Mon May 06, 2019 4:23 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 06, 2019 4:37 am    Post subject: Reply with quote

Thanks, DB. It's a clear answer.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25291
Location: The netherlands

PostPosted: Mon May 06, 2019 5:55 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 06, 2019 8:00 am    Post subject: Reply with quote

Nah DB, yes hadn't thought about yet. I tried your method and it works properly. Thanks for the useful tip. Very Happy

EDIT :
It works on form designer interface but not on Lua script.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25291
Location: The netherlands

PostPosted: Mon May 06, 2019 10:13 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 06, 2019 1:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites