Jump to content

GUI


Recommended Posts

I am trying to vertically center text in a button I had read Help and none of these code options work can anyone tell me the magic

1

$Enter2 = GUICtrlCreateButton("Enter", 315, 25, 25, 60, $BS_VCENTER)

2

$Enter2 = GUICtrlCreateButton("Enter", 315, 25, 25, 60, BitOr($GUI_SS_DEFAULT_BUTTON,$BS_VCENTER))

3

$Enter2 = GUICtrlCreateButton("Enter", 315, 25, 25, 60)

GUICtrlSetState(-1, $BS_VCENTER)

Cheers

Ant..

Link to comment
Share on other sites

When I test it, they all work (as far as centered vertically). The text is still horizontal, but is centered vertically in the button. Did you think it would change the orientation of the text?

Klexen's only needed $BS_MULTILINE added:

#include <guiconstants.au3>

Opt("GuiOnEventMode", 1)

$hGUI = GUICreate("Test", 125, 310)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$Enter1 = GUICtrlCreateButton("Enter1", 50, 10, 25, 60, $BS_VCENTER)
$Enter2 = GUICtrlCreateButton("Enter2", 50, 80, 25, 60, BitOr($GUI_SS_DEFAULT_BUTTON,$BS_VCENTER))
$Enter3 = GUICtrlCreateButton("Enter3", 50, 150, 25, 60)
GUICtrlSetState(-1, $BS_VCENTER)
$Enter4 = GUICtrlCreateButton("E" & @CRLF & "n" & @CRLF & "t" & @CRLF & "e" & @CRLF & "r" & @CRLF & "4", 50, 220, 25, 80, $BS_MULTILINE)
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

When I test it, they all work (as far as centered vertically). The text is still horizontal, but is centered vertically in the button. Did you think it would change the orientation of the text?

Klexen's only needed $BS_MULTILINE added:

#include <guiconstants.au3>

Opt("GuiOnEventMode", 1)

$hGUI = GUICreate("Test", 125, 310)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$Enter1 = GUICtrlCreateButton("Enter1", 50, 10, 25, 60, $BS_VCENTER)
$Enter2 = GUICtrlCreateButton("Enter2", 50, 80, 25, 60, BitOr($GUI_SS_DEFAULT_BUTTON,$BS_VCENTER))
$Enter3 = GUICtrlCreateButton("Enter3", 50, 150, 25, 60)
GUICtrlSetState(-1, $BS_VCENTER)
$Enter4 = GUICtrlCreateButton("E" & @CRLF & "n" & @CRLF & "t" & @CRLF & "e" & @CRLF & "r" & @CRLF & "4", 50, 220, 25, 80, $BS_MULTILINE)
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

:whistle:

Those don't work on my machine..

Anixon, are you running vista? Because I am... And this is what PsaltyDS's code looks like...

Posted Image

Link to comment
Share on other sites

Thanks for the help this is the code modified

CODE
#include <guiconstants.au3>

Opt("GuiOnEventMode", 1)

$font = "times new roman"

$hGUI = GUICreate("Test", 125, 310)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

GUISetFont(6, 600, 1, $font)

$Enter5 = GUICtrlCreateButton("E n t e r",50,25,20,60,$BS_MULTILINE+$BS_VCENTER)

$Enter6 = GUICtrlCreateButton("E" & @CRLF & "n" & @CRLF & "t" & @CRLF & "e" & @CRLF & "r" , 50, 220, 20, 60, $BS_MULTILINE+$BS_VCENTER)

GUISetState()

While 1

Sleep(20)

WEnd

Func _Quit()

Exit

EndFunc

Solution 6 is probably better visually however the letters do not exactly line up vertically ("e" is a bit off) centred in the button. I misinterpreted vcenter to mean centred text displayed vertically (1 char per line centred) not horizontally centred text.

Is that as good as it gets?

Ant..

Link to comment
Share on other sites

Those don't work on my machine..

Anixon, are you running vista? Because I am... And this is what PsaltyDS's code looks like...

Posted Image

I guess I don't understand what was meant by "vertically center text in a button". I got the same as the screen shot above, and in each case it looks to me like the text is vertically centered in the button. The shape of the buttons was take from the code in the OP.

Can you give an example of what you wanted it to look like?

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

however the letters do not exactly line up vertically ("e" is a bit off) centred in the button.

Use fixed width fonts, such as Fixedsys/Courier New/Lucida Console/Verdana/etc. Edited by Siao

"be smart, drink your wine"

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...