Group Umrandung Farbe ändern?

  • Abend,

    kann mir mal jemand sagen, wie ich die Farbe der Umrandung der Group ändern kann? Mit GUICtrlSetBkColor kommt ein Hintergrund oben beim Text, aber ich möchte nur die Farbe der Umrandung ändern.

    Gruß, Julien

  • moin moin,

    dazu gibt's ne UDF:

    Spoiler anzeigen
    [autoit]


    Func _GUICtrlCreateGroup($sText, $iLeft, $iTop, $iWidth, $iHeight, $bColor = 0xC0C0C0, $OutlineColor = 0xFFFFFF)
    Local $aLabel[6] = [5], $aLabelInner[6] = [5]
    Local $aStringSize = _StringSize($sText)
    GUISwitch($gui2)
    $aLabel[1] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, 1, $iHeight) ; Left Line.
    $aLabelInner[1] = GUICtrlCreateLabel("", $iLeft + 2, $iTop + 1, 1, $iHeight) ; Inner/Outer Left Line.
    $aLabel[2] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, 10, 1) ; Top Left Line.
    $aLabelInner[2] = GUICtrlCreateLabel("", $iLeft + 2, $iTop + 2, 10 - 1, 1) ; Top Inner/Outer Left Line.
    GUICtrlCreateLabel(" " & $sText, $iLeft + 7, $iTop - 4, $aStringSize[2] - 3, 15)
    GUICtrlSetColor(-1, 0xc00000); optional text color
    ;GUICtrlSetbkColor(-1, 0xc00000); optional text bg color
    $aLabel[3] = GUICtrlCreateLabel("", $iLeft + $aStringSize[2] + 4, $iTop + 1, $iWidth - $aStringSize[2] - 3, 1) ; Top Right Line.
    $aLabelInner[3] = GUICtrlCreateLabel("", $iLeft + $aStringSize[2] + 4, $iTop + 2, $iWidth - $aStringSize[2] - 3, 1) ; Top Inner/Outer Right Line.
    $aLabel[4] = GUICtrlCreateLabel("", $iLeft + $iWidth + 1, $iTop + 1, 1, $iHeight) ; Right Line.
    $aLabelInner[4] = GUICtrlCreateLabel("", $iLeft + $iWidth + 2, $iTop + 1, 1, $iHeight + 1) ; Right Inner/Outer Line.
    $aLabel[5] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + $iHeight + 1, $iWidth + 1, 1) ; Bottom Line.
    $aLabelInner[5] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + $iHeight + 2, $iWidth + 2, 1) ; Bottom Inner/Outer Line.
    For $i = 1 To $aLabel[0]
    GUICtrlSetBkColor($aLabel[$i], $bColor)
    GUICtrlSetBkColor($aLabelInner[$i], $OutlineColor)
    Next
    EndFunc

    [/autoit]

    anwendungsbeispiel:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt("GUIOnEventMode", 0)
    Break(0)
    Opt("TrayAutoPause",0)
    $gui2 = GUICreate("test", 300, 100)
    _GUICtrlCreateGroup("farbengroup", 3, 15, 274, 77, 0x019c00, 0x74ff73)
    GUISetState()
    while 1
    sleep(50)
    $mMsg = GUIGetMsg(1)
    Switch $mMsg[0]
    case $GUI_EVENT_CLOSE
    exitloop
    EndSwitch
    wend
    Func _GUICtrlCreateGroup($sText, $iLeft, $iTop, $iWidth, $iHeight, $bColor = 0x00ff00, $OutlineColor = 0xFFFFFF)
    Local $aLabel[6] = [5], $aLabelInner[6] = [5]
    Local $aStringSize = _StringSize($sText)
    GUISwitch($gui2)
    $aLabel[1] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, 1, $iHeight) ; Left Line.
    $aLabelInner[1] = GUICtrlCreateLabel("", $iLeft + 2, $iTop + 1, 1, $iHeight) ; Inner/Outer Left Line.
    $aLabel[2] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, 10, 1) ; Top Left Line.
    $aLabelInner[2] = GUICtrlCreateLabel("", $iLeft + 2, $iTop + 2, 10 - 1, 1) ; Top Inner/Outer Left Line.
    GUICtrlCreateLabel(" " & $sText, $iLeft + 7, $iTop - 4, $aStringSize[2] - 3, 15)
    GUICtrlSetColor(-1, 0x285af2); optional text color
    GUICtrlSetbkColor(-1, 0xf2eb28); optional text bg color
    $aLabel[3] = GUICtrlCreateLabel("", $iLeft + $aStringSize[2] + 4, $iTop + 1, $iWidth - $aStringSize[2] - 3, 1) ; Top Right Line.
    $aLabelInner[3] = GUICtrlCreateLabel("", $iLeft + $aStringSize[2] + 4, $iTop + 2, $iWidth - $aStringSize[2] - 3, 1) ; Top Inner/Outer Right Line.
    $aLabel[4] = GUICtrlCreateLabel("", $iLeft + $iWidth + 1, $iTop + 1, 1, $iHeight) ; Right Line.
    $aLabelInner[4] = GUICtrlCreateLabel("", $iLeft + $iWidth + 2, $iTop + 1, 1, $iHeight + 1) ; Right Inner/Outer Line.
    $aLabel[5] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + $iHeight + 1, $iWidth + 1, 1) ; Bottom Line.
    $aLabelInner[5] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + $iHeight + 2, $iWidth + 2, 1) ; Bottom Inner/Outer Line.
    For $i = 1 To $aLabel[0]
    GUICtrlSetBkColor($aLabel[$i], $bColor)
    GUICtrlSetBkColor($aLabelInner[$i], $OutlineColor)
    Next
    EndFunc
    Func _StringSize($sText, $iSize = Default, $iWeight = Default, $iAttrib = Default, $sName = "", $iWidth = 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $avSize_Info[4], $aRet, $iLine_Width = 0, $iLast_Word, $iWrap_Count
    Local $hLabel_Handle, $hFont, $hDC, $oFont, $tSize = DllStructCreate("int X;int Y")

    [/autoit] [autoit][/autoit] [autoit]

    ; Check parameters are correct type
    If Not IsString($sText) Then Return SetError(1, 1, 0)
    If Not IsNumber($iSize) And $iSize <> Default Then Return SetError(1, 2, 0)
    If Not IsInt($iWeight) And $iWeight <> Default Then Return SetError(1, 3, 0)
    If Not IsInt($iAttrib) And $iAttrib <> Default Then Return SetError(1, 4, 0)
    If Not IsString($sName) Then Return SetError(1, 5, 0)
    If Not IsNumber($iWidth) Then Return SetError(1, 6, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Create GUI to contain test labels, set to required font parameters
    Local $hGUI = GUICreate("", 1200, 500, 10, 10)
    If $hGUI = 0 Then Return SetError(2, 0, 0)
    GUISetFont($iSize, $iWeight, $iAttrib, $sName)

    [/autoit] [autoit][/autoit] [autoit]

    ; Store unwrapped text
    $avSize_Info[0] = $sText

    [/autoit] [autoit][/autoit] [autoit]

    ; Ensure EoL is @CRLF and break text into lines
    If StringInStr($sText, @CRLF) = 0 Then $sText = StringRegExpReplace($sText, "[\x0a|\x0d]", @CRLF)
    Local $asLines = StringSplit($sText, @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    ; Draw label with unwrapped lines to check on max width
    Local $hText_Label = GUICtrlCreateLabel($sText, 10, 10)
    Local $aiPos = ControlGetPos($hGUI, "", $hText_Label)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_HIDE)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlDelete($hText_Label)

    [/autoit] [autoit][/autoit] [autoit]

    ; Store line height for this font size after removing label padding (always 8)
    $avSize_Info[1] = ($aiPos[3] - 8)/ $asLines[0]
    ; Store width and height of this label
    $avSize_Info[2] = $aiPos[2]
    $avSize_Info[3] = $aiPos[3] - 4 ; Reduce margin

    [/autoit] [autoit][/autoit] [autoit]

    ; Check if wrapping is required
    If $aiPos[2] > $iWidth And $iWidth > 0 Then

    [/autoit] [autoit][/autoit] [autoit]

    ; Set returned text element to null
    $avSize_Info[0] = ""

    [/autoit] [autoit][/autoit] [autoit]

    ; Set width element to max allowed
    $avSize_Info[2] = $iWidth

    [/autoit] [autoit][/autoit] [autoit]

    ; Set line count to zero
    Local $iLine_Count = 0

    [/autoit] [autoit][/autoit] [autoit]

    ; Take each line in turn
    For $j = 1 To $asLines[0]

    [/autoit] [autoit][/autoit] [autoit]

    ; Size this line unwrapped
    $hText_Label = GUICtrlCreateLabel($asLines[$j], 10, 10)
    $aiPos = ControlGetPos($hGUI, "", $hText_Label)
    GUICtrlDelete($hText_Label)

    [/autoit] [autoit][/autoit] [autoit]

    ; Check wrap status
    If $aiPos[2] < $iWidth Then
    ; No wrap needed so count line and store
    $iLine_Count += 1
    $avSize_Info[0] &= $asLines[$j] & @CRLF
    Else
    ; Wrap needed so need to count wrapped lines

    [/autoit] [autoit][/autoit] [autoit]

    ; Create label to hold line as it grows
    $hText_Label = GUICtrlCreateLabel("", 0, 0)
    ; Initialise Point32 method
    $hLabel_Handle = ControlGetHandle($hGui, "", $hText_Label)
    ; Get DC with selected font
    $aRet = DllCall("User32.dll", "hwnd", "GetDC", "hwnd", $hLabel_Handle)
    If @error Or $aRet[0] = 0 Then Return SetError(3, 1, 0)
    $hDC = $aRet[0]
    $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont
    If @error Or $aRet[0] = 0 Then Return SetError(3, _StringSize_Error(2, $hLabel_Handle, $hDC, $hGUI), 0)
    $hFont = $aRet[0]
    $aRet = DllCall("GDI32.dll", "hwnd", "SelectObject", "hwnd", $hDC, "hwnd", $hFont)
    If @error Or $aRet[0] = 0 Then Return SetError(3, _StringSize_Error(3, $hLabel_Handle, $hDC, $hGUI), 0)
    $oFont = $aRet[0]

    [/autoit] [autoit][/autoit] [autoit]

    ; Zero counter
    $iWrap_Count = 0

    [/autoit] [autoit][/autoit] [autoit]

    While 1

    [/autoit] [autoit][/autoit] [autoit]

    ; Set line width to 0
    $iLine_Width = 0
    ; Initialise pointer for end of word
    $iLast_Word = 0

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To StringLen($asLines[$j])

    [/autoit] [autoit][/autoit] [autoit]

    ; Is this just past a word ending?
    If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1
    ; Increase line by one character
    Local $sTest_Line = StringMid($asLines[$j], 1, $i)
    ; Place line in label
    GUICtrlSetData($hText_Label, $sTest_Line)

    [/autoit] [autoit][/autoit] [autoit]

    ; Get line length into size structure
    $iSize = StringLen($sTest_Line)
    DllCall("GDI32.dll", "int", "GetTextExtentPoint32", "hwnd", $hDC, "str", $sTest_Line, "int", $iSize, "ptr", DllStructGetPtr($tSize))
    If @error Then Return SetError(3, _StringSize_Error(4, $hLabel_Handle, $hDC, $hGUI), 0)
    $iLine_Width = DllStructGetData($tSize, "X")

    [/autoit] [autoit][/autoit] [autoit]

    ; If too long exit the loop
    If $iLine_Width >= $iWidth - Int($iSize / 2) Then ExitLoop
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ; End of the line of text?
    If $i > StringLen($asLines[$j]) Then
    ; Yes, so add final line to count
    $iWrap_Count += 1
    ; Store line
    $avSize_Info[0] &= $sTest_Line & @CRLF
    ExitLoop
    Else
    ; No, but add line just completed to count
    $iWrap_Count += 1
    ; Check at least 1 word completed or return error
    If $iLast_Word = 0 Then Return SetError(4, _StringSize_Error(0, $hLabel_Handle, $hDC, $hGUI), 0)
    ; Store line up to end of last word
    $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF
    ; Strip string to point reached
    $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word)
    ; Trim leading whitespace
    $asLines[$j] = StringStripWS($asLines[$j], 1)
    ; Repeat with remaining characters in line
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; Add the number of wrapped lines to the count
    $iLine_Count += $iWrap_Count

    [/autoit] [autoit][/autoit] [autoit]

    ; Clean up
    DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hLabel_Handle, "hwnd", $hDC)
    If @error Then Return SetError(3, _StringSize_Error(5, $hLabel_Handle, $hDC, $hGUI), 0)
    GUICtrlDelete($hText_Label)

    [/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit] [autoit][/autoit] [autoit]

    ; Convert lines to pixels and add reduced margin
    $avSize_Info[3] = ($iLine_Count * $avSize_Info[1]) + 4

    [/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; Clean up
    GUIDelete($hGUI)

    [/autoit] [autoit][/autoit] [autoit]

    ; Return array
    Return $avSize_Info

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ; => _StringSize
    Func _StringSize_Error($iExtended, $hLabel_Handle, $hDC, $hGUI)

    [/autoit] [autoit][/autoit] [autoit]

    ; Release DC if created
    DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hLabel_Handle, "hwnd", $hDC)
    ; Delete GUI
    GUIDelete($hGUI)
    ; Return with extended set
    Return $iExtended

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ; => _StringSize_Error

    [/autoit]


    [Blockierte Grafik: http://h4w.de/1201/F1G.jpg]