[Gambas-user] User Controls and Font resizing to fit content

Charlie Ogier charlie at cogier.com
Tue May 1 15:09:00 CEST 2018


Hi KK,

1/. You can right click on FMain in the 'Project window' (Press [F10] in 
the IDE to see which one is the 'Project window') and import a Form from 
another Gambas program

2/. Run this code in a new 'graphical' program

*' Gambas class file**
**
**hButton As Button**
**
**Public Sub Form_Open()**
**
**With Me**
**  .Width = 200**
**  .Height = 200**
**  .Arrangement = Arrange.Vertical**
**  .Padding = 5**
**  .Title = "Expand me!"**
**End With**
**
**hButton = New Button(Me)**
**hButton.Text = "W"**
**hButton.Expand = True**
**
**Form_Resize**
**
**End**
**
**Public Sub Form_Resize()**
**Dim siFontH As Short**
**
**If Me.Width > Me.Height Then**
**  siFontH = Me.Height**
**Else**
**  siFontH = Me.Width**
**End If**
**
**hButton.Font.size = siFontH / 2**
**
**End*

Charlie

On 01/05/18 13:39, KKing wrote:
> Sorry to repeat and if any is covered by wiki/doco but I didn't seem 
> to find any recent info on easily.
>
> 1. Does Gambas have a concept similar to the VB User Control concept
> (i.e. you build a control with the standard label/textbox/buttons save
> it and be able to reuse multiple times in another form)?
>
> 2. Suggestions if convenient way to get the font size to automatically
> change to fit provided text in a (can be any of) label/textbox/or other
> control?
>
> KK
>
>
>
> --------------------------------------------------
>
> This is the Gambas Mailing List:
> https://lists.gambas-basic.org/listinfo/user
>
> Search the list:
> https://lists.gambas-basic.org/cgi-bin/search.cgi
>
> Hosted by https://www.hostsharing.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180501/04f388db/attachment-0001.html>


More information about the User mailing list