Jump to content

Label On ProgressBar


Patr89
 Share

Recommended Posts

Hi all :)

I've been having an issue which my Google searches so far couldn't help me fix, so decided to make an account here. Pls be gentle! :P

So what I'm trying to do it put a label on top of a progress bar, but it keeps disappearing if I update the progress bar or when it has any value (like in windows 10 it does this fancy shine effect which also seems to "update" it and hide my label). Now the best answer that I found so far would be to create a transparent child gui and put that over the progress bar with the label inside of it.

However, I'm making use of the "GUIScrollbars_Ex.au3" by Melba23. So I haven't been able to get this child gui thing to work properly, while maintaining a functioning scroll bar.

Here's a simplified version of what I'm trying to do:

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

Example()

Func Example()

    $hGUI = GUICreate( "Progress Test", 220, 70 )

    Global $Progress = GUICtrlCreateProgress( 10, 10, 200, 20, $PBS_SMOOTHREVERSE )
    Global $Label = GUICtrlCreateLabel( "Text", 60, 13, 100, 20, $SS_CENTER, $WS_EX_TOPMOST )
    GUICtrlSetBkColor( -1, $GUI_BKCOLOR_TRANSPARENT )
    Global $Button = GUICtrlCreateButton( "Click Me!", 10, 40, 200, 20 )

    GUISetState()

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Button
                _SomeRandomFuncTriggeredByAnEvent()

            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd
EndFunc

Func _SomeRandomFuncTriggeredByAnEvent()

    GUICtrlSetData( $Progress, 20 )

EndFunc

 

What it looks like in my actual script when running it, is this:

Naamloos.png

 

Any option (with or without child gui) would be very welcome!

Thanks in advance for the help. :)

 

P.S. it is not a requirement that the progress bar looks fancy, but I'd rather not be forced to create a custom progress bar because - as you can see - I make quite a lot of use of it.

Link to comment
Share on other sites

Here is a stab at making it happen...

 

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

#include <ColorConstants.au3>

Global $x = 0

Example()

Func Example()

    $hGUI = GUICreate("Progress Test", 220, 70)

    Global $Progress = GUICtrlCreateLabel("", 10, 10, $x, 20)
    GUICtrlSetBkColor(-1, $COLOR_GREEN)
    Global $Label = GUICtrlCreateLabel("Text", 60, 13, 100, 20, $SS_CENTER, $WS_EX_TOPMOST)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    Global $Button = GUICtrlCreateButton("Click Me!", 10, 40, 200, 20)

    GUISetState()

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Button
                _SomeRandomFuncTriggeredByAnEvent()

            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch

    WEnd

EndFunc   ;==>Example

Func _SomeRandomFuncTriggeredByAnEvent()

    $x += 20
    If $x >= 220 Then Return
    $t = $x / 2
    GUICtrlSetPos($Progress, 10, 10, $x, 20)
    GUICtrlSetData($Label, $t & " Percent")


EndFunc   ;==>_SomeRandomFuncTriggeredByAnEvent

 

 

You created a great example to review your problem... I always find a way!!!

Good Luck... 8)

Edited by Valuater

NEWHeader1.png

Link to comment
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
 Share

  • Recently Browsing   0 members

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