Jump to content

multilined and vcentered label


fisofo
 Share

Recommended Posts

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
Link to comment
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.

Link to comment
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?

Link to comment
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.
Link to comment
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.

Link to comment
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.
Link to comment
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.
Link to comment
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

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...