_SendMessage und Progressbar

  • Ich möchte gerne die Farbe des Balkens einer Progressbar ändern (Win 7).
    Dafür sende ich die Nachricht $PBM_SETBARCOLOR. Leider funktioniert das nicht.
    Was mache ich falsch?

    Spoiler anzeigen
    [autoit]

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

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

    $GUI = GUICreate("GUI", 300, 100)
    $Progress = GUICtrlCreateProgress(50, 35, 200, 30)
    GUISetState(@SW_SHOW)
    GUICtrlSetData($Progress, 50)

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

    Sleep(1000)

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

    _SendMessage($Progress, $PBM_SETBARCOLOR, 0, 0x0000FF)

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

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

    [/autoit]


    MfG,
    xp_fan

  • geht das nicht mit?

    [autoit]

    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetColor(-1, 0xFF0000)

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit]
  • geht das nicht mit?

    [autoit]

    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetColor(-1, 0xFF0000)

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

    Leider nicht.

    Dann liegt das am verwendeten Windows XP Style. So funktioniert es trotzdem:

    Spoiler anzeigen
    [autoit]

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

    [/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)

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

    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0) ; Classic-Style
    $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 7) ; Standard-Windows-Style

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

    $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
    $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", "The half is done...", 1)
    $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
    GUICtrlSetData($button, "Start")
    EndIf
    EndIf
    Until $msg = $GUI_EVENT_CLOSE
    EndFunc ;==>Example

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

    die erste Progress ist geändert,

    mfg (Auto)Bert

  • autoBert:
    Vielen Dank, dieses Beispiel kenne ich auch. Mir geht es darum, den Win7-Style beizubehalten und die Farbe zu ändern. Mit dieser Funktion von Prog@ndy kann man zwar die Farbe und den Status ändern, jedoch nur, wenn die Progressbar angehalten ist:

    Spoiler anzeigen
    [autoit]


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

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

    Global Const $PBST_NORMAL = 0x0001
    Global Const $PBST_ERROR = 0x0002
    Global Const $PBST_PAUSED = 0x0003

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

    $GUI = GUICreate("GUI", 300, 100)
    $Progress = GUICtrlCreateProgress(50, 35, 200, 30)
    GUISetState(@SW_SHOW)
    GUICtrlSetData($Progress, 50)

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

    Sleep(1000)

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

    _GUICtrlProgress_SetState($Progress, $PBST_PAUSED)

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

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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/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_SETSTATE, $iState, 0)
    Case Else
    Return GUICtrlSendMsg($iProgress, $PBM_SETSTATE, $iState, 0)
    EndSwitch
    EndFunc ;==>_GUICtrlProgress_SetState

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

    @Pinguin94:
    Klappt leider nicht:

    Spoiler anzeigen
    [autoit]

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

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

    $GUI = GUICreate("GUI", 300, 100)
    $Progress = GUICtrlCreateProgress(50, 35, 200, 30)
    GUISetState(@SW_SHOW)
    GUICtrlSetData($Progress, 50)

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

    Sleep(1000)

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

    $hProgress = GUICtrlGetHandle($Progress)
    _Progress_SetBarColor($hProgress, 0x0000FF)

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

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

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

    Func _Progress_SetBarColor($hWnd, $iColor)
    Return _SendMessage($hWnd, $PBM_SETBARCOLOR, 0, $iColor)
    EndFunc ;==>_Progress_SetBarColor

    [/autoit]