Jump to content

Recommended Posts

Posted (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 by VAN0
Posted

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.

Posted

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.

Posted (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 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
  • 1 year later...
Posted

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

Posted

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

Posted

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

#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

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