Hover flakkert

  • Hallo,
    ich habe mir ein Hovereffekt geschrieben. Das ist schon und gut, flakkert nicht.

    Jetzt habe ich das in eine andere Form gestopft und tada es flakert richtig doll. Was muss ich ändern damit das nicht mehr flakkert ?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <SendMessage.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    Global $minimieren, $schliesen, $Form, $buttons[1][2], $TEMPDIR = ".\bilder", $hover

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 383, 209, 294, 244, $WS_POPUP)
    $titel_balken = GUICtrlCreatePic ("",0,0,500,22)
    $Pic1 = GUICtrlCreatePic($TEMPDIR & "\bg.gif", 0, 0, 382, 208)
    $buttons[0][0] = GUICtrlCreatePic($TEMPDIR & "\start0.jpg", 4, 27, 155, 35)
    $buttons[0][1] = "start"
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    AdlibRegister ("_GUI_hover",200)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $titel_balken
    _SendMessage($Form1, $WM_SYSCOMMAND, 0xF012, 0)
    EndSwitch
    _GUI_hover()
    WEnd

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

    Func _GUI_hover()
    Local $iMouse = GUIGetCursorInfo($Form1)
    If Not @error Then
    For $i = 0 To UBound($buttons) - 1
    Local $bPos = ControlGetPos($Form, "", $buttons[$i][0])
    If ($iMouse[0] >= $bPos[0]) And ($iMouse[0] <= $bPos[0] + $bPos[2]) And ($iMouse[1] >= $bPos[1]) And ($iMouse[1] <= $bPos[1] + $bPos[3]) Then
    If $iMouse[2] = 0 Then
    GUICtrlSetImage($buttons[$i][0], $TEMPDIR & "\" & $buttons[$i][1] & "1.jpg")
    Else
    GUICtrlSetImage($buttons[$i][0], $TEMPDIR & "\" & $buttons[$i][1] & "2.jpg")
    EndIf
    Else
    GUICtrlSetImage($buttons[$i][0], $TEMPDIR & "\" & $buttons[$i][1] & "0.jpg")
    EndIf
    Next
    EndIf
    EndFunc ;==>_GUI_hover

    [/autoit]
  • Ich habs mal überarbeitet, obwohl ich so etwas eigentlich mit GDI+ mache :D.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <SendMessage.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>

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

    Global $minimieren, $schliesen, $Form, $buttons[1][3], $TEMPDIR = @ScriptDir, $hover

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

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 383, 209, 294, 244, $WS_POPUP)
    $titel_balken = GUICtrlCreatePic("", 0, 0, 500, 22)
    $Pic1 = GUICtrlCreatePic($TEMPDIR & "\bg.gif", 0, 0, 382, 208)
    $buttons[0][0] = GUICtrlCreatePic($TEMPDIR & "\start1.jpg", 4, 27, 155, 35)
    $buttons[0][1] = "start"
    $buttons[0][2] = False
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

    AdlibRegister("_GUI_hover", 200)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $titel_balken
    _SendMessage($Form1, $WM_SYSCOMMAND, 0xF012, 0)
    EndSwitch
    _GUI_hover()
    WEnd

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

    Func _GUI_hover()
    Local $iMouse = GUIGetCursorInfo($Form1)
    If Not @error Then
    For $i = 0 To UBound($buttons) - 1
    If $iMouse[4] = $buttons[$i][0] Then
    If $iMouse[2] And $buttons[$i][2] <> 1 Then
    GUICtrlSetImage($buttons[$i][0], $TEMPDIR & "\" & $buttons[$i][1] & "1.jpg")
    $buttons[$i][2] = 1
    ElseIf Not $iMouse[2] And $buttons[$i][2] <> 2 Then
    GUICtrlSetImage($buttons[$i][0], $TEMPDIR & "\" & $buttons[$i][1] & "2.jpg")
    $buttons[$i][2] = 2
    EndIf
    ElseIf $iMouse[4] <> $buttons[$i][0] And $buttons[$i][2] <> 0 Then
    GUICtrlSetImage($buttons[$i][0], $TEMPDIR & "\" & $buttons[$i][1] & "0.jpg")
    $buttons[$i][2] = 0
    EndIf
    Next
    EndIf
    EndFunc ;==>_GUI_hover

    [/autoit]
  • Zitat

    Wie krige ich bei einem Edit den Rand gefärbt ? :D


    .....
    Ich dachte das hätten wir in der SB gekärt ^^. Es gibt um Controls zu färben nur die Funktionen GUICtrlSetColor und GUICtrlSetBKColor. Kann es sein, dass der Rand immer die selbe Farbe hat und es dir einfach erst jetzt aufgefallen ist?