[Lua] Transparency of CE via slider
Posted: Wed Aug 25, 2021 9:30 pm
This snippet creates a form and allows the user to set the transparency value in percentage, based on the slider position. It also shows how to create and set components and their options programmatically.
Can be used for the Lua Engine form also, just decomment the appropriate lines.
I hope someone finds this useful and as always, if you like it then please show your support by rating this post.
Code: Select all
if tSettings then tSettings.destroy() tSettings = nil end
if not tSettings then
local ce = getMainForm()
tSettings = CreateForm()
tSettings.Caption = 'Transparency settings'
tSettings.BorderStyle = bsToolwindow
tSettings.Width = ce.Width
tSettings.Height = 100
tSettings.Left = ce.Left + 5
tSettings.Top = ce.Top + (ce.Height + ((tSettings.Height / 2) - 15))
local tb = createTrackBar(tSettings)
tb.Height = 25
tb.Width = tSettings.Width
tb.Align = alTop
tb.ShowSelRange = false
tb.TickStyle = "tsNone"
tb.Min = 1
tb.Max = 255
tb.Position = 255
tSettings.Height = tb.Height
tb.OnChange = function()
local ce = getMainForm()
--local le = getLuaEngine()
local perc = ((tb.Position/255) * 100)
tSettings.Caption = ('Currently set to: %.f%% transparency'):format(perc)
--le.AlphaBlend = true
--le.AlphaBlendValue = tb.Position
ce.AlphaBlend = true
ce.AlphaBlendValue = tb.Position
end
tSettings.OnClose = function()
local ce = getMainForm()
--local le = getLuaEngine()
ce.AlphaBlend = false
--le.AlphaBlend = false
tSettings.destroy()
tSettings = nil
end
end
I hope someone finds this useful and as always, if you like it then please show your support by rating this post.