Sign in to follow this  
Followers 0
PatL

Centering while wrapping text in a button control

17 posts in this topic

What do I need to do to both wrap and center the text in a button control?

Thanks

Share this post


Link to post
Share on other sites



Thanks. I tried the code and added a long text string. It was still left justified as if I had simply used the $BS_MULTILINE style by itself.

Share this post


Link to post
Share on other sites

Thanks. I tried the code and added a long text string. It was still left justified as if I had simply used the $BS_MULTILINE style by itself.

Are you saying it isn't looking like this on your computer?

Posted Image


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Yes. I wonder what is different on my computer

Share this post


Link to post
Share on other sites

Is there a reason that "BitOr($BS_CENTER ,$BS_MULTILINE" will not center my text as it is supposed to? The text word wrapped but remains left justified.

Share this post


Link to post
Share on other sites

Works fine for me:

#include <GUIConstantsEx.au3>
GUICreate("")
GUICtrlCreateButton("this is my button" & @CRLF & "Click here", 10, 10, 200, 50, BitOR($BS_CENTER, $BS_MULTILINE))
GUISetState()
While GUIGetMsg() <> -3
WEnd


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Right. I was hoping someone has an idea why it may be different on my system. I am running XP SP3

I'm ran it on XP Pro SP3 with no issues...

Next time don't double post ... and you might want to take the time to think about what you are going to ask before you start typing ... if what you asked isn't what you really want to know.

Edited by SmOke_N
Merged topics

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

hi

I am new to AutoIt and this forum and I am having a similar problem. I tried to center multiline text on a button control AND colour it and I am not having any success. I have tried using the styles and GUICtrlSetStyle and nothing works.

BTW: That IS how we spell colour in SA.

CODE

$ButT10 = GUICtrlCreateButton($But10[2], 385, 240, 84, 49, $BS_MULTILINE+$BS_VCENTER)

;GUICtrlSetBkColor(-1, 0xB9F8AE)

Share this post


Link to post
Share on other sites

Where a problem?

#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>

$hGUI = GUICreate("Test GUI", 200, 100)

$button = GUICtrlCreateButton("Button with" & @LF & "multiline text", 60, 40, 75, 40, BitOR($BS_MULTILINE, $BS_CENTER))
GUICtrlSetBkColor(-1, 0xB9F8AE)

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Sorry for the late reply, I'm in SA and our time zones...

the problem is that the text on the button is read from a string inside an array, which in turn is read from a database. I cannot add the @LF coz I don't know what text will be in there. try this:

$col2 = 0xB9F8AE

$ButT10 = GUICtrlCreateButton($But10[2], 385, 240, 84, 49, BitOR($BS_MULTILINE, $BS_CENTER))

GUICtrlSetBkColor(-1, $col2)

the text inside the string is 'Print Blk Text Colour Picture'. When not coloured the text is wrapped nicely and centred. As soon as I add the colour code, the text reverts back to single line AND jumps to the top of the button.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Create the Ownerdraw button. Example there is in help, see GUIRegisterMsg() function.

Edited by rasim

Share this post


Link to post
Share on other sites

Thank you, rasim, i will try that.

Share this post


Link to post
Share on other sites

Since we are on the topic of centering, can someone tell me how to get my text in the variable ($author) to be centered. Basically i wrote an admin tool for techs at my work and I would like to have the about me info centered. So far my work around has been to use spaces in between the " ".

Case $msg = $aboutitem
                Msgbox(0,"About", $me )

$Author = "IT Microsystems Technicians" & @LF & "  Troubleshooting Tool" & @CRLF & "   Version 1.2" & @CRLF & "   Created by " & @LF & "   Jason Morgan"
$me = StringAddCR($Author)

Go farther, go further, Go Harder,Is that not why we came?And if not then why bother?

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