SetImage bei schon vorhandenem Bild

  • Hallo,
    folgendes Problem:

    Ich habe Buttons erstellt und auf diese mit dem $BS_Bitmap Style ein Bild gelegt. Jetzt soll bei einer bestimmten Aktion das vorhandene Bild durch ein neues ersetzt werden. Ich habe versucht das mit guictrlsetimage zu realisieren aber scheinbar wird das neue Bild UNTER dem alten erstellt. Ich hab schon alles mögliche probiert. Hat wer eine Ahnung wie man das hinbekommen kann?


    MfG

    akira2012

    MfG

    akira2012

    ***---____---Wer RechtSCHRAIBfehler findet der darf Sie behalLTEN!---___---***

    • Offizieller Beitrag

    Hallo

    Erstelle den Button doch einfach neu! Man sieht es eigentlich garnicht:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    GUICreate("Test", 107, 53, 193, 125, -1, $WS_EX_TOOLWINDOW)
    $button = GUICtrlCreateButton("", 8, 8, 91, 36, $BS_ICON)
    GUICtrlSetImage(-1, "shell32.dll", Random(0,49,1))
    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    If $msg = $button Then
    GUICtrlDelete($button)
    $button = GUICtrlCreateButton("", 8, 8, 91, 36, $BS_ICON)
    GUICtrlSetImage(-1, "shell32.dll", Random(0,49,1))
    GUICtrlSetState(-1,$GUI_FOCUS)
    EndIf

    WEnd

    [/autoit]

    Mfg Spider

    • Offizieller Beitrag

    Hallo,

    bei mir geht es auch ohne den Button neu zu erstellen:

    [autoit]

    #include <GUIConstants.au3>

    GUICreate("Test", 107, 53, 193, 125, -1, $WS_EX_TOOLWINDOW)
    $button = GUICtrlCreateButton("", 8, 8, 91, 36, $BS_ICON)
    GUICtrlSetImage(-1, "shell32.dll", Random(0,49,1))
    GUISetState()

    While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    If $msg = $button Then
    GUICtrlSetImage($button, "shell32.dll", Random(0,49,1))
    EndIf

    WEnd

    [/autoit]
    • Offizieller Beitrag

    Und wenn du mehrere Aktionen durchführst, sodass ein Flackern sichtbar wäre, kannst du folgendes tun:

    [autoit]

    GUISetState(@SW_LOCK, $winhandle)
    ; Aktionen
    GUISetState(@SW_UNLOCK, $winhandle)

    [/autoit]


    Dabei wird die GUI 'eingefroren', dann passieren die Änderungen und sind nach 'Freigabe' auf einen Schlag sichtbar.

    • Offizieller Beitrag

    Hallo

    Bernd: Ja, die meisten, aber nicht alle funktionieren. Z.B. das hier funktioniert nicht:

    [autoit]

    #include <GUIConstants.au3>

    GUICreate("Test", 107, 53, 193, 125, -1, $WS_EX_TOOLWINDOW)
    $button = GUICtrlCreateButton("", 8, 8, 91, 36, $BS_ICON)
    GUICtrlSetImage(-1, "shell32.dll", 7)
    GUISetState()

    While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    If $msg = $button Then
    GUICtrlSetImage($button, "shell32.dll", 8)
    EndIf

    WEnd

    [/autoit]

    Mfg Spider

  • Danke erstmal für die Hilfe.

    @gta - An neuerstellung habe ich auch gedacht aber ich bekam immer einen Fehler den ich nicht hinbekommen habe.

    Ich werde heute abend mal bernds weg testen ansonsten poste ich einfach mal den code.


    MfG

    akira2012

    MfG

    akira2012

    ***---____---Wer RechtSCHRAIBfehler findet der darf Sie behalLTEN!---___---***

    • Offizieller Beitrag

    @Gta, bei mir funktioniert auch das!

  • ok also ich habs mir mal genauer angeschaut aber das ist genau das was ich gemacht habe - nur das ich den style $BS-BITMAP und nicht %BS_ICON benutzt habe. Schaut euch mal den Code an plz
    Also hierdrum gehts


    Spoiler anzeigen
    [autoit]


    func schiffe()
    $info=GUIGetCursorInfo ()

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

    _ArrayAdd($Schiffe, $info[4])
    $Schiffe[0]=$Schiffe[0]+1
    GUICtrlSetStyle($info[4], $BS_BITMAP)
    GUICtrlSetImage($info[4], "C:\Scripte\Poker\Karten\Herz Bube.bmp")
    GUICtrlSetData($info[4], "Schiff")

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

    ;MsgBox(0, "", $position)

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

    EndFunc

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

    func setzen()
    $z=0
    for $i = 4 to 172
    switch $i
    case 146 to 170
    local $Test = GUICtrlRead($i)
    local $test2=Guictrlread($i+1)
    local $test3=Guictrlread($i+2)
    ;MsgBox(0, $i, @ScriptDir&"\grey.bmp")
    case 171 to 172
    ExitLoop
    case 4 to 146
    local $Test = GUICtrlRead($i)
    local $test2=Guictrlread($i+1)
    local $test3=Guictrlread($i+2)
    local $test4=Guictrlread($i+13)
    local $test5=Guictrlread($i+26)
    ;MsgBox(0, $i, $test&" "&$test2&" "&$test3&" "&$test4&" "&$test5)
    EndSwitch
    IF $test="Schiff" AND $test2="Schiff" AND $test3="Schiff" Then
    #cs
    $position2=ControlGetPos("Schiffe versenken" ,"", $i)
    $x=$position2[0]
    $y=$position2[1]
    $width=$position2[2]
    $high=$position2[3]
    #ce
    GUICtrlSetData($i, "Transporter")
    GUICtrlSetStyle($i, $BS_BITMAP)
    GUICtrlsetImage($i, @ScriptDir&"\grey.bmp")
    GUICtrlsetData($i+1, "Transporter")
    GUICtrlSetStyle($i+1, $BS_BITMAP)
    GUICtrlSetImage($i+1, @ScriptDir&"\grey.bmp")
    GUICtrlSetData($i+2, "Transporter")
    GUICtrlSetStyle($i+2, $BS_BITMAP)
    GUICtrlSetImage($i+2, @ScriptDir&"\grey.bmp")
    ExitLoop

    ElseIF $test="Schiff" AND $test4="Schiff" AND $test5="Schiff" Then
    GUICtrlSetData($i, "Transporter")
    GUICtrlSetStyle($i, -1 )
    GUICtrlSetImage($i, "")
    GUICtrlSetData($i+13, "Transporter")
    GUICtrlSetStyle($i+13, -1 )
    GUICtrlSetImage($i+13, @ScriptDir&"\grey.bmp")
    GUICtrlSetData($i+26, "Transporter")
    GUICtrlSetStyle($i+26, -1 )
    GUICtrlSetImage($i+26, @ScriptDir&"\grey.bmp")
    exitLoop
    endIf
    Next


    EndFunc
    func schiffe()
    $info=GUIGetCursorInfo ()

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

    _ArrayAdd($Schiffe, $info[4])
    $Schiffe[0]=$Schiffe[0]+1
    GUICtrlSetStyle($info[4], $BS_BITMAP)
    GUICtrlSetImage($info[4], "C:\Scripte\Poker\Karten\Herz Bube.bmp")
    GUICtrlSetData($info[4], "Schiff")

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

    ;MsgBox(0, "", $position)

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

    EndFunc

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

    func setzen()
    $z=0
    for $i = 4 to 172
    switch $i
    case 146 to 170
    local $Test = GUICtrlRead($i)
    local $test2=Guictrlread($i+1)
    local $test3=Guictrlread($i+2)
    ;MsgBox(0, $i, @ScriptDir&"\grey.bmp")
    case 171 to 172
    ExitLoop
    case 4 to 146
    local $Test = GUICtrlRead($i)
    local $test2=Guictrlread($i+1)
    local $test3=Guictrlread($i+2)
    local $test4=Guictrlread($i+13)
    local $test5=Guictrlread($i+26)
    ;MsgBox(0, $i, $test&" "&$test2&" "&$test3&" "&$test4&" "&$test5)
    EndSwitch
    IF $test="Schiff" AND $test2="Schiff" AND $test3="Schiff" Then
    #cs
    $position2=ControlGetPos("Schiffe versenken" ,"", $i)
    $x=$position2[0]
    $y=$position2[1]
    $width=$position2[2]
    $high=$position2[3]
    #ce
    GUICtrlSetData($i, "Transporter")
    GUICtrlSetStyle($i, $BS_BITMAP)
    GUICtrlsetImage($i, @ScriptDir&"\grey.bmp")
    GUICtrlsetData($i+1, "Transporter")
    GUICtrlSetStyle($i+1, $BS_BITMAP)
    GUICtrlSetImage($i+1, @ScriptDir&"\grey.bmp")
    GUICtrlSetData($i+2, "Transporter")
    GUICtrlSetStyle($i+2, $BS_BITMAP)
    GUICtrlSetImage($i+2, @ScriptDir&"\grey.bmp")
    ExitLoop

    ElseIF $test="Schiff" AND $test4="Schiff" AND $test5="Schiff" Then
    GUICtrlSetData($i, "Transporter")
    GUICtrlSetStyle($i, -1 )
    GUICtrlSetImage($i, "")
    GUICtrlSetData($i+13, "Transporter")
    GUICtrlSetStyle($i+13, -1 )
    GUICtrlSetImage($i+13, @ScriptDir&"\grey.bmp")
    GUICtrlSetData($i+26, "Transporter")
    GUICtrlSetStyle($i+26, -1 )
    GUICtrlSetImage($i+26, @ScriptDir&"\grey.bmp")
    exitLoop
    endIf
    Next


    EndFunc

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

    func schiffe()
    $info=GUIGetCursorInfo ()

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

    _ArrayAdd($Schiffe, $info[4])
    $Schiffe[0]=$Schiffe[0]+1
    GUICtrlSetStyle($info[4], $BS_BITMAP)
    GUICtrlSetImage($info[4], "C:\Scripte\Poker\Karten\Herz Bube.bmp")
    GUICtrlSetData($info[4], "Schiff")

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

    ;MsgBox(0, "", $position)

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

    EndFunc

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

    func setzen()
    $z=0
    for $i = 4 to 172
    switch $i
    case 146 to 170
    local $Test = GUICtrlRead($i)
    local $test2=Guictrlread($i+1)
    local $test3=Guictrlread($i+2)
    ;MsgBox(0, $i, @ScriptDir&"\grey.bmp")
    case 171 to 172
    ExitLoop
    case 4 to 146
    local $Test = GUICtrlRead($i)
    local $test2=Guictrlread($i+1)
    local $test3=Guictrlread($i+2)
    local $test4=Guictrlread($i+13)
    local $test5=Guictrlread($i+26)
    ;MsgBox(0, $i, $test&" "&$test2&" "&$test3&" "&$test4&" "&$test5)
    EndSwitch
    IF $test="Schiff" AND $test2="Schiff" AND $test3="Schiff" Then
    #cs
    $position2=ControlGetPos("Schiffe versenken" ,"", $i)
    $x=$position2[0]
    $y=$position2[1]
    $width=$position2[2]
    $high=$position2[3]
    #ce
    GUICtrlSetData($i, "Transporter")
    GUICtrlSetStyle($i, $BS_BITMAP)
    GUICtrlsetImage($i, @ScriptDir&"\grey.bmp")
    GUICtrlsetData($i+1, "Transporter")
    GUICtrlSetStyle($i+1, $BS_BITMAP)
    GUICtrlSetImage($i+1, @ScriptDir&"\grey.bmp")
    GUICtrlSetData($i+2, "Transporter")
    GUICtrlSetStyle($i+2, $BS_BITMAP)
    GUICtrlSetImage($i+2, @ScriptDir&"\grey.bmp")
    ExitLoop

    ElseIF $test="Schiff" AND $test4="Schiff" AND $test5="Schiff" Then
    GUICtrlSetData($i, "Transporter")
    GUICtrlSetStyle($i, -1 )
    GUICtrlSetImage($i, "")
    GUICtrlSetData($i+13, "Transporter")
    GUICtrlSetStyle($i+13, -1 )
    GUICtrlSetImage($i+13, @ScriptDir&"\grey.bmp")
    GUICtrlSetData($i+26, "Transporter")
    GUICtrlSetStyle($i+26, -1 )
    GUICtrlSetImage($i+26, @ScriptDir&"\grey.bmp")
    exitLoop
    endIf
    Next


    EndFunc

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


    EDIT: Das ist immer noch aktuell - hat mitlerweile einer eine idee? ^^

    MfG

    akira2012

    ***---____---Wer RechtSCHRAIBfehler findet der darf Sie behalLTEN!---___---***

    2 Mal editiert, zuletzt von akira2012 (14. März 2008 um 01:08)