Jump to content

Recommended Posts

Posted

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.

Posted (edited)

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

Posted

Yeah I guess that's the only way to really make it work. I'll have to edit it a bit to make it look more pretty but the basics are good. And at least now I can easily make it change colour too :P

 

Thanks man! :)

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