[Gambas-user] making a gui without form editor
Benoit Minisini
gambas at ...2...
Tue May 6 13:53:33 CEST 2003
Le Lundi 5 Mai 2003 19:23, Jochen Georges a écrit :
> hi gambasians
>
> i try to make a program with gui, but i do not want to use the form
> editor.
>
> with the following code i get a form, but without button and label.
>
> can anybody give me a hint?
>
> many thanks !
>
> beste gruesse
> jochen
> '--------------------------------------------------------------------------
>------ ' Gambas class file
> STATIC hForm AS Form
> hButton AS Button
> hLabel AS Label
>
> STATIC PUBLIC SUB Main()
> hForm = NEW Form
> hForm.X = 20
> hForm.Y = 20
> hForm.Width = 500
> hForm.Height = 500
> hForm.show
> END
>
> PUBLIC SUB _new()
> hButton = NEW Button(hForm) AS "Button1"
> hButton.X = 8
> hButton.Y = 30
> hButton.Width = 80
> hButton.Height = 40
> hButton.Text = "hello"
> hButton.show
> hLabel = NEW Label(hForm) AS "Label1"
> hLabel.X = 8
> hLabel.Y = 100
> hLabel.Width = 200
> hLabel.Height = 40
> hLabel.show
> END
>
> PUBLIC SUB Button1_click()
> hLabel.Text = "hello hello"
> END
>
Your _new() function is the constructor of your class, not of the Form class.
So when you do hForm = new Form, this constructor is never called.
You should do hForm = new MyClass (if the file you sent is MyClass.class)
and put the form in a non-static variable of MyClass, and the code of Main()
in _new().
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list