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 


Create Button with an Icon

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Wed Jan 01, 2025 12:24 pm    Post subject: Create Button with an Icon Reply with quote

How to give a button an icon?

Using createButton() I can't even get hints despite adding the hint property and setting showhint to true.

I believe this is another kind of button used in Cheat Engine called SpeedButton. Allowing imageIndex and hints to show. But how do I create one?

And does createCECustomButton() help here if so could you please provide an example using createCECustomButton()?
Back to top
View user's profile Send private message Visit poster's website  
Dark Byte
Site Admin
Reputation: 468

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

PostPosted: Wed Jan 01, 2025 3:22 pm    Post subject: Reply with quote

speedbutton yes, but not currently implemented in CE.
And CECustomButton doesn't really help, though you can make a nice rounded button with it.

My suggestion is to use an image that changes when you click it. Maybe even change it when hovered over by the mouse (mouseenter/mouseleave)

_________________
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 
ICQ Number
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1478

PostPosted: Wed Jan 01, 2025 5:09 pm    Post subject: Reply with quote

Code:
if mf2 then mf2.Destroy() mf2=nil end

mf2 = createForm()
mf2.Caption="test"

local spbtn = {}

spbtn.btn7 = createComponentClass('TSpeedButton', mf2)
spbtn.btn7.Parent = mf2
spbtn.btn7.Height=25
spbtn.btn7.Left=75
spbtn.btn7.Top=75
spbtn.btn7.Width=125
spbtn.btn7.OnClick=function() print("Image Index: "..spbtn.btn7.ImageIndex) end

imglst1 = createImageList(mf2)
imglst1.Height = spbtn.btn7.Height - 8
imglst1.Left=2
imglst1.Top=4
imglst1.Width = 23

imgpath1 = [[C:\yourImageFolder\yourImageName.png]]
icn1 = createPicture()
icn1.loadFromFile(imgpath1)

img1=createImage(mf2)
img1.align=alClient
img1.stretch=true
srcbmp = createBitmap()
srcbmp = icn1.getBitmap()
imglst1.Add(srcbmp)

img1.Picture.Bitmap.Width=imglst1.Width
img1.Picture.Bitmap.Height=imglst1.Height
img1.Picture.Bitmap.Canvas.clear()
imglst1.draw(img1.Picture.Bitmap.Canvas,0,0,2)

spbtn.btn7.Images = imglst1
spbtn.btn7.ImageIndex = 0
spbtn.btn7.Caption="    MyButton    "

srcbmp.Destroy()
icn1.Destroy()
img1.Destroy()


-- or ..
Color buttons:
https://forum.cheatengine.org/viewtopic.php?t=621680

_________________
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 
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Wed Jan 01, 2025 6:13 pm    Post subject: Reply with quote

Thank you )
Back to top
View user's profile Send private message Visit poster's website  
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