AylinCE Grandmaster Cheater Supreme
Reputation: 34
Joined: 16 Feb 2017 Posts: 1462
|
Posted: Sun Feb 02, 2020 10:11 pm Post subject: Form-Color Button with simple codes |
|
|
I am updating this topic from the beginning again.
Version: 2
Add and use colored buttons to your trainer.
To use the code, you need to process the following data respectively;
Code: | createColorButton(form,hg,wd,lf,tp,cpt,pct1,pct2,pctShd,onclk) |
form: Your form name. (UDF1, CETrainer etc.)
hg: Height of the button.
wd: The width of the button.
lf: The left of the button.
tp: The top of the button.
pct1: The picture that should be in the "on" position.
pct2: The picture that should be in the "off" position.
pctShd: Shadow effect for button (image)
onclk: The name of the function that should be activated when the button is clicked.
( A small image archive is shared below.
Download it and add it to Trainer via CE >> Table >> Add file. )
Here is a usage example;
Code: | f1 = createForm(true)
f1.Position = poDesktopCenter
f1.Width = 320
f1.Height = 200
f1.caption = "Color Button"
function createColorButton(form,hg,wd,lf,tp,cpt,pct1,pct2,pctShd,onclk)
local owner = { }
owner.img1 = createImage(form)
owner.img1.Height=hg owner.img1.Width=wd
owner.img1.Left=lf owner.img1.Top=tp
owner.img1.Stretch = true
owner.img1.Picture=pct1
owner.Picture =owner.img1.Picture
owner.img2 = createImage(form)
owner.img2.Height=tonumber(hg) + 3
owner.img2.Width=wd
owner.img2.Left=lf
owner.img2.Top=tp
owner.img2.Stretch = true
owner.img2.Picture=pctShd
owner.lbl1 = createLabel(form)
owner.lbl1.AutoSize = false
owner.lbl1.Alignment= "taCenter"
owner.lbl1.Height=owner.img1.Height - 16
owner.lbl1.Width=owner.img1.Width - 8
owner.lbl1.Left=owner.img1.Left + 4
owner.lbl1.Top=owner.img1.Top + 8
owner.lbl1.Font.Size=11
owner.lbl1.Font.Style="fsBold"
owner.lbl1.OptimalFill = true
owner.lbl1.caption=(cpt.." OFF") owner.lbl1.Cursor= -21
owner.lbl1.bringToFront()
owner.lbl1.OnClick=function(sender)
if owner.lbl1.caption==(cpt.." OFF") then
owner.lbl1.caption=(cpt.." ON")
owner.img1.Picture=pct2
onclk(sender)
else
owner.lbl1.caption=(cpt.." OFF")
owner.img1.Picture=pct1
onclk(sender)
end
end
end
function crtPicture(pct)
local p = createPicture()
fstream = findTableFile(pct).Stream
p.loadFromStream(fstream)
return p
end
--##################################################
aa1 = 1
aa2 = 1
aa3 = 1
function printer1(sender)
if aa1==1 then
print(1,sender.Caption)
aa1=2
else
print(2,sender.Caption)
aa1=1
end
end
function printer2(sender)
if aa2==1 then
print(11,sender.Caption)
aa2=2
else
print(12,sender.Caption)
aa2=1
end
end
function printer3(sender)
if aa3==1 then
print(21,sender.Caption)
aa3=2
else
print(22,sender.Caption)
aa3=1
end
end
p1 = crtPicture("Btn1.png")
p2 = crtPicture("Btn2.png")
p3 = crtPicture("BtnShdw1.png")
createColorButton(f1,30,100,30,40,"Hack 1",p1,p2,p3,printer1)
createColorButton(f1,40,120,180,60,"Hack 2",p1,p2,p3,printer2)
createColorButton(f1,50,110,30,90,"Hack 3",p1,p2,p3,printer3) |
If you want more variety for the buttons, feel free to write in the comments.
Enjoy it!
Description: |
|
Filesize: |
2.74 KB |
Viewed: |
7078 Time(s) |

|
Description: |
|
Filesize: |
59.69 KB |
Viewed: |
7078 Time(s) |

|
Description: |
|
Filesize: |
53.15 KB |
Viewed: |
7078 Time(s) |

|
Description: |
|
Filesize: |
33.35 KB |
Viewed: |
7078 Time(s) |

|
Description: |
|
Filesize: |
31.13 KB |
Viewed: |
12551 Time(s) |

|
_________________
|
|