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 


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
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 42

PostPosted: Fri Aug 13, 2021 4:58 am    Post subject: button with an icon Reply with quote

With menu items it is possible to change the icon of it by doing
Code:

menuItem.ImageIndex = 15


This puts a "refresh" icon on the left side of the text.

Is it possible to put that same "refresh" icon on a button?
Desired result:
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1247

PostPosted: Fri Aug 13, 2021 5:48 am    Post subject: Reply with quote

https://forum.cheatengine.org/viewtopic.php?p=5759431#5759431
_________________
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
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 42

PostPosted: Fri Aug 13, 2021 5:56 am    Post subject: Reply with quote

Aylin wrote:
https://forum.cheatengine.org/viewtopic.php?p=5759431#5759431


thats just loading a image from file. I wanna know if it's possible to use the icons already inside Cheat Engine(that's why I provided the picture examples)


edit:
okay, I figured it out
Code:

mf = createForm()
btn = createComponentClass('TSpeedButton', mf)
btn.Parent = mf
btn.Images = MainForm.mfImageList
btn.ImageIndex = 15
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Aug 14, 2021 9:01 pm    Post subject: Reply with quote

Honest, I am not read the post completely. Anyhow this a sample script I made for my custom CE 7.2.

Code:
function createSpeedButton(parent)
local sp = createComponentClass('TSpeedButton', parent)
 sp.parent = parent
 return sp
end

function createBitButton(parent)
local bb = createComponentClass('TBitBtn', parent)
 bb.parent = parent
 return bb
end

function createFontDialog(parent)
local fd = createComponentClass('TFontDialog', parent)
 fd.parent = parent
 return fd
end

function createStaticText(parent)
local st = createComponentClass('TStaticText', parent)
 st.parent = parent
 return st
end

function createColorListBox(parent)
local clb = createComponentClass('TColorListBox', parent)
 clb.parent = parent
 return clb
end

function createColorBox(parent)
local clbx = createComponentClass('TColorBox', parent)
 clbx.parent = parent
 return clbx
end

function createNoteBook(parent) -- better use PageControl
local nb = createComponentClass('TNotebook', parent)
 nb.parent = parent
 return nb
end

function createShape(parent)
local sh = createComponentClass('TShape', parent)
 sh.parent = parent
 return sh
end

function createBevel(parent)
local bv = createComponentClass('TBevel', parent)
 bv.parent = parent
 return bv
end

function createControlBar(parent)
local cbar = createComponentClass('TControlBar', parent)
 cbar.parent = parent
 return cbar
end

function createFlowPanel(parent)
local fpnl = createComponentClass('TFlowPanel', parent)
 fpnl.parent = parent
 return fpnl
end

function createApplicationProperties(parent)
local aprop = createComponentClass('TApplicationProperties', parent)
 aprop.parent = parent
 return aprop
end


--- Test
if f then f.Destroy() end
f = createForm()
f.Width = 600
f.Height = 500
f.Position = 'poScreenCenter'
f.Caption = 'Additional CE 7.2 Components+'


-- // Speed Button //-- J
sbn = createSpeedButton(f)
sbn.setSize(130,40)
sbn.setPosition(10,10)
sbn.Caption = 'Speed Button'
pic = createPicture()
pic.loadFromFile('D:\\save.png')
sbn.Glyph = pic.Bitmap
pic.Destroy()
sbn.OnClick = function()
 showMessage('You have been clicked SPEED BUTTON')
 return
end

-- // Panel //--
pnl = createPanel(f)
pnl.setSize(150,40)
pnl.setPosition(300, 10)
pnl.Caption = 'Panel'
-- pnl.Color = 'clRed' -- Not recognize

-- // Color Box //--
clbox = createColorBox(f)
clbox.setPosition(470, 10)
clbox.OnChange = function()
 pnl.Color = clbox.Selected
end


-- // Color List Box //--
clsb = createColorListBox(f)
clsb.setSize(130,170)
clsb.setPosition(10,60)
clsb.Items.Clear()
clsb.Items.Add(clRed, 255)
clsb.Items.Add(clYellow, 65535)
clsb.Items.Add(clGreen, 32768)
clsb.Items.Add(clBlue, 16711680)
clsb.OnSelectionChange = function()
 x = clsb.ItemIndex
 local col = clsb.Items[x]   -- can not recognize color name
 pnl.Color = col
end


-- // Speed Button  2//--
sbn1 = createSpeedButton(f)
sbn1.setSize(130,40)
sbn1.setPosition(150,10)
sbn1.Caption = 'Font Dialog'
pic = createPicture()
pic.loadFromFile('D:\\bold.png')
sbn1.Glyph = pic.Bitmap
pic.Destroy()
sbn1.OnClick = function()
 if fdl.Execute() then
    lbl.Font = fdl.Font
 end
end


-- // Font Dialog //--
fdl = createFontDialog(f)


-- // Static Text //--
lbl = createStaticText(f)
lbl.setPosition(150,60)
lbl.AutoSize = true
lbl.Caption = 'Cheat Engine 7.2 Static Text'


-- // Page Control to substitude TNoteBook //--
nbk = createPageControl(f)  -- Better than TNoteBook
nbk.setSize(200, 140)
nbk.setPosition(150, 90)
local tab = {}
for i = 1, 4 do
 tab[i] = nbk.addTab()
 tab[i].Caption = 'Page '..i
end


-- // Shape //--
shp = createShape(f)
shp.setSize(100,140)
shp.setPosition(360,90)
shp.Shape = 'stStarDown'
shp.Brush.Color = 65355
shp.Brush.Style = 0


-- // Bevel //--
bvl = createBevel(f)
bvl.setSize(100,140)
bvl.setPosition(470,90)
bvl.BorderStyle = 'bsNone'
bvl.Style = 'bsRaised'
bvl.Shape = 'bsFrame'
bvl.OnPaint = function()
bvl.Canvas.Pen.Color = 0xffffff
bvl.Canvas.Font.Size = 14
bvl.Canvas.Brush.Style = 1
bvl.Canvas.gradientFill(0,0,bvl.width,bvl.height,1212,552582,1)
bvl.Canvas.textOut(20,50,'Bevel')
end


-- // Control Bar //--
ctbar = createControlBar(f)  --- not effective without TMenuBar, TToolBar
ctbar.setSize(f.width,60)
ctbar.setPosition(0,250)
ctbar.AutoSize = true
-- Add speed button to control bar
sbn2 = createSpeedButton(ctbar)
sbn2.setSize(130,40)
sbn2.setPosition(10,10)
sbn2.Caption = 'Font Dialog'
pic = createPicture()
pic.loadFromFile('D:\\bold.png')
sbn2.Glyph = pic.Bitmap
pic.Destroy()
sbn2.OnClick = function()
 if fdl.Execute() then
    lbl.Font = fdl.Font
 end
end


-- // Flow Panel //--
fpan = createFlowPanel(f)
fpan.setSize(300,170)
fpan.setPosition(10,320)
fpan.FlowStyle = 'fsLeftRightTopBottom'
fpan.FlowLayout = 'tlCenter'
fpan.Autowrap = true
local i,LButton,LEdit
for i = 0, 10 do
 LButton = createButton(fpan)
 LButton.Parent = fpan
 LButton.Height = 30
 LButton.Caption = string.format('Status%d', i)
 LButton.AlignWithMargins = true
end
for i = 0, 6 do
 LEdit = createEdit(fpan)
 LEdit.Parent = fpan
 LEdit.Height = 30
 LEdit.Text = string.format('MyEdit%d', i)
 LEdit.AlignWithMargins = true
end


-- // Application Properties //-- need example to use this
app = createApplicationProperties(f)


new72 = [[
  registerclass(TFontDialog);
  registerclass(TBitBtn);
  registerclass(TSpeedButton);
  registerclass(TStaticText);
  registerclass(TShape);
  registerclass(TBevel);
  registerclass(TNotebook);  -- better use TPageControl
  registerclass(TLabeledEdit);
  registerclass(TControlBar);
  registerclass(TFlowPanel);
  registerclass(TApplicationProperties);
  registerclass(TColorListBox);

---- THIS PART BELOW CAN'T ADD AS CUSTOM COMPONENT
---- NEED CREATE NEW CLASS
  registerclass(TColorButton);
  registerclass(TSpinEdit);
  registerclass(TEditButton);
  registerclass(THTMLBrowserHelpViewer); -- need this
]]

NoteAfterTest = [[
1. ColorListBox -> can't handle ColorListBox.Selected method
                   to assign color to components.
                   Can not set 'color rect, color name' on the
                   color listbox.

2. NoteBook -> Better use TPageControl.

3. BitButton -> Can not add glyph.

4. Other, ListView -> imagelist, still show one image event there are
                       more than one image on the image list.

5. ControlBar -> need TMenuBar, TToolBar ?

6. ApplicationProperties -> need study this one

7. -- // Speed Button //-- Just work fine
8. -- // Color Box //-- Just work fine
9. -- // Font Dialog //-- Just work fine
10.-- // Static Text //-- Just work fine
11.-- // Shape //-- Just work fine
12.-- // Bevel //-- Just work fine
13.-- // Flow Panel //-- Just work fine

14.Need THTMLBrowserHelpViewer
]]


I remember to edit a .pas file in CE 7.2 source code and recompile with Lazarus.

OR

Use some WINAPI functions to create windows and module handles

_________________
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