Button-Rand-Farbe

  • Wenn ich die Farbe des Buttons und die Hintergrundfarbe der dazu gehörigen GUI ändere, bekomme ich immer einen hässlichen blauen Rand um den Button. Dieser lässt sich nicht mit WS_Border beeinflussen, dies fügt nur noch einen zusätzlichen Rand hinzu. Wie kann den blauen Rand einfärben?


    [Blockierte Grafik: http://img535.imageshack.us/img535/2420/testbutton.png]

    [autoit]


    #Region ### START Koda GUI section ###
    $Form1 = GUICreate("Test", 434, 144, 192, 124)
    GUISetBkColor(0xA0A0A4)
    $Button1 = GUICtrlCreateButton("TestButton1", 104, 16, 211, 41, $WS_GROUP)

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

    GUICtrlSetBkColor(-1, 0xB4B4B4)

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

    $Button2 = GUICtrlCreateButton("TestButton2", 104, 72, 209, 41, $WS_GROUP)
    GUICtrlSetBkColor(-1, 0x808080)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

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

    Einmal editiert, zuletzt von UltimateX (27. Mai 2010 um 15:38)

  • Schade, da SkinCrafter auf Grund der Demo-Beschränkungen nicht in Frage kommt und ich finde es lohnt sich nicht eine Lizenz zukaufen.
    Gibt es sonst noch irgendwelche Möglichkeiten stylisch anspruchsvolle Buttons zu erstellen?
    Wie siehts mit SkinCrafter light aus? Lässt sich das verwenden?

  • Das hatte ich mir auch schon überlegt, aber wäre es da nicht stressig ein Roll-Over Effekt und weiteres zu integrieren?

  • So schon fertig.
    Hoffe es gefällt dir, vielleicht brauchen es ja noch mehr Leute.
    Beispiel ist drin, es wird nur gestartet wenn $testmode=true ist

    EDIT:
    War ein Fehler mit dem Rect drinnen, berichtigt:

    Spoiler anzeigen
    [autoit]


    #include-once
    #include <GDIPlus.au3>
    #include <Misc.au3>

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

    Local $buttons[1][6];image,posx,posy,$width,$height,state
    Local $othimg[1][2];imagefocus,imagebuttondown
    Local $firstused=0
    Local $hwnd=0
    Local $gra,$buffer,$backgra,$winx,$winy
    Local $lastclickedbutton=-1

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

    Local $testmode=True
    If $testmode=True Then
    $gui=GUICreate("")
    GUISetState()
    _ButtonStartup($gui)
    $p1="";Pfad 1 - Normalbild
    $p2="";Pfad 2 - Bild wenn Button Focus hat
    $p3="";Pfad 3 - Bild wenn Button geklickt wurde
    $button=_ButtonCreate($p1,$p2,$p3,100,100,100,100,0)
    _ButtonSetState($button,1)
    while GUIGetMsg()<>-3
    Sleep(10)
    If _GetLastButton()=$button Then
    MsgBox(0,"","")
    EndIf
    WEnd
    _ButtonShutdown()
    EndIf

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

    Func _ButtonStartup($gui)
    _GDIPlus_Startup()
    $hwnd=$gui
    $gra=_GDIPlus_GraphicsCreateFromHWND($hwnd)
    Local $w,$h
    $winx=_WinAPI_GetClientWidth($hwnd)
    $winy=_WinAPI_GetClientHeight($hwnd)
    $buffer=_GDIPlus_BitmapCreateFromGraphics($winx,$winy,$gra)
    $backgra=_GDIPlus_ImageGetGraphicsContext($buffer)
    AdlibRegister("__ButtonsRedraw",10)
    EndFunc

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

    Func _ButtonCreate($bild,$bildfocus,$bildbd,$px,$py,$width=100,$height=20,$state=1) ;1=show,0=hide
    If $state=1 Then
    $state="show"
    Else
    $state="hide"
    EndIf
    If $firstused=0 Then
    $firstused=1
    Local $bound=0
    Else
    Local $bound=UBound($buttons,1)
    ReDim $buttons[$bound+1][6]
    ReDim $othimg[$bound+1][2]
    EndIf
    $buttons[$bound][0]=_GDIPlus_ImageLoadFromFile($bild)
    $othimg[$bound][0]=_GDIPlus_ImageLoadFromFile($bildfocus)
    $othimg[$bound][1]=_GDIPlus_ImageLoadFromFile($bildbd)
    $buttons[$bound][1]=$px
    $buttons[$bound][2]=$py
    $buttons[$bound][3]=$width
    $buttons[$bound][4]=$height
    $buttons[$bound][5]=$state
    Return $bound ;Button-ID für _ButtonSetState, kleinstes: 0
    EndFunc

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

    Func _GetLastButton()
    Local $tmp=$lastclickedbutton
    $lastclickedbutton=-1
    Return $tmp
    EndFunc

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

    Func _ButtonSetState($buttonid,$state=1)
    If $state=1 Then
    $state="show"
    Else
    $state="hide"
    EndIf
    $buttons[$buttonid][5]=$state
    EndFunc

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

    Func _ButtonShutdown()
    AdlibUnRegister("__ButtonsRedraw")
    For $x=0 To UBound($buttons,1)-1
    _GDIPlus_ImageDispose($buttons[$x][0])
    _GDIPlus_ImageDispose($othimg[$x][0])
    _GDIPlus_ImageDispose($othimg[$x][1])
    Next
    _GDIPlus_GraphicsDispose($backgra)
    _GDIPlus_BitmapDispose($buffer)
    _GDIPlus_GraphicsDispose($gra)
    _GDIPlus_Shutdown()
    EndFunc

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

    Func __ButtonsRedraw()
    Local $nowimage
    Local $pos=_WinAPI_GetMousePos(True,$hwnd)
    Local $erg
    For $x=0 To UBound($buttons,1)-1
    If $buttons[$x][5]="show" Then
    $rect=__NewRect($buttons[$x][1],$buttons[$x][2],$buttons[$x][3],$buttons[$x][4])
    If _WinAPI_PtInRect($rect,$pos) Then
    $nowimage=$othimg[$x][0]
    If _IsPressed("1") Then
    $nowimage=$othimg[$x][1]
    $lastclickedbutton=$x
    EndIf
    Else
    $nowimage=$buttons[$x][0]
    EndIf
    _GDIPlus_GraphicsDrawImageRect($backgra,$nowimage,$buttons[$x][1],$buttons[$x][2],$buttons[$x][3],$buttons[$x][4])
    EndIf
    Next
    _GDIPlus_GraphicsDrawImageRect($gra,$Buffer,0,0,$winx,$winy)
    EndFunc

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

    Func __NewRect($x=0,$y=0,$w=0,$h=0)
    Local $struct=DllStructCreate("uint Left;uint Top;uint Right;uint Bottom");$tagRECT
    DllStructSetData($struct,"Left",$x)
    DllStructSetData($struct,"Top",$y)
    DllStructSetData($struct,"Right",$x+$w)
    DllStructSetData($struct,"Bottom",$y+$h)
    Return $struct
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von TheShadowAE (27. Mai 2010 um 15:40)

  • Echt super, ich denke das können auch noch mehr Leute brauchen, auch wenn man nebenbei wahrscheinlich noch Erfahrung in Gimp oder Photoshop braucht wenn man was Schönes gestalten will. MfG uX