Jump to content

How to center the text in a group box


AndyS01
 Share

Recommended Posts

I would like to center the text on a Group box (GUICtrlCreateGroup()) along its top horizontal line, but I can't find any examples of this.

Can this be done?

Example script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

Example()

Func Example()
    Local $flags = 0, $iMsg = 0

    GUICreate("My GUI group")

    $flags = BitOR($flags, $WS_THICKFRAME)
    $flags = BitOR($flags, $ES_CENTER)

    GUICtrlCreateGroup("Group 1", 10, 20, 190, 140, $flags) ; I want to cnter "Group 1"

    GUICtrlCreateRadio("Radio 1", 20, 50, 50, 20)
    GUICtrlCreateRadio("Radio 2", 20, 70, 60, 50)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        $iMsg = GUIGetMsg()

        If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

 

Link to comment
Share on other sites

The group control is just a button so you need to use a button style flag and include the ButtonConstants.au3

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>

Example()

Func Example()
    Local $flags = 0, $iMsg = 0

    GUICreate("My GUI group")

    GUICtrlCreateGroup("Group 1", 10, 20, 190, 140, BitOr($WS_THICKFRAME, $BS_CENTER)) ; I want to cnter "Group 1"

    GUICtrlCreateRadio("Radio 1", 20, 50, 50, 20)
    GUICtrlCreateRadio("Radio 2", 20, 70, 60, 50)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        $iMsg = GUIGetMsg()

        If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

 

Edited by InunoTaishou
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

×
×
  • Create New...