Jump to content

Change color of GUICtrlCreateProgress


Recommended Posts

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

Link to post
Share on other sites
  • Moderators

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
Posted (edited)
16 minutes ago, 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

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
Link to post
Share on other sites
  • Moderators

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

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...