Bilder-Flackern entfernen

  • Hi Leute

    Ich wollt für mein Program ein Rating mit Sternen machen, nur weis ich nicht wie ich das Flackern weg bekomme weil ich die Bilder jedes mal lösche und wieder einfüge
    Wenn es bessere Realisationsvorschlage gibt immer her damit ;)

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>

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

    $GUI = GUICreate("", 500, 500)
    Dim $Button[6]
    $Button[1] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 50, 100, 50, 50)
    $Button[2] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 100, 100, 50, 50)
    $Button[3] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 150, 100, 50, 50)
    $Button[4] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 200, 100, 50, 50)
    $Button[5] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 250, 100, 50, 50)

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

    GUISetState(@SW_SHOW)
    ;############### LOOP ###############
    While 1
    $Mouseover = GUIGetCursorInfo($GUI)
    If $Mouseover[4] = $Button[1] Then
    GUICtrlDelete($Button[2])
    GUICtrlDelete($Button[3])
    GUICtrlDelete($Button[4])
    GUICtrlDelete($Button[5])
    $Button[2] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 100, 100, 50, 50)
    $Button[3] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 150, 100, 50, 50)
    $Button[4] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 200, 100, 50, 50)
    $Button[5] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 250, 100, 50, 50)
    $Zahl = 1
    EndIf
    If $Mouseover[4] = $Button[2] Then
    GUICtrlDelete($Button[2])
    GUICtrlDelete($Button[3])
    GUICtrlDelete($Button[4])
    GUICtrlDelete($Button[5])
    $Button[2] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 100, 100, 50, 50)
    $Button[3] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 150, 100, 50, 50)
    $Button[4] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 200, 100, 50, 50)
    $Button[5] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 250, 100, 50, 50)
    EndIf
    If $Mouseover[4] = $Button[3] Then
    GUICtrlDelete($Button[2])
    GUICtrlDelete($Button[3])
    GUICtrlDelete($Button[4])
    GUICtrlDelete($Button[5])
    $Button[2] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 100, 100, 50, 50)
    $Button[3] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 150, 100, 50, 50)
    $Button[4] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 200, 100, 50, 50)
    $Button[5] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 250, 100, 50, 50)
    EndIf
    If $Mouseover[4] = $Button[4] Then
    GUICtrlDelete($Button[2])
    GUICtrlDelete($Button[3])
    GUICtrlDelete($Button[4])
    GUICtrlDelete($Button[5])
    $Button[2] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 100, 100, 50, 50)
    $Button[3] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 150, 100, 50, 50)
    $Button[4] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 200, 100, 50, 50)
    $Button[5] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 250, 100, 50, 50)
    EndIf
    If $Mouseover[4] = $Button[5] Then
    GUICtrlDelete($Button[2])
    GUICtrlDelete($Button[3])
    GUICtrlDelete($Button[4])
    GUICtrlDelete($Button[5])
    $Button[2] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 100, 100, 50, 50)
    $Button[3] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 150, 100, 50, 50)
    $Button[4] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 200, 100, 50, 50)
    $Button[5] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 250, 100, 50, 50)
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]

    Danke schon mal im vorraus

    Keyle

  • Moin,

    Du solltest die Buttons nur einmal erzeugen, und dann mittels GuiCtrlSetState($Button, @GUI_HIDE), bzw. $GUI_SHOW verstecken und anzeigen.

    Gruß

  • Ich hab irgendwie den Wurm drin,
    das flackert jetzt die ganze Zet durch.
    keine Ahnung wie ich das machen soll ?(

    aber @TrueMu danke für den Tipp hiden ist sinvoller

    Spoiler anzeigen
    [autoit]


    #include <GuiConstantsEx.au3>

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

    $GUI = GUICreate("", 500, 500)
    Dim $Button[6],$ButtonE[6]

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

    $ButtonE[1] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 50, 100, 50, 50)
    $ButtonE[2] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 100, 100, 50, 50)
    $ButtonE[3] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 150, 100, 50, 50)
    $ButtonE[4] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 200, 100, 50, 50)
    $ButtonE[5] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 250, 100, 50, 50)
    $Button[1] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 50, 100, 50, 50)
    $Button[2] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 100, 100, 50, 50)
    $Button[3] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 150, 100, 50, 50)
    $Button[4] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 200, 100, 50, 50)
    $Button[5] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 250, 100, 50, 50)

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

    GUISetState(@SW_SHOW)
    ;############### LOOP ###############
    While 1
    $Mouseover = GUIGetCursorInfo($GUI)
    If $Mouseover[4] = $Button[1] or $ButtonE[1] Then
    GuiCtrlSetState($Button[2], $GUI_HIDE)
    GuiCtrlSetState($Button[3], $GUI_HIDE)
    GuiCtrlSetState($Button[4], $GUI_HIDE)
    GuiCtrlSetState($Button[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[5], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[2], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[3], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[4], $GUI_SHOW)
    EndIf
    If $Mouseover[4] = $Button[2] or $ButtonE[2] Then
    GuiCtrlSetState($Button[2], $GUI_SHOW)
    GuiCtrlSetState($Button[3], $GUI_HIDE)
    GuiCtrlSetState($Button[4], $GUI_HIDE)
    GuiCtrlSetState($Button[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[2], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[3], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[4], $GUI_SHOW)
    EndIf
    If $Mouseover[4] = $Button[3] or $ButtonE[3] Then
    GuiCtrlSetState($Button[2], $GUI_SHOW)
    GuiCtrlSetState($Button[3], $GUI_SHOW)
    GuiCtrlSetState($Button[4], $GUI_HIDE)
    GuiCtrlSetState($Button[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[2], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[3], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[4], $GUI_SHOW)
    EndIf
    If $Mouseover[4] = $Button[4] or $ButtonE[4] Then
    GuiCtrlSetState($Button[2], $GUI_SHOW)
    GuiCtrlSetState($Button[3], $GUI_SHOW)
    GuiCtrlSetState($Button[4], $GUI_SHOW)
    GuiCtrlSetState($Button[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[2], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[3], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[4], $GUI_SHOW)
    EndIf
    If $Mouseover[4] = $ButtonE[5] or $ButtonE[5] Then
    GuiCtrlSetState($Button[2], $GUI_SHOW)
    GuiCtrlSetState($Button[3], $GUI_SHOW)
    GuiCtrlSetState($Button[4], $GUI_SHOW)
    GuiCtrlSetState($Button[5], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[2], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[3], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[4], $GUI_HIDE)
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]

    Keyle

  • während der mauszeiger da drauf ist wird die operation immer wieder wiederholt
    daher kommt das flackern

    das sollte helfen (konnte es leider nicht ausprobieren)

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>

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

    $GUI = GUICreate("", 500, 500)
    Dim $Button[6],$ButtonE[6], $over

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

    $ButtonE[1] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 50, 100, 50, 50)
    $ButtonE[2] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 100, 100, 50, 50)
    $ButtonE[3] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 150, 100, 50, 50)
    $ButtonE[4] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 200, 100, 50, 50)
    $ButtonE[5] = GUICtrlCreatePic(@ScriptDir & "\empty.gif", 250, 100, 50, 50)
    $Button[1] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 50, 100, 50, 50)
    $Button[2] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 100, 100, 50, 50)
    $Button[3] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 150, 100, 50, 50)
    $Button[4] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 200, 100, 50, 50)
    $Button[5] = GUICtrlCreatePic(@ScriptDir & "\full.gif", 250, 100, 50, 50)

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

    GUISetState(@SW_SHOW)
    ;############### LOOP ###############
    While 1
    $Mouseover = GUIGetCursorInfo($GUI)
    If $over <> 1 And $Mouseover[4] = $Button[1] or $ButtonE[1] Then
    GuiCtrlSetState($Button[2], $GUI_HIDE)
    GuiCtrlSetState($Button[3], $GUI_HIDE)
    GuiCtrlSetState($Button[4], $GUI_HIDE)
    GuiCtrlSetState($Button[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[5], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[2], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[3], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[4], $GUI_SHOW)
    $over = 1
    EndIf
    If $over <> 2 And $Mouseover[4] = $Button[2] or $ButtonE[2] Then
    GuiCtrlSetState($Button[2], $GUI_SHOW)
    GuiCtrlSetState($Button[3], $GUI_HIDE)
    GuiCtrlSetState($Button[4], $GUI_HIDE)
    GuiCtrlSetState($Button[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[2], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[3], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[4], $GUI_SHOW)
    $over = 2
    EndIf
    If $over <> 3 And $Mouseover[4] = $Button[3] or $ButtonE[3] Then
    GuiCtrlSetState($Button[2], $GUI_SHOW)
    GuiCtrlSetState($Button[3], $GUI_SHOW)
    GuiCtrlSetState($Button[4], $GUI_HIDE)
    GuiCtrlSetState($Button[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[2], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[3], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[4], $GUI_SHOW)
    $over = 3
    EndIf
    If $over <> 4 And $Mouseover[4] = $Button[4] or $ButtonE[4] Then
    GuiCtrlSetState($Button[2], $GUI_SHOW)
    GuiCtrlSetState($Button[3], $GUI_SHOW)
    GuiCtrlSetState($Button[4], $GUI_SHOW)
    GuiCtrlSetState($Button[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[2], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[3], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[4], $GUI_SHOW)
    $over = 4
    EndIf
    If $over <> 5 And $Mouseover[4] = $ButtonE[5] or $ButtonE[5] Then
    GuiCtrlSetState($Button[2], $GUI_SHOW)
    GuiCtrlSetState($Button[3], $GUI_SHOW)
    GuiCtrlSetState($Button[4], $GUI_SHOW)
    GuiCtrlSetState($Button[5], $GUI_SHOW)
    GuiCtrlSetState($ButtonE[5], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[2], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[3], $GUI_HIDE)
    GuiCtrlSetState($ButtonE[4], $GUI_HIDE)
    $over = 5
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]
  • Moin,

    musst schauen, ob Du damit leben kannst ... ;)

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>

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

    Global $Button[5][2]

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

    $GUI = GUICreate("", 500, 500)

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

    $Button[0][0] = GUICtrlCreatePic (".\empty.gif", 50, 100, 50, 50)
    $Button[1][0] = GUICtrlCreatePic (".\empty.gif", 100, 100, 50, 50)
    $Button[2][0] = GUICtrlCreatePic (".\empty.gif", 150, 100, 50, 50)
    $Button[3][0] = GUICtrlCreatePic (".\empty.gif", 200, 100, 50, 50)
    $Button[4][0] = GUICtrlCreatePic (".\empty.gif", 250, 100, 50, 50)

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

    GUISetState(@SW_SHOW, $GUI)
    ;############### LOOP ###############
    While 1

    $Mouseover = GUIGetCursorInfo ($GUI)

    For $i = 0 To 4

    If $Mouseover[4] == $Button[$i][0] Then

    For $ix = 0 To 4

    If ($ix <= $i And Not $Button[$ix][1]) Then

    GUICtrlSetImage ($Button[$ix][0], ".\full.gif")

    $Button[$ix][1] = True
    EndIf

    If ($ix > $i And $Button[$ix][1]) Then

    GUICtrlSetImage ($Button[$ix][0], ".\empty.gif")

    $Button[$ix][1] = False
    EndIf
    Next

    ElseIf $Mouseover[4] == 0 Then

    If ($Button[$i][1]) Then

    GUICtrlSetImage ($Button[$i][0], ".\empty.gif")

    $Button[$i][1] = False
    EndIf
    EndIf
    Next

    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

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

    LG
    Greenhorn

    p.s.: Es hat nicht nur geflackert, sondern auch die CPU voll ausgelastet !


  • huch hab ich bei mir gar nicht gemerkt das mit der CPU

    thx @Greenhorn

    wenn der jetzt noch den Zustand speicher wenn die Maus da weg geht isses Perfekt :D

    edit: habs selbst einfach das letzte elseif weglassen :D

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>

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

    Global $Button[5][2]

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

    $GUI = GUICreate("", 500, 500)

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

    $Button[0][0] = GUICtrlCreatePic (".\empty.gif", 50, 100, 50, 50)
    $Button[1][0] = GUICtrlCreatePic (".\empty.gif", 100, 100, 50, 50)
    $Button[2][0] = GUICtrlCreatePic (".\empty.gif", 150, 100, 50, 50)
    $Button[3][0] = GUICtrlCreatePic (".\empty.gif", 200, 100, 50, 50)
    $Button[4][0] = GUICtrlCreatePic (".\empty.gif", 250, 100, 50, 50)

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

    GUISetState(@SW_SHOW, $GUI)
    ;############### LOOP ###############
    While 1

    $Mouseover = GUIGetCursorInfo ($GUI)

    For $i = 0 To 4

    If $Mouseover[4] == $Button[$i][0] Then

    For $ix = 0 To 4

    If ($ix <= $i And Not $Button[$ix][1]) Then

    GUICtrlSetImage ($Button[$ix][0], ".\full.gif")

    $Button[$ix][1] = True
    EndIf

    If ($ix > $i And $Button[$ix][1]) Then

    GUICtrlSetImage ($Button[$ix][0], ".\empty.gif")

    $Button[$ix][1] = False
    EndIf
    Next
    EndIf
    EndIf
    Next

    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]

    Mfg Keyle