Label : texto centrado verticalmente
Moderator: Rathinagiri
- edufloriv
- Posts: 243
- Joined: Thu Nov 08, 2012 3:42 am
- DBs Used: DBF, MariaDB, MySQL, MSSQL, MariaDB
- Location: PERU
Label : texto centrado verticalmente
Saludos amigos,
¿ Alguien sabe si se puede alinear el texto en el centro VERTICALMENTE de los controles Label ?. Cuando le pongo una altura de 30 (HEIGTH 30) el texto se ve ligeramente ubicado hacia arriba, dejando más espacio abajo. Agradeceré cualquier ayuda al respecto. Saludos.
--------------------------------------------------------------------------------------------------------
Hi friends,
Does anyone know if it's possible to center the text in Label controls vertically? When I set the height to 30, the text appears slightly raised, leaving more space at the bottom. Any help would be greatly appreciated. Thanks.
¿ Alguien sabe si se puede alinear el texto en el centro VERTICALMENTE de los controles Label ?. Cuando le pongo una altura de 30 (HEIGTH 30) el texto se ve ligeramente ubicado hacia arriba, dejando más espacio abajo. Agradeceré cualquier ayuda al respecto. Saludos.
--------------------------------------------------------------------------------------------------------
Hi friends,
Does anyone know if it's possible to center the text in Label controls vertically? When I set the height to 30, the text appears slightly raised, leaving more space at the bottom. Any help would be greatly appreciated. Thanks.
Eduardo Flores Rivas
LIMA - PERU
- danielmaximiliano
- Posts: 2716
- Joined: Fri Apr 09, 2010 4:53 pm
- Location: Argentina
- Contact:
Re: Label : texto centrado verticalmente
Hola Edu : no entiendo bien pero puedes probar
pero si redimensionas la ventanaDEFINE LABEL <ControlName>
PARENT <ParentWindowName>
ROW <nValue>
COL <nValue>
VALUE <cValue>
ONCLICK <ActionProcedureName>
WIDTH <nWidth>
HEIGHT <nHeight>
AUTOSIZE <lValue> .T. por si cambias de tipo de letra en runtime
FONTNAME <cValue>
FONTSIZE <nValue>
ALIGNMENT Left | Right | Center
END LABEL
Code: Select all
FUNCTION ReCenter()
WITH OBJECT Form_1.Label_1
.COL := ( Form_1.WIDTH - .WIDTH ) / 2
.ROW := ( Form_1.HEIGHT - .HEIGHT ) / 2
END WITH
RETURN NIL*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
- serge_girard
- Posts: 3412
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Label : texto centrado verticalmente
Daniel,
This gives me syntax error....
Serge
This gives me syntax error....
Serge
There's nothing you can do that can't be done...
- danielmaximiliano
- Posts: 2716
- Joined: Fri Apr 09, 2010 4:53 pm
- Location: Argentina
- Contact:
Re: Label : texto centrado verticalmente
perdon el error ocurre porque no es un objeto
Code: Select all
#include "hmg.ch"
FUNCTION Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 600 ;
HEIGHT 400 ;
TITLE 'Label centrado con padding dentro de Frame' ;
MAIN ;
ON SIZE CenterLabelInFrame()
DEFINE FRAME Frame_1
ROW 60
COL 80
WIDTH 440
HEIGHT 200
CAPTION "Frame con padding"
END FRAME
DEFINE LABEL Label_1
VALUE "Texto centrado con margen interno"
AUTOSIZE .T.
END LABEL
DEFINE BUTTON Btn_1
ROW 300
COL 200
WIDTH 200
HEIGHT 30
CAPTION "Cambiar texto"
ACTION ChangeText()
END BUTTON
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
CenterLabelInFrame()
RETURN NIL
FUNCTION CenterLabelInFrame()
LOCAL nPadTop := 25
LOCAL nPadBottom := 10
LOCAL nPadLeft := 10
LOCAL nPadRight := 10
LOCAL nInnerWidth := Form_1.Frame_1.WIDTH - nPadLeft - nPadRight
LOCAL nInnerHeight := Form_1.Frame_1.HEIGHT - nPadTop - nPadBottom
Form_1.Label_1.COL := Form_1.Frame_1.COL + nPadLeft + ;
( nInnerWidth - Form_1.Label_1.WIDTH ) / 2
Form_1.Label_1.ROW := Form_1.Frame_1.ROW + nPadTop + ;
( nInnerHeight - Form_1.Label_1.HEIGHT ) / 2
RETURN NIL
FUNCTION ChangeText()
Form_1.Label_1.VALUE := ;
"Texto más largo centrado respetando padding del frame"
//Form_1.Label_1.AUTOSIZE := .T.
CenterLabelInFrame()
RETURN NIL*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
- serge_girard
- Posts: 3412
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Label : texto centrado verticalmente
Thanks DaNiElMaXiMiLiAnO !
There's nothing you can do that can't be done...
- edufloriv
- Posts: 243
- Joined: Thu Nov 08, 2012 3:42 am
- DBs Used: DBF, MariaDB, MySQL, MSSQL, MariaDB
- Location: PERU
Re: Label : texto centrado verticalmente
Daniel muchas gracias,
Aún no he tenido tiempo pero lo probaré. Saludos cordiales.
Aún no he tenido tiempo pero lo probaré. Saludos cordiales.
Eduardo Flores Rivas
LIMA - PERU
Re: Label : texto centrado verticalmente
You can center vertical LABEL control only if it has one line of text - try
HMG_ChangeWindowStyle(GetControlHandle("Label_1","Form_1"), 0x00000200 /*SS_CENTERIMAGE*/, NIL, .F., .T.)
you can also write
HMG_ChangeWindowStyle(Form_1.Label_1.Handle, 0x00000200 /*SS_CENTERIMAGE*/, NIL, .F., .T.)
Remember! It works only for one line labels!
HMG_ChangeWindowStyle(GetControlHandle("Label_1","Form_1"), 0x00000200 /*SS_CENTERIMAGE*/, NIL, .F., .T.)
you can also write
HMG_ChangeWindowStyle(Form_1.Label_1.Handle, 0x00000200 /*SS_CENTERIMAGE*/, NIL, .F., .T.)
Remember! It works only for one line labels!
Re: Label : texto centrado verticalmente
This may help. Not sure if this is what you are asking.
Code: Select all
#include "hmg.ch"
Function Main
DEFINE WINDOW Form_Main ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'Main Window' ;
MAIN
@ 50,50 LABEL Label_1 ;
WIDTH 500 HEIGHT 200 ;
VALUE "Click ME! "+ CRLF+ ;
"I am testing for hmg." + CRLF+ ;
"Seem to Work." ;
ACTION MsgInfo('Label Clicked!!!') ;
FONT 'Areal' SIZE 24 CENTERALIGN ;
tooltip 'Help Me'
@ 260,10 LABEL Label_2 ;
AUTOSIZE ;
VALUE '...' ;
ACTION {||{msgbox(this.name)}, { ,msginfo('test')}}
END WINDOW
Form_Main.Label_2.Value := 'Hello All, This Is An AutoSIzable Label!!!'
CENTER WINDOW Form_Main
ACTIVATE WINDOW Form_Main
Return
All The Best,
Franco
Canada
Franco
Canada
Re: Label : texto centrado verticalmente
This also works for column.
Code: Select all
@ 50,50 LABEL Label_1 ;
WIDTH 500 HEIGHT 200 ;
VALUE "Click "+ CRLF+ ;
"Me!" + CRLF+ ;
"Seems" + CRLF+ ;
"To "+ CRLF+ ;
" Work" ;
ACTION MsgInfo('Label Clicked!!!') ;
FONT 'Areal' SIZE 24 CENTERALIGN ;
tooltip 'Help Me'
All The Best,
Franco
Canada
Franco
Canada