In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Making TLables in code ... strange Font and Width behaviour
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Making TLables in code ... strange Font and Width behaviour
Happy New Year to everyone, but still doing a bit of work in 2015.
A simple test program with a mainform and making 3 TLabels in code. All 3 TLabels have same width and height. Xailer 4.0
All works OK as expected without any lBold
When I make TLabel3, :lBold := TRUE ...
- All 3 TLabels go bold?
- TLabel1 & TLabel2 chop of some text on the right hand side, nWidth has changed?
Here is my simple code ....
METHOD FormInitialize( oSender ) CLASS TForm1
local oLabel1, oLabel2, oLabel3
oLabel1 := TLabel():New( self )
oLabel1:SetBounds( 200, 150, 300, 30 )
oLabel1:cText := "In Code, TLabel 300 wide"
oLabel1:Create()
oLabel2 := TLabel():New( self )
oLabel2:SetBounds( 200, 200, 300, 30 )
oLabel2:cText := "In Code Red, TLabel 300 wide"
oLabel2:nClrText := CLR_RED
oLabel2:Create()
oLabel3 := TLabel():New( self )
oLabel3:SetBounds( 200, 250, 300, 30 )
oLabel3:cText := "In Code Red and this one BOLD, TLabel 300 wide"
// Without this line .... all TLabels are OK
// When I include this line .... all TLabels go BOLD!!
oLabel3:oFont:lBold := TRUE
// Adding these lines to give oLabel3 its own oFont .... does not solve the problem.
// oLabel3:lParentFont := .F.
// oLabel3:oFont := TFont():Create( "MS Sans Serif", 8, 0, 400 )
oLabel3:nClrText := CLR_RED
oLabel3:Create()
RETURN Nil
So question is what am I doing wrong or what is going on here?
Thank you for any thoughts.
Chris
A simple test program with a mainform and making 3 TLabels in code. All 3 TLabels have same width and height. Xailer 4.0
All works OK as expected without any lBold
When I make TLabel3, :lBold := TRUE ...
- All 3 TLabels go bold?
- TLabel1 & TLabel2 chop of some text on the right hand side, nWidth has changed?
Here is my simple code ....
METHOD FormInitialize( oSender ) CLASS TForm1
local oLabel1, oLabel2, oLabel3
oLabel1 := TLabel():New( self )
oLabel1:SetBounds( 200, 150, 300, 30 )
oLabel1:cText := "In Code, TLabel 300 wide"
oLabel1:Create()
oLabel2 := TLabel():New( self )
oLabel2:SetBounds( 200, 200, 300, 30 )
oLabel2:cText := "In Code Red, TLabel 300 wide"
oLabel2:nClrText := CLR_RED
oLabel2:Create()
oLabel3 := TLabel():New( self )
oLabel3:SetBounds( 200, 250, 300, 30 )
oLabel3:cText := "In Code Red and this one BOLD, TLabel 300 wide"
// Without this line .... all TLabels are OK
// When I include this line .... all TLabels go BOLD!!
oLabel3:oFont:lBold := TRUE
// Adding these lines to give oLabel3 its own oFont .... does not solve the problem.
// oLabel3:lParentFont := .F.
// oLabel3:oFont := TFont():Create( "MS Sans Serif", 8, 0, 400 )
oLabel3:nClrText := CLR_RED
oLabel3:Create()
RETURN Nil
So question is what am I doing wrong or what is going on here?
Thank you for any thoughts.
Chris
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: Making TLables in code ... strange Font and Width behaviour
Hmmm .... images in my post seem to be the wrong way round and I don't seem to be able to edit the sequence of the images and save it.
Non Bold OK image should be the first one in the post.
lBold = TRUE with All TLabels in Bold? and strange width effects should be in the second position.
Sorry to make this confusing!
Chris
Non Bold OK image should be the first one in the post.
lBold = TRUE with All TLabels in Bold? and strange width effects should be in the second position.
Sorry to make this confusing!
Chris
- ignacio
- Site Admin
- Mensajes: 9246
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Re: Making TLables in code ... strange Font and Width behaviour
Hello,
Change the property lParentFont to FALSE and lAutoSize to FALSE on TLabel controls.
Regards,
Change the property lParentFont to FALSE and lAutoSize to FALSE on TLabel controls.
Regards,
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: Making TLables in code ... strange Font and Width behaviour
Hi Ignacio,
Thanks for the reply.
The two properties, lParentFont to FALSE and lAutoSize to FALSE, have solved my length problems
I still have a problem with the line
TLable3:oFont:lBold
This is setting all my labels to bold
Should I be making a new oFont for oLabel3 ?
Hopefully nearly there.
Chris
Thanks for the reply.
The two properties, lParentFont to FALSE and lAutoSize to FALSE, have solved my length problems
I still have a problem with the line
TLable3:oFont:lBold
This is setting all my labels to bold
Should I be making a new oFont for oLabel3 ?
Hopefully nearly there.
Chris
Re: Making TLables in code ... strange Font and Width behaviour
Chris,
fonts are shared (by default) among all controls in the form. So, when you write ::oLabel3:oFont:lBold := .F., you are changing that font attribute for all controls.
The way to change it for only one control is by creating a new font for it: ::oLabel3:oFont := TFont():Create( "MS Sans Serif", 9,, 700 )
fonts are shared (by default) among all controls in the form. So, when you write ::oLabel3:oFont:lBold := .F., you are changing that font attribute for all controls.
The way to change it for only one control is by creating a new font for it: ::oLabel3:oFont := TFont():Create( "MS Sans Serif", 9,, 700 )
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: Making TLables in code ... strange Font and Width behaviour
Jose,
Thanks for the confirmation that fonts are shared by all controls on the form and how to get round it.
Slightly different subject ..... is the any way of making a Label with a basic text colour but highlighting one or two characters in another characters ?
I suspect not easy, maybe the possibility of using two controls one in basic colour and an cleverly positioned second control in the highlight colour ?
Any other thoughts, please.
Thanks
Chris
Thanks for the confirmation that fonts are shared by all controls on the form and how to get round it.
Slightly different subject ..... is the any way of making a Label with a basic text colour but highlighting one or two characters in another characters ?
I suspect not easy, maybe the possibility of using two controls one in basic colour and an cleverly positioned second control in the highlight colour ?
Any other thoughts, please.
Thanks
Chris
- ignacio
- Site Admin
- Mensajes: 9246
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Re: Making TLables in code ... strange Font and Width behaviour
Take a look at TLabelEx and this sample:
\xailer\samples\LabelEx.
Regards,
\xailer\samples\LabelEx.
Regards,
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: Making TLables in code ... strange Font and Width behaviour
Hi Ignacio,
TLabelEx looks very promising for what I have in mind ... thank you.
My last wish is for the same text flebility in Tbutton objects .... that would make my life complete, at the moment!!
I dont know what else you have planned for Xailer over the coming months and years but maybe a UI with more HTML possibilities?
Would be nice but I have absolutely no idea how it could be done!!
Thanks again.
Chris
TLabelEx looks very promising for what I have in mind ... thank you.
My last wish is for the same text flebility in Tbutton objects .... that would make my life complete, at the moment!!
I dont know what else you have planned for Xailer over the coming months and years but maybe a UI with more HTML possibilities?
Would be nice but I have absolutely no idea how it could be done!!
Thanks again.
Chris