[Gambas-user] How to extend properties of classes
Fabien Bodard
gambas.fr at ...626...
Thu Jan 10 23:26:30 CET 2008
Le Thursday 10 January 2008 23:03:18 richard terry, vous avez écrit :
> I've used the code in CCoolButton to construct an 'outlook style' side bar
> (like in gambas itself), but want a couple of extra properties.
>
> I want to be able to have a popup menu (done that and works) which allows
> the user to change the font size on the buttons.
>
> I did fiddle and try and create Font_Read and Font_Write in the file (by
> coping the structure of the other entries), but it comes up 'null object',
> so I wondered if someone could quickly explain how one extends the
> properties of an object like this.
>
> Tried something like adding this to the file:
>
> PRIVATE SUB Font_Write(Value AS String)
>
> ' $hLabel.Font = Value
>
> END
> PRIVATE FUNCTION Font_Read() AS String
> ' hFont = $hLabel.Font
> RETURN $hLabel.Font
>
> END
>
> Hope that makes sense as I don't understand what I'm doing.
>
> Regards
>
> Richard
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplac
>e _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
:)
Me for a new time...
Add this ion the header of the class :
Property {Font} as Font
then at the bottom :
Sub Font_Write(Value as Font)
hLabel.Font = Value
End
Function Font_Read() as Font
Return hLabel.font
End
i'm not sur for hLabel it is maybe another name
So now to use it :
For example from string
hButton.Font = Font["Bold, 16, Arial"]
For example from object
hButton.Font = Form.Font
For example just modifi the font :)
hButton.Font.Size = 1
hButton.Font.Name = "Arial"
etc...
More information about the User
mailing list