Sign in to follow this  
Followers 0
fisofo

multilined and vcentered label

14 posts in this topic

#1 ·  Posted (edited)

I can't seem to create a label that has text in it that is split into two lines (using Chr(13)) and that can also be centered horizontally and vertically.

Haven't seen this in the forums, anyone know how?

edit: and on a related note, is there a simple way of getting the text from a label? GUICtrlRead doesn't seem to be doing it...

edit2: here's some more details i should provide:

If I apply style: $SS_CENTER, I can get multiple lines, but the are not vertically centered

If I apply style: $SS_CENTERIMAGE, it centers it vertically, but the Chr(13) gets screwed up and everything is on one line.

If I BitOr those two together, it centers everything correctly, but it's all on one line, the Chr(13) doesn't make it through :P

Edited by fisofo

Share this post


Link to post
Share on other sites



I can't seem to create a label that has text in it that is split into two lines (using Chr(13)) and that can also be centered horizontally and vertically.

Haven't seen this in the forums, anyone know how?

edit: and on a related note, is there a simple way of getting the text from a label? GUICtrlRead doesn't seem to be doing it...

edit2: here's some more details i should provide:

If I apply style: $SS_CENTER, I can get multiple lines, but the are not vertically centered

If I apply style: $SS_CENTERIMAGE, it centers it vertically, but the Chr(13) gets screwed up and everything is on one line.

If I BitOr those two together, it centers everything correctly, but it's all on one line, the Chr(13) doesn't make it through :P

Forums are quiet tonight :D

Well, If someone has an idea, feel free to post, but for the time being I got around both of these issues:

- for getting the text, I created an array based on the Control ID and stored the text there

- for the positioning problem: I was trying to center the text not necessarily in a label, but over a button... since I know I will always have only 2 lines of text, I calculated that the Top position for the label should be

$ButtonTop + $ButtonHeight/2 - 15
The 15 I estimated by measuring the actual text, could be 14 too, it's close.

anyway, just thought that might be helpful to someone... i'd post code w/ more detail, but i think it's pretty easy conceptually.

Share this post


Link to post
Share on other sites

Did you ever think to try adding a line feed to your carriage return?

Share this post


Link to post
Share on other sites

Did you ever think to try adding a line feed to your carriage return?

tried chr(10), chr(13), @LF, and @CRLF and in different combinations, but combined with $SS_CENTERIMAGE, they just come through as little boxes and everything is on one line.

does it work for you?

Share this post


Link to post
Share on other sites

Taken straight from the documentation for $SS_CENTERIMAGE from the AutoIt help file:

It can be used with static control having only one line of text.

Share this post


Link to post
Share on other sites

Taken straight from the documentation for $SS_CENTERIMAGE from the AutoIt help file:

The original question was for text which is split into 2 lines so maybe the image is not needed. A label can have many lines and they can be centred, you just need to make sure the height of the label is enough to contain all of the text.

Here is an example

#include <GUIConstants.au3>

$Form1 = GUICreate("AForm1", 415, 300, 320, 252)
$Label1 = GUICtrlCreateLabel("a label which has more than 1 line and is centered", 104, 72, 88, 89, $SS_CENTER)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I think you missed the part where the OP wants it centered vertically which is what SS_CENTERIMAGE does. Presumably, the control's height is not going to be too small, rather, it's going to be pretty big, hence the desire to center the text vertically inside the space.

Share this post


Link to post
Share on other sites

I think you missed the part where the OP wants it centered vertically which is what SS_CENTERIMAGE does. Presumably, the control's height is not going to be too small, rather, it's going to be pretty big, hence the desire to center the text vertically inside the space.

Yes Valik, I did miss the Vertically bit. Tx


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

tried chr(10), chr(13), @LF, and @CRLF and in different combinations, but combined with $SS_CENTERIMAGE, they just come through as little boxes and everything is on one line.

does it work for you?

If you use $SS_CENTER it gives the horizontal centering. (I know you know that.)

If the height of the label is fixed, and you know how many lines it can hold, then could you simply add @CR a few times before the lines for the label to get how many lines of text you want.

I've tried it and it looks ok to me.

edit: and on a related note, is there a simple way of getting the text from a label? GUICtrlRead doesn't seem to be doing it...

GuiCtrlRead read the label text fine.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I think you missed the part where the OP wants it centered vertically which is what SS_CENTERIMAGE does. Presumably, the control's height is not going to be too small, rather, it's going to be pretty big, hence the desire to center the text vertically inside the space.

Sorry for OFF topic.

Can somebody please tell me what OP abbreviation means?

I know from context it's creator of post with original question but I don't know from which word it comes.

In my mind is only OPerator which is nonsense for this situation and

I found with GOOGLE possible:

Observation Post

Order Processing

Opposite Prompt

I'm not native English speaker, so be gentle.

Thanks

Share this post


Link to post
Share on other sites

Original Poster.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Original Poster

.... Ahhhh, Valik was quicker than me!

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

If you use $SS_CENTER it gives the horizontal centering. (I know you know that.)

If the height of the label is fixed, and you know how many lines it can hold, then could you simply add @CR a few times before the lines for the label to get how many lines of text you want.

I've tried it and it looks ok to me.

GuiCtrlRead read the label text fine.

not if the height is say... 40 and you have 2 lines of text. the code i posted earlier works brilliantly (if i do say so myself :P

$ButtonTop + $ButtonHeight/2 - 15

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0