[Gambas-user] Custom Class question

tobias tobiasboe1 at ...20...
Tue Jan 25 17:37:47 CET 2011


hi,
i have a question about some source code from fabien from 8th november 
2009 about creating custom controls:

"I think for the begginnig you must to do an encapsulating classe.

It's a class that take a control as parameter. And give to it new
function or feature.

so:

=============================================================

CLASS CColourCombo

Private $hComboBox
Private $hObs as new Observer
Public sub _New(hCombo as ComboBox)

   $hComboBox = hCombo
   $hOBS=NEW Observer(hCombo) AS "MyCombo"
End


PUBLIC SUB MyCombo_Change()

   If $hCombox.Current.Text<0 then
     $hComboBox.BackColor=Color.Red
   else
     $hComboBox.BackColor=Color.White
   endif
end
====================================
'Form

Now in your form just add
Public sub _New
dim hCColourCombo as CColourCombo

hCColourCombo = new CColourCombo(MyComboBox)

endif


END

======================================
I think for the begginnig you must to do an encapsulating classe.




And now you have a combo box that change backcolour when the selected
value is negative !

It's more simple than a control if you have no so many feature to add.


Fabien"

i quite can't make this working for me. i corrected this a bit but in 
the forms _new() i get "Not enough arguments" in the creation of the 
CColourCombo: hCColourCombo = new CColourCombo(MyComboBox)




More information about the User mailing list