Progresscolor ändern NICHT möglich unter Windows 7 x32...???

  • Hey leute:
    mein Code:

    [autoit]

    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <WindowsConstants.au3>
    $Form1 = GUICreate("Form1", 625, 443, 210, 57)
    $Progress1 = GUICtrlCreateProgress(48, 96, 529, 25)
    GUICtrlSetColor($Progress1, 0xFF0000)
    GUICtrlSetData($Progress1, 80)
    GUISetState(@SW_SHOW)

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

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

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

    EndSwitch
    WEnd

    [/autoit]


    und meine Frage: warum ändert sich die Farbe nicht in Rot um...

    Die Hintergrundfarbe lässt sich auch nicht ändern....

    Woran kann das liegen..? :?:

    Mfg Mr_Gitarre :rock:

    4 Mal editiert, zuletzt von Mr_gitarre (3. Oktober 2010 um 11:13)

  • Edit:

    Aus einem anderem Forum:

    [autoit]

    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

    [/autoit]

    muss oben aufgerufen werden...

    dann kann man auch unter windows 7 die Farbe ändern...

    Doch dann hat der Progress keinen Window 7 Style mehr...:(

    Also: ausweichmöglichkeit gefunden, doch kann mir jemand sagen, wie es auch geht, ohne den Style zu verändern...??

  • [autoit]

    ;===========================================================================
    ; Version : V 1.20
    ; Example : _BKColor() :Transparent
    ; _BKColor( -1, $MeinLabel) :Transparent
    ; _BKColor(0x00ff00) :Color Green
    ; _BKColor(0x00ff00, $MeinLabel) :Color Green
    ; _BKColor( -1, $MeinLabel, 0x00ff00) :Text Color Green
    ;===========================================================================

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

    Func _BKColor($BackColor_ = "", $GuiID_ = -1, $Textcolor_ = 0x000000)
    If $BackColor_ = "" Or $BackColor_ = -1 Then
    GUICtrlSetBkColor($GuiID_, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor($GuiID_, $Textcolor_)
    Else
    GUICtrlSetBkColor($GuiID_, $BackColor_)
    GUICtrlSetColor($GuiID_, $Textcolor_)
    EndIf
    EndFunc ;==>_BKColor
    ;=======================================================================

    [/autoit]

    Meine Projekte :

    Taschenrechner [X]
    JamLegend Auto-Player [Canceld]
    Launcher [X]
    Multi-Game-Quest-Viewer [Canceld]


    [autoit]

    If $goffy or not $brain Then $DeleteInetCable

    [/autoit]
  • Aus der Hilfe:

    Zitat

    Folgende Items können momentan gefärbt werden: Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic, Progress und Combo

    Checkbox, Radio, Group oder Progress-Controls können nicht gefärbt werden, wenn der "Windows XP style" verwendet wird.

    Also mit den Standard-Controls erstmal garnich.
    Es gibt aber iwo ne Progress UDF von progandy wenn ich mich nicht irre.
    Ich glaube die könnte das

    • Offizieller Beitrag

    Für die Variante mit dem DLL-Call hatte ich mir mal ein Beispiel-Skript erstellt:

    Spoiler anzeigen
    [autoit]


    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>

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

    Global $hGui = GUICreate('Klassische Progressbar', 420, 280, -1, -1)

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

    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0) ; auf den klassischen Style umschalten
    Global $hProgress1 = GUICtrlCreateProgress(15, 20, 384, 20, $PBS_SMOOTH) ; obere Progressbar erstellen
    GUICtrlSetColor(-1, 0x22FF22)
    GUICtrlSetBkColor(-1, 0xEEEEEE)
    GUICtrlCreateLabel('|', 18, 40, 20, 16) ; Anzeige von 0%
    GUICtrlCreateLabel('0%', 11, 56, 25, 16, $SS_CENTER)
    GUICtrlCreateLabel('|', 396, 40, 20, 16) ; Anzeige von 100%
    GUICtrlCreateLabel('100%', 389, 56, 25, 16, $SS_CENTER)

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

    Global $hLabel1 = GUICtrlCreateLabel('0%', 190, 23, 30, 14, $SS_CENTER) ; Prozentanzeige innerhalb der Progressbar
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; Transparenter Hintergrund für das Label

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

    Global $hProgress2 = GUICtrlCreateProgress(15, 160, 384, 20, $PBS_SMOOTH) ; untere Progressbar erstellen
    GUICtrlSetColor(-1, 0xC83131)
    GUICtrlSetBkColor(-1, 0xEEEEEE)
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 7) ; zurück zum Standard-Windowsstyle

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

    For $i = 0 To 100 Step 10 ; die Anzeige für die Prozentwerte der unteren Progressbar erstellen
    GUICtrlCreateLabel('|', 16 + $i * 3.8, 180, 20, 16)
    GUICtrlCreateLabel($i & '%', 9 + $i * 3.8, 196, 25, 16, $SS_CENTER)
    Next

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

    Global $hSlider = GUICtrlCreateSlider(5, 130, 404, 28, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
    GUICtrlSetData(-1, 33) ; Sliderwert auf 33% setzen (als Beispiel)

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

    Global $hClose = GUICtrlCreateButton('Close', 180, 240, 60, 24)
    GUISetState(@SW_SHOW)

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

    Global $iAddend = 1 ; globale Variable (dient als Summand für _SetProgress)
    AdlibRegister('_SetProgress', 50)

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

    While True
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $hClose
    AdlibUnRegister()
    Exit
    EndSwitch
    WEnd

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

    Func _SetProgress()
    Local $iPercent = GUICtrlRead($hProgress1) ; Prozentwert der oberen Progressbar auslesen
    If $iPercent = 100 Or $iPercent = 0 Then $iAddend = -$iAddend ; wenn 100 oder Null, dann den Summand negieren
    GUICtrlSetData($hProgress1, $iPercent + $iAddend) ; neuen Wert der oberen Progressbar schreiben
    GUICtrlSetData($hLabel1, $iPercent + $iAddend & '%') ; neuen Wert für das Label schreiben
    GUICtrlSetData($hProgress2, GUICtrlRead($hSlider)) ; und den Wert vom Slider in die untere Progressbar schreiben
    EndFunc ;==>_SetProgress

    [/autoit]


    So hat man eine farbige Progressbar im klassischen Stil und der Rest der GUI-Elemente kann im modernen Look dargestellt werden.

    Wenn Du dagegen mit der roten Progressbar auf die Farben (grün, rot, gelb) bei Vista und Windows7 anspielst, dann kannst Du die Funktion von progandy benutzen:

    Spoiler anzeigen
    [autoit]


    #include-once
    #include<SendMessage.au3>
    #include<ProgressConstants.au3>
    Global Const $PBST_NORMAL = 0x0001
    Global Const $PBST_ERROR = 0x0002
    Global Const $PBST_PAUSED = 0x0003
    Global Const $PBM_SETSTATE = 0x0410
    Global Const $PBM_GETSTATE = 0x0411

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlProgress_SetState
    ; Description ...: Sets the state of the progressbar
    ; Syntax.........: _GUICtrlProgress_SetState($iProgress, $iStyle)
    ; Parameters ....: $iProgress - handle or CtrlID of progressbar
    ; $iState - new status of progress:
    ; |$PBM_NORMAL - normal state (green)
    ; |$PBM_ERROR - error state (red)
    ; |$PBM_PAUSED - paused style (yellow)
    ; Return values .: Success -
    ; Failure - 0
    ; Author ........: Prog@ndy
    ; Modified.......:
    ; Remarks .......: requires WinVista or above
    ; Related .......:
    ; Link ..........; @@MsdnLink@@ PBM_SETSTATE
    ; Example .......;
    ; ===============================================================================================================================
    Func _GUICtrlProgress_SetState($iProgress, $iState)
    ; Author: Prog@ndy
    Switch IsHWnd($iProgress)
    Case True
    Return _SendMessage($iProgress, $PBM_SETSTATE, $iState, 0)
    Case Else
    Return GUICtrlSendMsg($iProgress, $PBM_SETSTATE, $iState, 0)
    EndSwitch
    EndFunc ;==>_GUICtrlProgress_SetState

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlProgress_GetState
    ; Description ...: Gets the state of the progressbar
    ; Syntax.........: _GUICtrlProgress_GetState($iProgress)
    ; Parameters ....: $iProgress - handle or CtrlID of progressbar
    ; Return values .: Success - status of progress:
    ; |$PBM_NORMAL - normal state (green)
    ; |$PBM_ERROR - error state (red)
    ; |$PBM_PAUSED - paused style (yellow)
    ; Failure - 0
    ; Author ........: Prog@ndy
    ; Modified.......:
    ; Remarks .......: requires WinVista or above
    ; Related .......:
    ; Link ..........; @@MsdnLink@@ PBM_GETSTATE
    ; Example .......;
    ; ===============================================================================================================================
    Func _GUICtrlProgress_GetState($iProgress)
    ; Author: Prog@ndy
    Switch IsHWnd($iProgress)
    Case True
    Return _SendMessage($iProgress, $PBM_GETSTATE, 0, 0)
    Case Else
    Return GUICtrlSendMsg($iProgress, $PBM_GETSTATE, 0, 0)
    EndSwitch
    EndFunc ;==>_GUICtrlProgress_GetState

    [/autoit]
  • ok...

    ist schonmal viel information...

    Der letzte Code von Oscar interessiert mich...

    Dabei gibts folgende Fehlermeldung beim starten:


    WARUM...?

  • [autoit]

    #include-once
    #include<SendMessage.au3>
    #include<ProgressConstants.au3>

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

    Global Const $PBST_NORMAL = 0x0001
    Global Const $PBST_ERROR = 0x0002
    Global Const $PBST_PAUSED = 0x0003
    Global Const $PBM_SETSTATE2 = 0x0410
    Global Const $PBM_GETSTATE2 = 0x0411

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlProgress_SetState
    ; Description ...: Sets the state of the progressbar
    ; Syntax.........: _GUICtrlProgress_SetState($iProgress, $iStyle)
    ; Parameters ....: $iProgress - handle or CtrlID of progressbar
    ; $iState - new status of progress:
    ; |$PBM_NORMAL - normal state (green)
    ; |$PBM_ERROR - error state (red)
    ; |$PBM_PAUSED - paused style (yellow)
    ; Return values .: Success -
    ; Failure - 0
    ; Author ........: Prog@ndy
    ; Modified.......:
    ; Remarks .......: requires WinVista or above
    ; Related .......:
    ; Link ..........; @@MsdnLink@@ PBM_SETSTATE
    ; Example .......;
    ; ===============================================================================================================================
    Func _GUICtrlProgress_SetState($iProgress, $iState)
    ; Author: Prog@ndy
    Switch IsHWnd($iProgress)
    Case True
    Return _SendMessage($iProgress, $PBM_SETSTATE2, $iState, 0)
    Case Else
    Return GUICtrlSendMsg($iProgress, $PBM_SETSTATE2, $iState, 0)
    EndSwitch
    EndFunc ;==>_GUICtrlProgress_SetState

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlProgress_GetState
    ; Description ...: Gets the state of the progressbar
    ; Syntax.........: _GUICtrlProgress_GetState($iProgress)
    ; Parameters ....: $iProgress - handle or CtrlID of progressbar
    ; Return values .: Success - status of progress:
    ; |$PBM_NORMAL - normal state (green)
    ; |$PBM_ERROR - error state (red)
    ; |$PBM_PAUSED - paused style (yellow)
    ; Failure - 0
    ; Author ........: Prog@ndy
    ; Modified.......:
    ; Remarks .......: requires WinVista or above
    ; Related .......:
    ; Link ..........; @@MsdnLink@@ PBM_GETSTATE
    ; Example .......;
    ; ===============================================================================================================================
    Func _GUICtrlProgress_GetState($iProgress)
    ; Author: Prog@ndy
    Switch IsHWnd($iProgress)
    Case True
    Return _SendMessage($iProgress, $PBM_GETSTATE2, 0, 0)
    Case Else
    Return GUICtrlSendMsg($iProgress, $PBM_GETSTATE2, 0, 0)
    EndSwitch
    EndFunc ;==>_GUICtrlProgress_GetState

    [/autoit]

    hab die funktion so verändert!
    jetzt funktioniert sie ohne Fehlermeldung...

    Aber ich weiß nicht, wie ich die übergabe parameter setzen soll, um Zb. ne Rote Farbe hinzukriegen...
    werd einfach nich schlau daraus...!

    Kann mir jemand nen beispiel für
    _GUICtrlProgress_setState()

    schreiben...?

    ps: In der funktion hab ich mir angeguckt, wie der syntex ist, doch irgendwie ist mir schleierhaft, WAS GENAU geschrieben werden muss.,.

    vielen dank :rock:

    • Offizieller Beitrag
    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include<SendMessage.au3>
    #include<ProgressConstants.au3>

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

    Global Const $PBST_NORMAL = 0x0001
    Global Const $PBST_ERROR = 0x0002
    Global Const $PBST_PAUSED = 0x0003
    Global Const $PBM_SETSTATE2 = 0x0410
    Global Const $PBM_GETSTATE2 = 0x0411

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

    Opt('MustDeclareVars', 1)

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

    Example()

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

    Func Example()
    Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m

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

    GUICreate("My GUI Progressbar", 220, 100, 100, 200)
    $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
    _GUICtrlProgress_SetState($progressbar2, $PBST_PAUSED)
    $button = GUICtrlCreateButton("Start", 75, 70, 70, 20)
    GUISetState()

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

    $wait = 20; wait 20ms for next progressstep
    $s = 0; progressbar-saveposition
    Do
    $msg = GUIGetMsg()
    If $msg = $button Then
    GUICtrlSetData($button, "Stop")
    For $i = $s To 100
    If GUICtrlRead($progressbar1) = 50 Then
    MsgBox(0, "Info", "Jetzt wird es Rot", 1)
    _GUICtrlProgress_SetState($progressbar1, $PBST_ERROR)
    Endif

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

    $m = GUIGetMsg()

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

    If $m = -3 Then ExitLoop

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

    If $m = $button Then
    GUICtrlSetData($button, "Next")
    $s = $i;save the current bar-position to $s
    ExitLoop
    Else
    $s = 0
    GUICtrlSetData($progressbar1, $i)
    GUICtrlSetData($progressbar2, (100 - $i))
    Sleep($wait)
    EndIf
    Next
    If $i > 100 Then
    ; $s=0
    _GUICtrlProgress_SetState($progressbar1, $PBST_NORMAL)
    GUICtrlSetData($button, "Start")
    EndIf
    EndIf
    Until $msg = $GUI_EVENT_CLOSE
    EndFunc ;==>Example

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlProgress_SetState
    ; Description ...: Sets the state of the progressbar
    ; Syntax.........: _GUICtrlProgress_SetState($iProgress, $iStyle)
    ; Parameters ....: $iProgress - handle or CtrlID of progressbar
    ; $iState - new status of progress:
    ; |$PBM_NORMAL - normal state (green)
    ; |$PBM_ERROR - error state (red)
    ; |$PBM_PAUSED - paused style (yellow)
    ; Return values .: Success -
    ; Failure - 0
    ; Author ........: Prog@ndy
    ; Modified.......:
    ; Remarks .......: requires WinVista or above
    ; Related .......:
    ; Link ..........; @@MsdnLink@@ PBM_SETSTATE
    ; Example .......;
    ; ===============================================================================================================================
    Func _GUICtrlProgress_SetState($iProgress, $iState)
    ; Author: Prog@ndy
    Switch IsHWnd($iProgress)
    Case True
    Return _SendMessage($iProgress, $PBM_SETSTATE2, $iState, 0)
    Case Else
    Return GUICtrlSendMsg($iProgress, $PBM_SETSTATE2, $iState, 0)
    EndSwitch
    EndFunc ;==>_GUICtrlProgress_SetState

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlProgress_GetState
    ; Description ...: Gets the state of the progressbar
    ; Syntax.........: _GUICtrlProgress_GetState($iProgress)
    ; Parameters ....: $iProgress - handle or CtrlID of progressbar
    ; Return values .: Success - status of progress:
    ; |$PBM_NORMAL - normal state (green)
    ; |$PBM_ERROR - error state (red)
    ; |$PBM_PAUSED - paused style (yellow)
    ; Failure - 0
    ; Author ........: Prog@ndy
    ; Modified.......:
    ; Remarks .......: requires WinVista or above
    ; Related .......:
    ; Link ..........; @@MsdnLink@@ PBM_GETSTATE
    ; Example .......;
    ; ===============================================================================================================================
    Func _GUICtrlProgress_GetState($iProgress)
    ; Author: Prog@ndy
    Switch IsHWnd($iProgress)
    Case True
    Return _SendMessage($iProgress, $PBM_GETSTATE2, 0, 0)
    Case Else
    Return GUICtrlSendMsg($iProgress, $PBM_GETSTATE2, 0, 0)
    EndSwitch
    EndFunc ;==>_GUICtrlProgress_GetState

    [/autoit]
  • Und wieder nen Problem...

    Mein Script

    [autoit]

    #include<_pro.au3>

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

    GUICreate("test")
    $progressbar = GUICtrlCreateProgress(10, 10, 80, 15)
    GUICtrlSetData($progressbar, 60)

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

    GUISetState()

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

    _GUICtrlProgress_setState($progressbar, 0x0002)
    Sleep(2000)
    GUICtrlSetData($progressbar, 40)
    Sleep(2000)
    GUICtrlSetData($progressbar, 80)

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

    While 1
    WEnd

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

    der _pro.au3 ist im anhang...

    und nun meine Frage: wieso erkennt er nur bei jedem 2tem Mal das setzen des wertes von GuiCtrlSetData...

    Das merke ich daran das, wenn ich die anzahl jeweils verdopple, er es erst setzt...

    Doch----> Warum..?

    • Offizieller Beitrag

    Das liegt scheinbar am setzen des States. Der fehler trifft nur auf wenn $PMB_ERROR oder $PBM_PAUSE verwendet
    wird. Eine Lösung dazu fällt mir nicht ein, liegt am Control selbst.

    Edit:
    Einzige Lösung scheint es zu sein, die Werte 2 mal zu setzen. Keine schöne Lösung aber es ist eine. ;)