VAN0 Posted May 29, 2010 Posted May 29, 2010 (edited) Hello. I've been trying display some text with transparent background inside a progress bar. it kind of worked, but the text/progress bar flickers.. also, if I use GUICtrlCreateEdit then it shows colored background. #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> GUICreate("Text over progress bar", 200, 40) $progress = GUICtrlCreateProgress(5, 5, 190, 30, $PBS_SMOOTH) $text = GUICtrlCreateEdit("", 90, 9, 50, 20, 0x0800) ;text shows on white background ;$text = GUICtrlCreateLabel("", 90, 9, 50, 20) ;text shows with transparent background GUICtrlSetBkColor(-1, -2) GUISetState() $p = 0 $d = 1 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $p > 500 Then $d = -1 If $p < 1 Then $d = 1 $p += $d GUICtrlSetData($progress, Round($p/5, 1)) GUICtrlSetData($text, Round($p/5, 1)) Sleep(50) WEnd Any ideas how this can it be fixed? Thank you. Edited May 29, 2010 by VAN0
jaberwacky Posted May 29, 2010 Posted May 29, 2010 The numbers would move too fast for them to be selectable anyway. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
VAN0 Posted May 29, 2010 Author Posted May 29, 2010 True, but I was going to use same gui element to display something else when progress bar is not in use. But anyhow if text not selectable - it wouldn't be a problem, I can always hide the label element and replace it with edit when needed and vice versa. The main concern is the flickering...I would really like use windows native progress bar instead of a simulator, but if it's the only way, then oh well.
jaberwacky Posted May 30, 2010 Posted May 30, 2010 Have you seen ProgressOn()? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
VAN0 Posted May 30, 2010 Author Posted May 30, 2010 Yes I have, but it's not what I was looking for. Anyway, I've abandon this idea and now displaying very thin 4 pixels high progress bar below the text, doesn't look too bad.
taietel Posted May 30, 2010 Posted May 30, 2010 (edited) Maybe this will help (You have to make the label size equal to the progress and then set the transparency): #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #Include <StaticConstants.au3> GUICreate("Text over progress bar", 200, 40) $progress = GUICtrlCreateProgress(5, 5, 190, 30, $PBS_SMOOTH) $text = GUICtrlCreateLabel("0%", 5, 10, 190, 30, $SS_CENTER) GUICtrlSetBkColor ($text, $GUI_BKCOLOR_TRANSPARENT) ;GUICtrlSetFont($text, 9, 800) GUISetState() $p = 0 ;$d = 1 Do $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch For $i = $p To 100 $p = 0 GUICtrlSetData($progress, $i) GUICtrlSetData($text, $i & '%') Sleep(100) Next If $i > 100 Then $p=0 GUICtrlSetData($text, "Done!") Sleep(1500) Exit EndIf Until $nMsg = $GUI_EVENT_CLOSE GUIDelete() Exit Edited May 30, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Reveal hidden contents Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
andygo Posted August 21, 2011 Posted August 21, 2011 reply after a long time..... but: is it possible to prevent the text from flickering? cant't figure it out....
Slym Posted August 22, 2011 Posted August 22, 2011 On 8/21/2011 at 11:37 AM, 'andygo said: reply after a long time..... but:is it possible to prevent the text from flickering? cant't figure it out....Try changing the label only if it is different from the actual value. (avec un test if GuiCTrlReadValue ....) --------------------- [font="Franklin Gothic Medium"]LinuxLive USB Creator[/font], [size="3"]The only Linux Live USB creator with easy integrated virtualization (made with AutoIT)[/size] ---------------------
Zedna Posted August 22, 2011 Posted August 22, 2011 #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> GUICreate("Text over progress bar", 200, 40) $progress = GUICtrlCreateProgress(5, 5, 190, 30, $PBS_SMOOTH) $text = GUICtrlCreateLabel("", 5, 12, 190, 30, $SS_CENTER) ;text shows on white background GUICtrlSetColor(-1, 0x008000) ; choose some color which will be visible on progress background and also foreground GUICtrlSetBkColor(-1, -2) GUISetState() $p = 0 $d = 1 $value = 0 $value_prev = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $p > 500 Then $d = -1 If $p < 1 Then $d = 1 $p += $d $value = StringFormat('%.1f', Round($p/5, 1)) If $value <> $value_prev Then GUICtrlSetData($progress, $value) GUICtrlSetData($text, $value) $value_prev = $value EndIf Sleep(50) WEnd Here is antiflicker modification. Ideal for label color would be some type of XOR painting so it should paint by different color depended on its backround but I don't know how to achieve this by some simple trick. Resources UDF ResourcesEx UDF AutoIt Forum Search
andygo Posted August 23, 2011 Posted August 23, 2011 @Zenda: thank you, i modified it a little bit, so that setting the controls is in a timer-function. have a look at it. for one second everything is fine, for the next second, the text-label is invisible, then its visible again for a second and so on..... expandcollapse popup#include <StaticConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <Timers.au3> #Include <Misc.au3> #include <Constants.au3> #include <INet.au3> #Include <GuiButton.au3> #Include <Clipboard.au3> #Include <ScreenCapture.au3> #include <GDIPlus.au3> #include <GDIP.au3> #include <file.au3> #include <unixtime.au3> #Include <Array.au3> #include "StringSize.au3" #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> $maingui = GUICreate("Text over progress bar", 200, 40) $progress = GUICtrlCreateProgress(5, 5, 190, 30, $PBS_SMOOTH) $text = GUICtrlCreateLabel("", 5, 12, 190, 30, $SS_CENTER) ;text shows on white background GUICtrlSetColor(-1, 0x008000) ; choose some color which will be visible on progress background and also foreground GUICtrlSetBkColor(-1, -2) GUISetState() $p = 0 $d = 1 $value = 0 $value_prev = 0 _Timer_SetTimer($maingui,1000,"addup") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch #cs;If $p > 500 Then $d = -1 If $p < 1 Then $d = 1 $p += $d $value = StringFormat('%.1f', Round($p/5, 1)) If $value <> $value_prev Then GUICtrlSetData($progress, $value) GUICtrlSetData($text, $value) $value_prev = $value #ce;EndIf Sleep(50) WEnd _Timer_KillAllTimers($maingui) func addup($a, $b, $c, $d) $value += 1 If $value <> $value_prev Then GUICtrlSetData($progress, $value) GUICtrlSetData($text, $value) $value_prev = $value EndIf endfunc
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