[Gambas-user] A Beginner's Guide to Gambas

ron ronstk at ...239...
Tue Jul 3 01:30:39 CEST 2007


On Monday 02 July 2007 23:23, Benoit Minisini wrote:
> > PUBLIC SUB Form_Open()
> >      DIM hButton AS Button
> >      hButton = NEW Button (ME) AS "hButton"
> 


in top of your form do instead the FormOpen.
  PRIVATE hButton AS Button

  PUBLIC SUB Form_Open()
'     DIM hButton AS Button  '<----- Rem this line.
     hButton = NEW Button (ME) AS "hButton"

The fact is the hButton must be global in the form class.
It is now local in the Form_Open() 

For the  line in the Form_open meaning:
  hButton	: the variable to hold the handle to the object
  =
  NEW		: create new instance of the object
  Button	: the type of object
  (ME)		: where to place
  AS		
  "hButton"	: the 'name' part for event descriptors
		: as hButton_Click

On the events it goes to this sub routine starting with this name
The object properties however are available on the handle variable
and not the used name. 


i.e.
PUBLIC hButton as Button

  PUBLIC SUB Form_Open()
     hButton = NEW Button (ME) AS "MyFancyButton"
....


  PUBLIC SUB MyFancyButton_Click()
    hButton.caption = "Im the fancy button"


--
Ron




More information about the User mailing list