jfcby Posted August 23, 2009 Share Posted August 23, 2009 Hi, Is it possibe to change the colors of a progrgressbar? The help said it is possible but in the following code GUICtrlSetColor and GUICtrlSetBkColor does not work. I searched this forum but did not find any examples using them either. Script Code: expandcollapse popup#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m GUICreate("My GUI Progressbar", 220, 100, 100, 200) $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20, -1, $WS_EX_WINDOWEDGE) GUICtrlSetColor(-1, 0x000000) ; Black GUICtrlSetBkColor(-1, 0xC2C2C2) ; Gray $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH) GUICtrlSetColor(-1, 0x000000) ; Black GUICtrlSetBkColor(-1, 0xC2C2C2) ; Gray $button = GUICtrlCreateButton("Start", 75, 70, 70, 20) GUISetState() $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() If $m = -3 Then ExitLoop 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 Thank you for your help, jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** Link to comment Share on other sites More sharing options...
Scriptonize Posted August 23, 2009 Share Posted August 23, 2009 Try this... expandcollapse popup#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m GUICreate("My GUI Progressbar", 220, 100, 100, 200) $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20, -1, $WS_EX_WINDOWEDGE) GUICtrlSetColor(-1, 0x000000) ; Black GUICtrlSetBkColor(-1, 0xC2C2C2) ; Gray $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH) GUICtrlSetColor(-1, 0x000000) ; Black GUICtrlSetBkColor(-1, 0xC2C2C2) ; Gray $button = GUICtrlCreateButton("Start", 75, 70, 70, 20) GUISetState() $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) GUICtrlSetColor($progressbar2, 0xFF0000) EndIf $m = GUIGetMsg() If $m = -3 Then ExitLoop 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 If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
sandin Posted August 23, 2009 Share Posted August 23, 2009 (edited) it is possible, but only in it's plain style, any other theme/style will disable it's ability to change colors, in order to set the progress as plain style, try this: DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($progressbar1), "wstr", 0, "wstr", 0) GUICtrlSetStyle($progressbar1, BitOr($GUI_SS_DEFAULT_PROGRESS, $PBS_SMOOTH));doesn't have to be smooth, but I personally like this better and here's the full code: expandcollapse popup#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m GUICreate("My GUI Progressbar", 220, 100, 100, 200) $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20, -1, $WS_EX_WINDOWEDGE) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0) GUICtrlSetStyle($progressbar1, BitOr($GUI_SS_DEFAULT_PROGRESS, $PBS_SMOOTH)) GUICtrlSetColor(-1, 0x000000) ; Black GUICtrlSetBkColor(-1, 0xC2C2C2) ; Gray $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0) GUICtrlSetStyle($progressbar2, BitOr($GUI_SS_DEFAULT_PROGRESS, $PBS_SMOOTH)) GUICtrlSetColor(-1, 0x000000) ; Black GUICtrlSetBkColor(-1, 0xC2C2C2) ; Gray $button = GUICtrlCreateButton("Start", 75, 70, 70, 20) GUISetState() $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() If $m = -3 Then ExitLoop 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 Edited August 23, 2009 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Yashied Posted August 23, 2009 Share Posted August 23, 2009 @jfcbyYou have badly searched (or did not searched absolutely).http://www.autoitscript.com/forum/index.php?showtopic=74649@ScriptonizeAre you trying to run your script? This does not work. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 23, 2009 Share Posted August 23, 2009 The help said it is possible but in the following code GUICtrlSetColor and GUICtrlSetBkColor does not work. I searched this forum but did not find any examples using them either.The helpfile also said:Checkbox, Radio or Progress controls cannot be painted if the "Windows XP style" is used.The "Remarks"-section should be read, not skipped over >_< .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Scriptonize Posted August 23, 2009 Share Posted August 23, 2009 (edited) @Scriptonize Are you trying to run your script? This does not work. I did, it worked fine. I will recheck, maybe something went wrong copying the code... [[EDIT]] It does work like a charm. Running XP-SP3 (Classic style) and AutoIt v3.3.0.0 Edited August 23, 2009 by Scriptonize If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
Yashied Posted August 23, 2009 Share Posted August 23, 2009 I did, it worked fine. I will recheck, maybe something went wrong copying the code... [[EDIT]] It does work like a charm. Running XP-SP3 (Classic style) and AutoIt v3.3.0.0 I see, sandin post. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
jfcby Posted August 23, 2009 Author Share Posted August 23, 2009 It does work like a charm.Running XP-SP3 (Classic style) and AutoIt v3.3.0.0How do you change Win XP to (Classic Style)?Thank you for your help,jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** Link to comment Share on other sites More sharing options...
Scriptonize Posted August 23, 2009 Share Posted August 23, 2009 Hover mouse over desktop, right click, choose properties, Select appearance tab, and here at "Windows and buttons" select Windows classic style. Voila. If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
sandin Posted August 23, 2009 Share Posted August 23, 2009 ...right... but why would u want to change entire windows style when you can change only 1 single control into classic style Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Yashied Posted August 23, 2009 Share Posted August 23, 2009 Another way.#Include <WinAPIEx.au3> Global $hForm, $Theme = _WinAPI_GetThemeAppProperties() $hForm = GUICreate('MyGUI', 310, 189) GUISetFont(8.5, 400, 0, 'MS Shell Dlg', $hForm) GUICtrlCreateGroup('Group', 10, 10, 140, 95) _WinAPI_SetThemeAppProperties($STAP_ALLOW_NONCLIENT) GUICtrlCreateCheckbox('Check1', 22, 26, 120, 23) GUICtrlCreateCheckbox('Check2', 22, 49, 120, 23) GUICtrlCreateCheckbox('Check3', 22, 72, 120, 23) _WinAPI_SetThemeAppProperties($Theme) GUICtrlCreateGroup('Group', 160, 10, 140, 95) GUICtrlCreateRadio('Radio1', 172, 26, 120, 23) GUICtrlCreateRadio('Radio2', 172, 49, 120, 23) GUICtrlCreateRadio('Radio3', 172, 72, 120, 23) _WinAPI_SetThemeAppProperties($STAP_ALLOW_NONCLIENT) GUICtrlCreateProgress(10, 121, 290, 20) GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetData(-1, 20) _WinAPI_SetThemeAppProperties($Theme) GUICtrlCreateButton('OK', 120, 154, 70, 23) GUISetState() Do Until GUIGetMsg() = -3WinAPIEx.au3 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now