Jump to content
Sign in to follow this  
lewisg

Larger Progress display

Recommended Posts

lewisg

Trying to display a long PATH and filename with a progress bar, however the PATH and filename get cut off because the progress bar display is to small. Only found sizing with GUICtrlCreateProgress which is not being used (trying to not do a rewrite of the code).

Share this post


Link to post
Share on other sites
BrettF

It would be better to create a gui with Koda, and set it with GUICtrlSetData. Would be much more suited to your needs. :)

Maybe Something like this?

#include <GUIConstants.au3>
$Progressctrl = _ProgressOn("title", "maintext", "subtext", 400, 100, -1, -1)
$i = 1
While 1
    $msg = GUIGetMsg ()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    _ProgressSet ($Progressctrl[0], $i)
    Sleep (100)
    $i += 1
WEnd

_ProgressOff ($Progressctrl[1])

Func _ProgressOn($title, $maintext, $subtext, $w = 200, $h = 100, $x = -1, $y = -1)
    Select
        Case $w = -1 or $w < 200
            $w = 200
            ContinueCase
        Case $h = -1 or $h < 100
            $h = 100
            ContinueCase
        Case $x = -1
            $x = (@DesktopWidth / 2) - ($w / 2)
            ContinueCase
        Case $y = -1
            $y = (@DesktopHeight / 2) - ($h / 2)
            ContinueCase
    EndSelect

$ctrlw = Int ($w - 10)
$mtexth = Int ($h/3)
$ppos = Int ($mtexth + 10)
$spos = Int ($ppos + 25)

$ProgressGUI = GUICreate ($title, $w, $h, $x, $y)

$lblMainText = GUICtrlCreateLabel ($maintext, 5, 5, $ctrlw, $mtexth)
$proProgress = GUICtrlCreateProgress (5, $ppos, $ctrlw, 20)
$lblSubText = GUICtrlCreateLabel ($subtext, 5, $spos, $ctrlw, $mtexth)
GUISetState (@SW_SHOW)

Dim $ret[2]
$ret[0] = $proProgress
$ret[1] = $ProgressGUI
Return $ret
EndFunc

Func _ProgressSet ($proProgress, $percent)
    GUICtrlSetData ($proProgress, $percent)
EndFunc

Func _ProgressOff ($hwnd)
    GUIDelete ($hwnd)
EndFunc

Also, welcome to the forums ;)

Edited by Bert

Share this post


Link to post
Share on other sites
lewisg

Thanks for the advice, I was really trying to not rewrite the code anymore then I had to. However by "borrowing" some of your example I was able to accomplish just what I wanted! Once I figured out your example I was very impress with the elegance of it, well done and thank you again.

It would be better to create a gui with Koda, and set it with GUICtrlSetData. Would be much more suited to your needs. :)

Also, welcome to the forums ;)

Share this post


Link to post
Share on other sites
BrettF

Thanks for the advice, I was really trying to not rewrite the code anymore then I had to. However by "borrowing" some of your example I was able to accomplish just what I wanted! Once I figured out your example I was very impress with the elegance of it, well done and thank you again.

Glad to be of assistance :)

Share this post


Link to post
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
Sign in to follow this  

×