mikesdeman How do I cheat?
Reputation: 0
Joined: 26 Feb 2016 Posts: 1
|
Posted: Fri Feb 26, 2016 5:06 pm Post subject: Add Picture Background To Form |
|
|
Hi All.
I am having trouble adding a picture to a lua created form. I am using the following code to create the form:
Code: |
MainGUI = {}
MainGUI[1] = createForm(false)
setProperty(MainGUI[1] , "color", red2)
setProperty(MainGUI[1] , "ShowInTaskBar", 'stAlways')
setProperty(MainGUI[1] , "Position", "poScreenCenter")
setProperty(MainGUI[1] , "BiDiMode", "bdLeftToRight")
control_setSize(MainGUI[1], 425, 512)
form_show(MainGUI[1])
|
Following this code I have the following ImageAttach:
Code: |
function attachBackground(wc,tblFile)
local p = createPicture()
p.loadFromStream(findTableFile(tblFile).Stream)
wc.OnPaint = function(sender)
local c = sender.getCanvas()
local bitmap = p.getBitmap()
c.draw(0,0,bitmap)
end
end
attachBackground(MainGUI[1] ,[[bg1.png]])
|
Where bg1.png is a PNG file, of the same size as the form, attached via Table>Add File on CE.
I cannot seem to load up the picture, when the form loads it is always set to the colour defined by red2 variable. I am missing something so simple I know it!
EDIT
OK I've figured out why that code does sort of doesn't work. It works in principal but the trainer maker I used adds a panel on the form to which all of the other elements are added with the following code:
Code: |
MainGUI[2] = createPanel(MainGUI[1])
x,y = control_getSize(MainGUI[1])
control_setSize(MainGUI[2], x,y)
|
Substituting MainGUI[2] sending it to the function attachBackground does not work.
Thanks for any input.
EDIT:
I found a workaround by simply removing the panel and dumping the elements directly onto the form however it would still be nice to know how to change a panel picture background.
|
|