Jump to content

GUICtrlCreateGroup rectangle colored


faustf
 Share

Recommended Posts

This example uses a graphic control to draw a border around a group control and fill with colour, if require.

#include <GUIConstantsEx.au3>

Opt("GUICoordMode", 1) ; 1=(default)absolute, 0=relative, 2=cell

Example()

Func Example()
    Local $hGui = GUICreate("My GUI group") ; will create a dialog box that when displayed is centered
    GUISetBkColor(0xFFFFE0) ; <--------- Comment out for non-coloured GUI background.

    ; Group A controls
    Local $iLeft = 190, $iTop = 60, $iWidth = 90, $iHeight = 140, $iColorA = 0x0000FF, $GroupACol = $GUI_BKCOLOR_TRANSPARENT ; 0xFFFFE0 ;
    GUICtrlCreateGroup("Group A", $iLeft, $iTop, $iWidth, $iHeight)
    GUICtrlSetBkColor(-1, $GroupACol)
    ;GUIStartGroup()
    Local $idRadio_1 = GUICtrlCreateRadio("Radio 1", 210, 90, 60, 20)
    GUICtrlSetBkColor(-1, $GroupACol)
    Local $idRadio_2 = GUICtrlCreateRadio("Radio 2", 210, 110, 60, 50)
    GUICtrlSetBkColor(-1, $GroupACol)

    ; Group B controls
    Local $iLeftB = 50, $iTopB = 60, $iWidthB = 90, $iHeightB = 140, $iColorB = 0xFF0000, $GroupBCol = 0xFFFFE0 ; $GUI_BKCOLOR_TRANSPARENT ;
    GUICtrlCreateGroup("Group B", $iLeftB, $iTopB, $iWidthB, $iHeightB)
    GUICtrlSetBkColor(-1, $GroupBCol)
    ;GUIStartGroup()
    Local $idRadio_3 = GUICtrlCreateRadio("Radio 3", 70, 90, 60, 20)
    GUICtrlSetBkColor(-1, $GroupBCol)
    Local $idRadio_4 = GUICtrlCreateRadio("Radio 4", 70, 110, 60, 50)
    GUICtrlSetBkColor(-1, $GroupBCol)

    _GuiCtrlGroupSetColor($iLeft, $iTop, $iWidth, $iHeight, $iColorA, $GroupACol) ; Group A - Colouring
    _GuiCtrlGroupSetColor($iLeftB, $iTopB, $iWidthB, $iHeightB, $iColorB, $GroupBCol) ; Group B - Colouring

    GUICtrlSetState($idRadio_1, $GUI_CHECKED)
    GUICtrlSetState($idRadio_4, $GUI_CHECKED)

    ; Init our vars that we will use to keep track of radio events
    Local $iRadioValA = 1 ; We will assume 0 = first radio button selected, 1 = last button
    Local $iRadioValB = 4
    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                MsgBox(0, "Radio Buttons", "Group A: Radio " & $iRadioValA & @CRLF & "Group B: Radio " & $iRadioValB, 10, $hGui)
                ExitLoop
            Case $idRadio_1, $idRadio_2
                $iRadioValA = $Msg - $idRadio_1 + 1 ; Plus 1 for the 1 in $idRadio_1
            Case $idRadio_3, $idRadio_4
                $iRadioValB = $Msg - $idRadio_3 + 3 ; Plus 3 for the 3 in $idRadio_3
        EndSwitch
    WEnd
EndFunc   ;==>Example


Func _GuiCtrlGroupSetColor($iLeft, $iTop, $iWidth, $iHeight, $iBorderColor = 0x000000, $iBkGndCol0r = $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateGraphic($iLeft, $iTop, $iWidth, $iHeight)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $iBorderColor, $iBkGndCol0r)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, -1, 7, $iWidth, $iHeight - 7)
EndFunc   ;==>_GuiCtrlGroupSetColor

 

Edited by Malkey
See post #4 and #5
Link to comment
Share on other sites

@jguinch

Thanks for the heads up concerning the bug.

The problem was fixed by changing the function:-

Func _GuiCtrlGroupSetColor($iLeft, $iTop, $iWidth, $iHeight, $iBorderColor = 0x000000, $iBkGndCol0r = $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateGraphic(-1, -1)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $iBorderColor, $iBkGndCol0r)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, $iLeft, $iTop + 8, $iWidth, $iHeight - 7)
EndFunc   ;==>_GuiCtrlGroupSetColor

to what it is now in the edited post #3.

 

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