Probleme beim Abändern von Buttons

  • Hey,

    ich versuche derzeit mir einen Programm/Script - Starter zu erstellen.

    Klappt soweit auch ganz gut, allerdings bereitet mir die GUI bzw. die Buttons Probleme.

    Der Standardbutton gefällt mir nicht so gut und ich wollte den etwas ändern.

    Aus der Hilfe habe ich folgenden Befehl entnommen:

    [autoit]


    $TVbutton = GUICtrlCreateButton ("TV", 150 , 10, 150, 50)
    GUICtrlSetFont (3,15, 600, "", "")

    [/autoit]


    Somit kann ich die Schriftgröße, Schriftart usw. verändern. Nur wie ändere ich die Hintergrundfarbe der Buttons? Oder die Schriftfarbe?

    Ein weiteres Problem von GUICtrlSetFont ist, dass ich die Zeile für jeden Buttons einfügen muss. Die sollen eigentlich alle gleich aussehen und ich frage mich ob das nicht auch eleganter geht?

    Vielen dank schonmal für die Antworten.

    Gruß Nuts

    Einmal editiert, zuletzt von nuts (4. Oktober 2008 um 19:08)

  • einfach GUISetFont verwenden. Wenn du Farben verwendest, wird der Button jedoch hässlich ( nur ein rechteck in gewählter Frabe. Kein 3D ...)

  • Ah hehe danke.
    Wenn man den richtigen Befehl nimmt ist ja ganz leicht.

    Ok farbig müssten die Buttons nicht umbedingt sein! Nur ist die Schriftfarbe irgendwie änderbar?

    Was mir gerade noch einfällt:
    Der angewählte Button ist ganz leicht blau umrandet. Ist es möglich den angewählten Buttons ganz zu färben oder zumindest den Rahmen stärker zu betonen?

  • Geht alles nur mit ownerdrawn -> Bsp in der Hilfe unter GuiregisterMsg
    //edit: Bsp angepasst, um den Einbau zu vereinfachen:

    Spoiler anzeigen
    [autoit]

    ; *******************************************************
    ; Example - Create an ownerdrawn/colored button
    ; *******************************************************

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

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

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

    Example()

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

    Func Example()
    Local Const $BS_OWNERDRAW = 0x0000000B
    Local $hGUI, $nButton, $nButton2, $GUIMsg

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

    $hGUI = GUICreate("My Ownerdrawn Created Button", 300, 200)

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

    $nButton0 = GUICtrlCreateButton("My Ownerdrawn", 90, 50, 120, 30)
    GUICtrlSetStyle($nButton, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW)) ; Set the ownerdrawn flag
    $nButton = GUICtrlCreateButton("My Ownerdrawn No 2", 90, 10, 120, 30)
    GUICtrlSetStyle($nButton, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW)) ; Set the ownerdrawn flag

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

    $nButton2 = GUICtrlCreateButton("Normal Button", 90, 110, 120, 30)

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

    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
    ; WM_DRAWITEM has to registered before showing GUI otherwise the initial drawing isn't done
    GUIRegisterMsg($WM_DRAWITEM, "MY_WM_DRAWITEM")

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

    GUISetState()

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

    While 1
    $GUIMsg = GUIGetMsg()

    Switch $GUIMsg
    Case $GUI_EVENT_CLOSE
    ExitLoop

    Case $nButton0
    MsgBox(0, "Info", "Button pressed ownerd")

    Case $nButton
    MsgBox(0, "Info", "Button pressed ownerd")

    Case $nButton2
    MsgBox(0, "Info", "Button2 pressed")
    EndSwitch
    WEnd
    EndFunc ;==>Example

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

    ; React on a button click
    Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam

    If $nID <> 2 And $nNotifyCode = 0 Then ; Check for IDCANCEL - 2
    ; Ownerdrawn buttons don't send something by pressing ENTER
    ; So IDOK - 1 comes up, now check for the control that has the current focus
    If $nID = 1 Then
    $hFocus = DllCall("user32.dll", "hwnd", "GetFocus")
    $nCtrlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hFocus[0])
    PostButtonClick($hWnd, $nCtrlID[0])
    Else
    EndIf
    EndIf
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_WM_COMMAND

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

    ; RePost a WM_COMMAND message to a ctrl in a gui window
    Func PostButtonClick($hWnd, $nCtrlID)
    DllCall("user32.dll", "int", "PostMessage", _
    "hwnd", $hWnd, _
    "int", $WM_COMMAND, _
    "int", BitAND($nCtrlID, 0x0000FFFF), _
    "hwnd", GUICtrlGetHandle($nCtrlID))
    EndFunc ;==>PostButtonClick

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

    ; Draw the button
    Func MY_WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    Local $stDrawItem = DllStructCreate("uint;uint;uint;uint;uint;uint;uint;int[4];dword", $lParam)
    Local Const $ODT_BUTTON = 4

    $nCtlType = DllStructGetData($stDrawItem, 1)
    If $nCtlType = $ODT_BUTTON Then
    $nCtrlID = DllStructGetData($stDrawItem, 2)
    $nItemState = DllStructGetData($stDrawItem, 5)
    $hCtrl = DllStructGetData($stDrawItem, 6)
    $hDC = DllStructGetData($stDrawItem, 7)
    $nLeft = DllStructGetData($stDrawItem, 8, 1)
    $nTop = DllStructGetData($stDrawItem, 8, 2)
    $nRight = DllStructGetData($stDrawItem, 8, 3)
    $nBottom = DllStructGetData($stDrawItem, 8, 4)
    ConsoleWrite($hCtrl & @CRLF)
    $sText =_WinAPI_GetWindowText($hCtrl)
    ;~ $sText = WinGetText($hCtrl);"Ownerdrawn Button"
    $nTextColor = 0x5555DD
    $nBackColor = 0xFFEEDD
    DrawButton($hWnd, $hCtrl, $hDC, $nLeft, $nTop, $nRight, $nBottom, $nItemState, $sText, $nTextColor, $nBackColor)
    $stDrawItem = 0
    Return 1
    EndIf

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

    $stDrawItem = 0
    Return $GUI_RUNDEFMSG ; Proceed the default Autoit3 internal message commands
    EndFunc ;==>MY_WM_DRAWITEM

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

    ; The main drawing procedure
    Func DrawButton($hWnd, $hCtrl, $hDC, $nLeft, $nTop, $nRight, $nBottom, $nItemState, $sText, $nTextColor, $nBackColor)
    ;Local $bDefault = FALSE
    Local Const $GWL_STYLE = -16
    Local Const $ODS_SELECTED = 0x0001
    Local Const $ODS_GRAYED = 0x0002
    Local Const $ODS_DISABLED = 0x0004
    Local Const $ODS_CHECKED = 0x0008
    Local Const $ODS_FOCUS = 0x0010
    Local Const $ODS_HOTLIGHT = 0x0040
    Local Const $ODS_INACTIVE = 0x0080
    Local Const $ODS_NOACCEL = 0x0100
    Local Const $ODS_NOFOCUSRECT = 0x0200
    Local Const $DFC_BUTTON = 4
    Local Const $DFCS_BUTTONPUSH = 0x0010
    Local $bChecked = BitAND($nItemState, $ODS_CHECKED)
    Local $bFocused = BitAND($nItemState, $ODS_FOCUS)
    Local $bGrayed = BitAND($nItemState, BitOR($ODS_GRAYED, $ODS_DISABLED))
    Local $bSelected = BitAND($nItemState, $ODS_SELECTED)

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

    $stRect = DllStructCreate("int;int;int;int")
    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)

    If $bGrayed Then
    $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_HIGHLIGHTTEXT))
    ElseIf $nTextColor = -1 Then
    $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_BTNTEXT))
    Else
    $nClrTxt = SetTextColor($hDC, $nTextColor)
    EndIf

    If $nBackColor = -1 Then
    $hBrush = GetSysColorBrush($COLOR_BTNFACE)
    $nClrSel = GetSysColor($COLOR_BTNFACE)
    Else
    $hBrush = CreateSolidBrush($nBackColor)
    $nClrSel = $nBackColor;
    EndIf

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

    $nClrBk = SetBkColor($hDC, $nClrSel)
    $hOldBrush = SelectObject($hDC, $hBrush)

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

    $nTmpLeft = $nLeft
    $nTmpTop = $nTop
    $nTmpRight = $nRight
    $nTmpBottom = $nBottom

    If $bSelected Then
    InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -1, -1)
    $hBrushSel = CreateSolidBrush(GetSysColor($COLOR_BTNSHADOW))
    FrameRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrushSel)
    DeleteObject($hBrushSel)
    Else
    If $bFocused And Not $bSelected Then InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -1, -1)
    DrawFrameControl($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $DFC_BUTTON, $DFCS_BUTTONPUSH)
    EndIf

    $nTmpLeft = $nLeft
    $nTmpTop = $nTop
    $nTmpRight = $nRight
    $nTmpBottom = $nBottom

    If $bSelected Then
    InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -2, -2)
    Else
    If $bFocused And Not $bSelected Then
    InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -3, -3)
    $nTmpLeft -= 1
    $nTmpTop -= 1
    Else
    InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -2, -2)
    $nTmpLeft -= 1
    $nTmpTop -= 1
    EndIf
    EndIf

    FillRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrush)

    If $bSelected Or $bGrayed Then
    $nTmpLeft = $nTmpLeft + 2
    $nTmpTop = $nTmpTop + 2
    EndIf

    $uFlags = BitOR($DT_NOCLIP, $DT_CENTER, $DT_VCENTER)

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

    If Not BitAND(GetWindowLong($hCtrl, $GWL_STYLE), $BS_MULTILINE) Then $uFlags = BitOR($uFlags, $DT_SINGLELINE)

    DrawText($hDC, $sText, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $uFlags)

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

    If $bGrayed Then
    $nTmpLeft = $nLeft
    $nTmpTop = $nTop
    $nTmpRight = $nRight
    $nTmpBottom = $nBottom

    $nTmpLeft -= 1

    $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_GRAYTEXT))
    DrawText($hDC, $sText, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, BitOR($DT_NOCLIP, $DT_CENTER, $DT_VCENTER, $DT_SINGLELINE))
    EndIf

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

    $nTmpLeft = $nLeft
    $nTmpTop = $nTop
    $nTmpRight = $nRight
    $nTmpBottom = $nBottom

    If $bFocused Then
    $hBrush = CreateSolidBrush(0)
    FrameRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrush)

    $nTmpLeft = $nLeft
    $nTmpTop = $nTop
    $nTmpRight = $nRight
    $nTmpBottom = $nBottom

    InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -4, -4)
    DrawFocusRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom)
    EndIf

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

    SelectObject($hDC, $hOldBrush)
    DeleteObject($hBrush)
    SetTextColor($hDC, $nClrTxt)
    SetBkColor($hDC, $nClrBk)

    Return 1
    EndFunc ;==>DrawButton

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

    ; Some graphic / windows functions
    Func CreateSolidBrush($nColor)
    Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)
    Return $hBrush[0]
    EndFunc ;==>CreateSolidBrush

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

    Func GetSysColor($nIndex)
    Local $nColor = DllCall("user32.dll", "int", "GetSysColor", "int", $nIndex)
    Return $nColor[0]
    EndFunc ;==>GetSysColor

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

    Func GetSysColorBrush($nIndex)
    Local $hBrush = DllCall("user32.dll", "hwnd", "GetSysColorBrush", "int", $nIndex)
    Return $hBrush[0]
    EndFunc ;==>GetSysColorBrush

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

    Func DrawFrameControl($hDC, $nLeft, $nTop, $nRight, $nBottom, $nType, $nState)
    Local $stRect = DllStructCreate("int;int;int;int")

    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)

    DllCall("user32.dll", "int", "DrawFrameControl", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "int", $nType, "int", $nState)

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

    $stRect = 0
    EndFunc ;==>DrawFrameControl

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

    Func DrawFocusRect($hDC, $nLeft, $nTop, $nRight, $nBottom)
    Local $stRect = DllStructCreate("int;int;int;int")

    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)

    DllCall("user32.dll", "int", "DrawFocusRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect))

    $stRect = 0
    EndFunc ;==>DrawFocusRect

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

    Func DrawText($hDC, $sText, $nLeft, $nTop, $nRight, $nBottom, $nFormat)
    Local $nLen = StringLen($sText)

    Local $stRect = DllStructCreate("int;int;int;int")
    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)

    Local $stText = DllStructCreate("char[260]")
    DllStructSetData($stText, 1, $sText)

    DllCall("user32.dll", "int", "DrawText", "hwnd", $hDC, "ptr", DllStructGetPtr($stText), "int", $nLen, "ptr", DllStructGetPtr($stRect), "int", $nFormat)

    $stRect = 0
    $stText = 0
    EndFunc ;==>DrawText

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

    Func FillRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush)
    Local $stRect = DllStructCreate("int;int;int;int")

    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)

    DllCall("user32.dll", "int", "FillRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush)

    $stRect = 0
    EndFunc ;==>FillRect

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

    Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush)
    Local $stRect = DllStructCreate("int;int;int;int")

    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)

    DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush)

    $stRect = 0
    EndFunc ;==>FrameRect

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

    Func InflateRect(ByRef $nLeft, ByRef $nTop, ByRef $nRight, ByRef $nBottom, $nX, $nY)
    Local $stRect = DllStructCreate("int;int;int;int")

    DllStructSetData($stRect, 1, $nLeft)
    DllStructSetData($stRect, 2, $nTop)
    DllStructSetData($stRect, 3, $nRight)
    DllStructSetData($stRect, 4, $nBottom)

    DllCall("user32.dll", "int", "InflateRect", "ptr", DllStructGetPtr($stRect), "int", $nX, "int", $nY)

    $nLeft = DllStructGetData($stRect, 1)
    $nTop = DllStructGetData($stRect, 2)
    $nRight = DllStructGetData($stRect, 3)
    $nBottom = DllStructGetData($stRect, 4)

    $stRect = 0
    EndFunc ;==>InflateRect

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

    Func SetBkColor($hDC, $nColor)
    Local $nOldColor = DllCall("gdi32.dll", "int", "SetBkColor", "hwnd", $hDC, "int", $nColor)
    Return $nOldColor[0]
    EndFunc ;==>SetBkColor

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

    Func SetTextColor($hDC, $nColor)
    Local $nOldColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)
    Return $nOldColor[0]
    EndFunc ;==>SetTextColor

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

    Func SelectObject($hDC, $hObj)
    Local $hOldObj = DllCall("gdi32.dll", "hwnd", "SelectObject", "hwnd", $hDC, "hwnd", $hObj)
    Return $hOldObj[0]
    EndFunc ;==>SelectObject

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

    Func DeleteObject($hObj)
    Local $nResult = DllCall("gdi32.dll", "hwnd", "DeleteObject", "hwnd", $hObj)
    EndFunc ;==>DeleteObject

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

    Func GetWindowLong($hWnd, $nIndex)
    Local $nVal = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", $nIndex)
    Return $nVal[0]
    EndFunc ;==>GetWindowLong

    [/autoit]

    Einmal editiert, zuletzt von progandy (4. Oktober 2008 um 19:34)

  • Ah ja. Nur wie kommt die Farbe in den Button? und wieso im Beispiel nur in den Ersten?
    Ziemlich schwierig, da kommt man sich ja richtig blöd vor ;(

    Danke aber schonmal für die Hilfestellung.

    Edit \
    Aha ich komme der Sache näher. Ist ja ganz einfach :thumbup:

    [autoit]


    $Button1 = GUICtrlCreateButton("TV", 100, 8, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFF00)
    GUICtrlSetBkColor(-1, 0x004E98)

    [/autoit]

    Das Beispielscript (das ich im moment gar nicht kapiere) bezieht sich jetzt aus den von mir erwähnten "blauen Rahmen" des angewählten Button richtig?

    3 Mal editiert, zuletzt von nuts (4. Oktober 2008 um 21:05)

  • leider stecke ich schon wieder fest.

    Um die angewählten Buttons hervorzuheben hab ich hier im forum ein Beispiel gefunden.

    Spoiler anzeigen


    $GUI = GuiCreate("Test", 480, 220)
    Opt("GUICoordMode",0)
    $Button = GuiCtrlCreateButton("Button1", 30, 60, 100, 30)
    $Button2 = GuiCtrlCreateButton("Button2", 1, 60, 100, 30)

    GuiSetState()

    ; Hover Functions
    Func Hover($ID)
    Switch $ID
    Case $Button
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button2
    GUICtrlSetBkColor($ID, 0xFFFF00)

    EndSwitch
    EndFunc

    Func Normal($ID)
    Switch $ID
    Case $Button
    GUICtrlSetBkColor($ID, -1)
    Case $Button2
    GUICtrlSetBkColor($ID, -1)
    EndSwitch
    EndFunc

    ; Main While
    $Hover_Old = ""

    While 1

    If GUIGetMsg() = -3 Then Exit

    $Cursor = GUIGetCursorInfo($GUI) ; it's important that the gui variable is setted in this function!
    If $Cursor[4] <> $Hover_Old Then
    Normal($Hover_Old) ; reset the previous control
    Hover($Cursor[4]) ; set the new control hovered
    $Hover_Old = $Cursor[4]
    EndIf

    WEnd

    Damit färbt sich jeder Button über dem sich der Mauszeiger befindet in meinem Beispiel "gelb".
    Ich wollte aber den Programmstarter mit den Hoch/Runter Tasten bedienen. Dabei ändert sich die Farbe leider nicht (GUIGetCursorInfo ist da wohl ungeeignet)
    Was wäre der passende Befehl? Der "blaue" Rahmen wandert ja sauber mit - irgendwie muss ich doch abfragen können wo sich dieser gerade befindet?!?

  • Gibt wohl keine Möglichkeit das so umzusetzen wie ich will oder?
    Auch die echte Hover Funktion aus dem englischen autoit Forum färbt die Buttons bei meinen versuchen nur wenn der Mauszeiger darüber ist.

  • hm klingt trickreich und macht mir mut.

    mit der grafischen oberfläche hab ich ganz schön zu kämpfen. hab auch schon versucht eine mit turbodelphi zu erstellen und dort die autoit skripte einzubinden.
    allerdings ist das dort mit dem button design genauso eigenartig (bzw. noch schlimmer).
    ich verstehe auch ehrlich gesagt die problematik nicht. wird beim standardbutton auf ein windows standarddesign zurückgegriffen?

    auf jeden fall vielen dank für die antwort - ich werd mich morgen mal dran versuchen!

  • Hehe hab noch eine ganz "billige" Lösung gefunden.
    Man muss einfach den Windows Standard Style ändern.
    Ist natürlich keine schöne Lösung ..

    am Vorschlag von peethebee "arbeite" ich noch.

    edit \ muss eigentlich zwingend auf das eingestellte Design zurückgegriffen werden?
    könnte man das Andern ergebe das einen riesen Vorteil beim "stylen" von autoit gui's.
    Weil Windows Themes gibts ja massig zum downloaden. Dann könnte man sich für sein Programm was nettes aussuchen und für den normalen Desktopbetrieb die vertraute Oberfläche behalten.

    edit2 \ naja kommando zurück. das nützt nichts :(
    sobald ich dann wieder was am button ändere (Schriftfarbe, Hintergrund) wird der button wieder "hässlich"

    irgendwie verstehe ich die Zusammenhänge leider nicht.

    edit3 \
    @ peethebee hast du mal ein kurzes Beispiel deines Vorschlags?
    Bekomme das alleine nicht zuende gedacht. Wie schaffe ich es den Button durch erneutes drücken wieder zu "entfärben"?

    4 Mal editiert, zuletzt von nuts (6. Oktober 2008 um 19:21)

  • Meine ziemlich komische Lösung:

    Spoiler anzeigen


    #include <GUIConstants.au3>

    Opt("GUICoordMode", 1)
    ;;;;;;;;;;;;;;;;; Beenden Variablen wegen Hoverdings
    $Herunterfahren = GUICtrlCreateButton ("Herunterfahren", 100, 8, 200, 60, 0)
    $Neustart = GUICtrlCreateButton ("Neustart", 100, 88, 200, 60, 0)
    $Standby = GUICtrlCreateButton ("Standby", 100, 168, 200, 60, 0)
    $close = GUICtrlCreateButton ("Close", 100, 248, 200, 60, 0)
    $backbutton = GUICtrlCreateButton ("Zurück", 100, 328, 200, 60, 0)
    ;;;;;;;;;;;;;;;;; Hauptvariablen
    $HauptGUI = GUICreate("HTPC", 400, 600, 1000, 0)
    GUISetBkColor(0x000000)
    $Button1 = GUICtrlCreateButton("TV", 100, 8, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button2 = GUICtrlCreateButton("DVD", 100, 88, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button3 = GUICtrlCreateButton("Aufnahmen", 100, 168, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button4 = GUICtrlCreateButton("Musik/Bilder", 100, 248, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button5 = GUICtrlCreateButton("Bluray", 100, 328, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button6 = GUICtrlCreateButton("Einstellungen", 100, 408, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Beenden = GUICtrlCreateButton("Beenden", 100, 488, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    GUISetState(@SW_SHOW)
    $Hover_Old = "" ;gehört zum Hover Beispiel
    run ("C:\Dokumente und Einstellungen\Nussman\Desktop\autoitskripte\tests\mausmove.exe") ;setzt die maus auf den ersten button
    HotKeySet("{Down}", "_Down" )

    While 1
    ;Hoverdings
    $Cursor = GUIGetCursorInfo($HauptGUI)
    If $Cursor[4] <> $Hover_Old Then
    Normal($Hover_Old) ; reset the previous control
    Hover($Cursor[4]) ; set the new control hovered
    $Hover_Old = $Cursor[4]
    EndIf
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    Case $msg = $Beenden

    ;Start der Beenden GUI
    $BeendenGUI = GUICreate("Beenden", 400, 600, 1000 , 0)
    GUISetBkColor(0x000000)

    ;Definition der Beenden Variablen
    Opt("GUICoordMode",1)
    GUISetFont( 18, 800, 0, "MS Sans Serif")
    $Herunterfahren = GUICtrlCreateButton ("Herunterfahren", 100, 8, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Neustart = GUICtrlCreateButton ("Neustart", 100, 88, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Standby = GUICtrlCreateButton ("Standby", 100, 168, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $close = GUICtrlCreateButton ("Close", 100, 248, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $backbutton = GUICtrlCreateButton ("Zurück", 100, 328, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    GUISetState(@SW_HIDE, $HauptGUI)
    GUISetState(@SW_SHOW, $BeendenGUI)
    While 1 ;Start der Beenden Schleife

    ;Hoverdings
    $Cursor = GUIGetCursorInfo($BeendenGUI)
    If $Cursor[4] <> $Hover_Old Then
    Normal($Hover_Old) ; reset the previous control
    Hover($Cursor[4]) ; set the new control hovered
    $Hover_Old = $Cursor[4]
    EndIf

    $msg = GUIGetMsg()
    Select

    Case $msg = $close
    Exit

    Case $msg = $Herunterfahren
    ;Schliesse alle Anwendungen und fahre den PC herunter
    run ("C:\WINDOWS\system32\shutdown.exe -f -s -t 00")
    Exit

    Case $msg = $backbutton
    GUISetState(@SW_HIDE, $BeendenGUI)
    GUISetState(@SW_SHOW, $HauptGUI)
    ExitLoop

    Case $msg = $Neustart
    ;Schliesse alle Anwendungen und starte den PC neu
    run ("C:\WINDOWS\system32\shutdown.exe -f -r -t 00")
    Exit

    Case $msg = $Standby
    ;standby (S3 im System eingestellt))
    run ("rundll32.exe powrprof.dll,SetSuspendState")
    Exit
    EndSelect

    Wend ;Ende Herunterfahren GUI
    EndSelect
    WEnd

    Func Hover($ID)
    Switch $ID
    Case $Button1
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button2
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button3
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button4
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button5
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button6
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Beenden
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Herunterfahren
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Neustart
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Standby
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Close
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $backbutton
    GUICtrlSetBkColor($ID, 0xFFFF00)
    EndSwitch
    EndFunc
    Func Normal($ID)
    Switch $ID
    Case $Button1
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button2
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button3
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button4
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button5
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button6
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Beenden
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Herunterfahren
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Neustart
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Standby
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Close
    GUICtrlSetBkColor($ID, 0x008080)
    Case $backbutton
    GUICtrlSetBkColor($ID, 0x008080)
    EndSwitch
    EndFunc

    Func _Down ()
    $pos = MouseGetPos()
    IF $pos [1] < 548 then
    MouseMove (1198, $pos [1] + 80, 0)
    Elseif $pos[1] > 548 then
    run ("C:\Dokumente und Einstellungen\Nussman\Desktop\autoitskripte\tests\mausmove.exe")
    EndIf
    EndFunc

    ist eher noch suboptimal :wacko:
    hab jetzt aber keine lust mehr und geh ins bett 8)

    Einmal editiert, zuletzt von nuts (7. Oktober 2008 um 23:54)

  • auf die Gefahr hin mit dem thema zu nerven .. :whistling:

    hier meine fertige lösung:

    Spoiler anzeigen


    #include <GUIConstants.au3>

    Opt("GUICoordMode", 1)

    ;;;;;;;;;;;;;;;;; Hauptvariablen
    $HauptGUI = GUICreate("HTPC", 400, 600, 1000, 0)
    GUISetBkColor(0x000000)
    $Button1 = GUICtrlCreateButton("TV", 100, 8, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button2 = GUICtrlCreateButton("DVD", 100, 88, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button3 = GUICtrlCreateButton("Aufnahmen", 100, 168, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button4 = GUICtrlCreateButton("Musik/Bilder", 100, 248, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button5 = GUICtrlCreateButton("Bluray", 100, 328, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Button6 = GUICtrlCreateButton("Einstellungen", 100, 408, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    $Beenden = GUICtrlCreateButton("Beenden", 100, 488, 200, 60, 0)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008080)
    GUISetState(@SW_SHOW)
    $Hover_Old = "" ;gehört zum Hover Beispiel
    run ("C:\Dokumente und Einstellungen\Nussman\Desktop\autoitskripte\tests\mousemove\mausmove.exe") ;setzt die maus auf den ersten button

    While 1
    ;Mausroutine in Zusammenspiel mit Eventghost
    $fensterHTPC = WinGetState("HTPC", "")
    IF BitAND($fensterHTPC, 8) then
    _Down()
    Endif
    ;Hoverdings
    $Cursor = GUIGetCursorInfo($HauptGUI)
    If $Cursor[4] <> $Hover_Old Then
    Normal($Hover_Old) ; reset the previous control
    Hover($Cursor[4]) ; set the new control hovered
    $Hover_Old = $Cursor[4]
    EndIf
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    Case $msg = $Beenden
    Exit
    EndSelect
    WEnd

    Func Hover($ID)
    Switch $ID
    Case $Button1
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button2
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button3
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button4
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button5
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Button6
    GUICtrlSetBkColor($ID, 0xFFFF00)
    Case $Beenden
    GUICtrlSetBkColor($ID, 0xFFFF00)
    EndSwitch
    EndFunc
    Func Normal($ID)
    Switch $ID
    Case $Button1
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button2
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button3
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button4
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button5
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Button6
    GUICtrlSetBkColor($ID, 0x008080)
    Case $Beenden
    GUICtrlSetBkColor($ID, 0x008080)
    EndSwitch
    EndFunc
    Func _Down ()
    $pos = MouseGetPos()
    IF $pos [1] > 547 then
    MouseMove (1198, 67, 0)
    EndIf
    IF $pos [1] <67 Then
    MouseMove (1198, 547, 0)
    Endif
    EndFunc

    mit dem fernbedienungsprog. (eventghost) lasse ich bei jedem {down} bzw. {up} befehl die maus um 80 "Punkte" (= abstand der buttons) nach oben/unter verschieben.
    wirklich gut gefällt mir das ganze nicht, muss ja auch an jedem monitor anhand der mauskoordinaten neu einstellt werden.

    wenn noch jemand eine idee hat wie das "richtig" geht ... nur zu.
    würde mich freuen.

  • so hab doch noch ne gescheite lösung gefunden :D
    schlüssel zum sieg war eine hier im forum gefundene funktion (ganz unten im script).

    hat zwar lange gedauert, aber dafür hab ich halbwegs verstanden wie man funktionen einsetzt.

    Spoiler anzeigen


    #include <GuiConstants.au3>

    Global $last_focus = -1
    Opt("GUICoordMode", 1)
    $GUI = GUICreate("HTPC", 400, 600, 1000, 0)
    $Button1 = GUICtrlCreateButton ("lala", 100, 8, 200, 60, 0)
    $Button2 = GUICtrlCreateButton ("lala2", 100, 80, 200, 60, 0)
    $Button = GUICtrlCreateButton("Button", 100, 168, 200, 60, 0)
    GUISetState()

    While 1
    $Msg = GUIGetMsg()
    Switch $Msg
    Case -3
    Exit
    EndSwitch
    If Not _IsFocused($GUI,$last_focus) Then

    Select
    Case _IsFocused($GUI, $Button1)
    GUICtrlSetBkColor(3, 0x008080)
    GUICtrlSetBkColor(4, -1)
    GUICtrlSetBkColor(5, -1)
    $last_focus = $Button1
    Case _IsFocused($GUI, $Button2)
    GUICtrlSetBkColor(4, 0x008080)
    GUICtrlSetBkColor(3, -1)
    GUICtrlSetBkColor(5, -1 )
    $last_focus = $Button2
    Case _IsFocused($GUI, $Button)
    GUICtrlSetBkColor(5, 0x008080)
    GUICtrlSetBkColor(3, -1)
    GUICtrlSetBkColor(4, -1)
    $last_focus = $Button

    EndSelect
    EndIf
    WEnd

    Func _IsFocused($hWnd, $nCID)
    Return GUICtrlGetHandle($nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
    EndFunc

    was mir noch nicht gefällt ist der ausdruck um die hintergrundfarbe des button wieder zu reseten.