Jump to content

Recommended Posts

Posted

Hi I want to change background and foreground color of Progress bar that I created with GUICtrlCreateProgress

I found this piece of code in this forum, this code only change progressBar foreground color to blue

$Progress1 = GUICtrlCreateProgress(25, 150, 350, 26)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Progress1), "wstr", 0, "wstr", 0)
GUICtrlSetStyle($Progress1, BitOr($GUI_SS_DEFAULT_PROGRESS, $PBS_SMOOTH))

its possible to for example change background color to black and foreground to red

thanks

  • Moderators
Posted

Invicore,

You can change the colour of the bar itself like this:

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

$hGUI = GUICreate("Test", 300, 380)

GUIStartGroup()
$cRadio_1 = GUICtrlCreateRadio("Green", 60, 95, 60, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$cRadio_2 = GUICtrlCreateRadio("Red", 120, 95, 60, 20)
$cRadio_3 = GUICtrlCreateRadio("Yellow", 180, 95, 60, 20)
$cProgress = GUICtrlCreateProgress(25, 130, 250, 15)
GUICtrlSetData(-1, 50)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cRadio_1
            _SendMessage(GUICtrlGetHandle($cProgress), $PBM_SETSTATE, 1)
        Case $cRadio_2
            _SendMessage(GUICtrlGetHandle($cProgress), $PBM_SETSTATE, 2)
        Case $cRadio_3
            _SendMessage(GUICtrlGetHandle($cProgress), $PBM_SETSTATE, 3)
    EndSwitch

WEnd

No idea about how to change the background.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)
  On 3/23/2021 at 8:33 PM, Melba23 said:

Invicore,

You can change the colour of the bar itself like this:

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

$hGUI = GUICreate("Test", 300, 380)

GUIStartGroup()
$cRadio_1 = GUICtrlCreateRadio("Green", 60, 95, 60, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$cRadio_2 = GUICtrlCreateRadio("Red", 120, 95, 60, 20)
$cRadio_3 = GUICtrlCreateRadio("Yellow", 180, 95, 60, 20)
$cProgress = GUICtrlCreateProgress(25, 130, 250, 15)
GUICtrlSetData(-1, 50)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cRadio_1
            _SendMessage(GUICtrlGetHandle($cProgress), $PBM_SETSTATE, 1)
        Case $cRadio_2
            _SendMessage(GUICtrlGetHandle($cProgress), $PBM_SETSTATE, 2)
        Case $cRadio_3
            _SendMessage(GUICtrlGetHandle($cProgress), $PBM_SETSTATE, 3)
    EndSwitch

WEnd

No idea about how to change the background.

M23

Expand  

thank you, I search a little more and found this code In this post

DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)
GUICtrlSetStyle($Progress1, BitOr($GUI_SS_DEFAULT_PROGRESS, $PBS_SMOOTH))

GUICtrlSetColor(-1, 0xff0000) ; Red
GUICtrlSetBkColor(-1, 0x000000) ; Black

with it, its possible to change  color of both background and bar itself

Edited by Invicore
  • Moderators
Posted

Invicore,

Great.

But when you reply in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...