Sign in to follow this  
Followers 0
Bert

two lines on a button

13 posts in this topic

#1 ·  Posted (edited)

I made a example script to show what I'm attempting:

#include <GuiConstants.au3>

GuiCreate("MyGUI", 392, 323,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Button1" & @CRLF & "test", 30, 30, 160, 70)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd
Exit

I want the button to be displayed so it says "button 1" above the word "test", instead of in one line, which it does now. Any ideas? I could do a pic, but I like to stay away from that, for I want to be able to change the text of the button depending on how a ini setting is configured.

Edit:I also know I can use $BS_MULTILINE, but that won't do what I want. I need to set what text is on each line, not just have it wrap

Edited by vollyman

Share this post


Link to post
Share on other sites



I came up with this, but the second line is to the left. I need that line to be centered also. The second line will have the variable text, so using spaces won't do it.

#include <GuiConstants.au3>

GuiCreate("MyGUI", 392, 323,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Button1" & @CRLF & "test", 30, 30, 150, 70, $BS_CENTER + $BS_MULTILINE)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>

GuiCreate("MyGUI", 392, 323,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Button1" & @CRLF & "test", 30, 30, 160, 70, $BS_MULTILINE)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
       ;;;
    EndSelect
WEnd
Exit



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

does the same thing. It will put the word "test" to the left, at the same indent as the word "button". How do I make the word "test" be centered on the button?

example of what it is doing now:

Example of what I want it to do:

Edited by vollyman

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Strange, they are both centred on my computer.

Running latest release on win xp pro sp2

Edit - typo

Edited by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

odd. I have SP2, and ...wait...let me update with the latest beta.

edit...nope...still happening..

anyone else tried the example to see if it works? It may just be my PC

I have Windows 2003 Server SP1, same as yours.

Share this post


Link to post
Share on other sites

I'm running the the latest release (which isn't beta in case you didn't know :P) and I get the

same as you volleyman. I'm also running WinXP SP2.

Share this post


Link to post
Share on other sites

I have figured out what the problem is. If I change to Windows classic theme I get the same as you but using the Windows XP theme I get it centred. I do not know how to fix it so that it is the same for both.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Looks like that is the problem... weird. I'm running WinXP SP2 with XP theme and its centered.

Edit: what about $BS_CENTER? From the help file - "Centers the text horizontally in the button rectangle." I tried switching to classic to test it, but it stayed the same even without the $BS_CENTER... I didn't restart though.

Edited by BPBNA

Share this post


Link to post
Share on other sites

Hi,

XP SP1 Theme XP centered!

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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