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 


Changing Class Components Color At The Run Time

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

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Oct 04, 2020 5:40 am    Post subject: Changing Class Components Color At The Run Time Reply with quote

This is very simple tutorial which everyone can do it without learns 12 years or more. Laughing Laughing Laughing

Since I have seen many peoples created their own CE Game Trainer and arranged the trainer with some colors, but I never saw they use 'ColorBox' which can use to change the trainer class components color at the run time.

So, this is a simple script to show how to using ColorBox and link the ColorBox change to change a color label on a form.

Code:
function createColorBox(Parent)
local box = createComponentClass('TColorBox', Parent)
 box.Parent = Parent
 return box
end

if f then f.Destroy() end
f = createForm()
f.Position = 'poScreenCenter'
f.Caption = 'Color Box Tester'
f.Color = 0xffffff  -- white

clrbox = createColorBox(f)
clrbox.left = 10
clrbox.top = 10
clrbox.width = 150
clrbox.height = 150
clrbox.style = [['cbStandardColors', 'cbExtendedColors', 'cbSystemColors',
                 'cbIncludeNone', 'cbIncludeDefault']]
clrbox.ItemIndex = 0

label1 = createLabel(f)
label1.setPosition(12, 75)
label1.Caption = 'Hello World'
label1.Font.Size = 42

function colorboxChange(sender)
  label1.Font.Color = clrbox.Selected
end

f.Show()
clrbox.OnChange = colorboxChange


On the example, if we select a color on the color box then the label color also change according to the selected color.
You can use the method to change other components on your game trainer form including the form itself.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Sun Oct 04, 2020 3:30 pm    Post subject: Reply with quote

To get the numerical value, this works well; Wink

EDIT :

Code:
local clrNum=tonumber(clrbox.Selected)

label1 = createLabel(f)
label1.setPosition(12, 75)
label1.Caption = 'Color: '..clrNum
label1.Font.Size = 22

function colorboxChange(sender)
  label1.Font.Color = clrbox.Selected
  clrNum=tonumber(clrbox.Selected)
  label1.caption="Color: "..clrNum
end

label1.OnClick=function()
writeToClipboard(clrNum)
end


Good job, good idea. Thanks.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials 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 cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites