Jump to content

Recommended Posts

Posted

Local $ui = GUICreate('test', 100, 160, -1, -1)
Local $pb = GUICtrlCreateProgress(50, 20, 10, 120, 0x04)
GUISetState(@SW_SHOW, $ui)

While 1
    For $i = 1 To 100
        GUICtrlSetData($pb, $i)
        Sleep(50)
    Next
    ExitLoop
WEnd

GUIDelete($ui)
Exit

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

Thats a great idea - but I need to graphically flip it.

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted (edited)

After a little looking around, all the solutions I seen, were to draw your own progress bar.

Maybe in a label or something with graphics.

EDIT:

@Yashied

I think the OP wants to physically rotate the control by 180 degrees, so the progress advances from right to left.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

I was afraid of that - nothing simple

Thanks guys

btw -- theres nothing physical about an image on your screen!

Thats okay .. I had to think about it before I said graphically too. <grin>

Lets see, where was I ... flip, mirror, rotate ...

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

Drawing Vertical Progress (somewhat simply) - in case 90 degrees is what you meant by flip it.

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


    $Top = 0
    $Bottom = @DesktopHeight
    $MAX = 50
    $Blocks = 50
    $each  = 50

For $i = 1 to $Blocks
$Rcolor = random (0x000000 , 0xFFFFFF)
    For $y = $Top To $Top + 40
For $x = 0 To $each



    _PixelSetColor ($x , $y , $Rcolor)

Next
Next

$Top = $Top + 50

sleep (500)   ; where an action would go

If $Top > @DesktopHeight Then
$i = 1
$Top = 0
Endif
Next


Func _PixelSetColor($XCoord, $YCoord, $Color)
    Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    If Not IsArray($dc) Then Return -1
    DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $XCoord, "long", $YCoord, "long", _
            "0x" & StringRegExpReplace(hex($Color,6), "(..)(..)(..)", "\3\2\1")) ; Change to 0xBBGGRR hex colour format.
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])
EndFunc ;==>_PixelSetColor

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Posted

Try this.

Local $ui = GUICreate('test', 100, 160, -1, -1)

Local $pb = GUICtrlCreateProgress(30, 20, 10, 120, BitOR(0x04, 0x01))
GUICtrlSetBkColor($pb, 0x000080)
GUICtrlSetColor($pb, 0xD4D0C8)

Local $pb1 = GUICtrlCreateProgress(70, 20, 10, 120, 0x04)

GUISetState(@SW_SHOW, $ui)

While 1
    For $i = 1 To 100
        GUICtrlSetData($pb, $i)
        GUICtrlSetData($pb1, 100 - $i)
        Sleep(50)
    Next
    For $i = 1 To 100
        GUICtrlSetData($pb, 100 - $i)
        GUICtrlSetData($pb1, $i)
        Sleep(50)
    Next
    ExitLoop
WEnd
  • Moderators
Posted

Malkey,

Very clever. :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Only for a themeable windows.

#Include <WinAPIEx.au3>
#Include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hForm, $Pic

$hForm = GUICreate('MyGUI', 200, 300)
$Pic = GUICtrlCreatePic('', 91, 20, 18, 260)
_SetHProgressBackwards($Pic, 0)
GUISetState()

While 1
    For $i = 0 To 100
        _SetHProgressBackwards($Pic, $i)
        Sleep(20)
    Next
    For $i = 100 To 0 Step -1
        _SetHProgressBackwards($Pic, $i)
        Sleep(20)
    Next
WEnd

Func _SetHProgressBackwards($CtrlID, $iPercent)

    Local $hWnd, $hDC, $hMemDC, $hSv, $hObj, $hBitmap, $hTheme, $tRect, $tClip, $Width, $Height

    $hWnd = GUICtrlGetHandle($CtrlID)
    If Not $hWnd Then
        Return 0
    EndIf
    $Width = _WinAPI_GetClientWidth($hWnd)
    $Height = _WinAPI_GetClientHeight($hWnd)
    $hDC = _WinAPI_GetDC($hWnd)
    $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    $hBitmap = _WinAPI_CreateSolidBitmap(0, _WinAPI_GetSysColor($COLOR_3DFACE), $Width, $Height, 0)
    $hSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $hTheme = _WinAPI_OpenThemeData($hWnd, 'Progress')
    $tRect = _WinAPI_CreateRectEx(0, 0, $Width, $Height)
    _WinAPI_DrawThemeBackground($hTheme, 2, 0, $hMemDC, $tRect)
    $tRect = _WinAPI_CreateRectEx(0, 0, $Width, $Height * $iPercent / 100)
    $tClip = _WinAPI_CreateRectEx(1, 1, $Width - 2, $Height - 2)
    _WinAPI_DrawThemeBackground($hTheme, 6, 1, $hMemDC, $tRect, $tClip)
    _WinAPI_CloseThemeData($hTheme)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    _WinAPI_SelectObject($hMemDC, $hSv)
    _WinAPI_DeleteDC($hMemDC)
    _WinAPI_DeleteObject(_SendMessage($hWnd, 0x0172, 0, $hBitmap))
    $hObj = _SendMessage($hWnd, 0x0173)
    If $hObj <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf
    Return 1
EndFunc   ;==>_SetHProgressBackwards

Edited by Yashied
Posted (edited)

Here my try:

Local $hGUI = GUICreate("Test", 100, 500)
Local $bg_p = GUICtrlCreateProgress(40, 0, 20, 500, 0x04)
GUICtrlSetData($bg_p, 100)
Local $fg_p = GUICtrlCreateProgress(40, 0, 20, 500, 0x04)
GUICtrlSetData($fg_p, 0)
GUISetState()

For $i = 0 To 501
    GUICtrlSetPos($fg_p, 40, $i)
    Sleep(20)
Next

Do
Until GUIGetMsg() = -3

I know it is flickering but maybe it can be fixed with styles...

@Yashied: very cool solution from your post #15! Posted Image

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Me 2

Local $ui = GUICreate('test', 100, 160, -1, -1, 0x80880000)
Local $pb = GUICtrlCreateLabel("  ", 43, 20, 15, 1, 0x1000)
GUICtrlSetBkColor(-1, 0x00ff00)
GUISetState(@SW_SHOW, $ui)
While 1
    For $i = 1 To 100
        GUICtrlSetData($pb, $i)
        GUICtrlSetPos($pb, 43, 20, 15, 1 + $i)
        Sleep(50)
    Next
    GUICtrlSetData($pb, "Ok!")
    Sleep(250)
    ExitLoop
WEnd
GUIDelete($ui)
Exit
Posted

Whoa .. you guys have been busy!

I appreciate all your efforts -- and I have checked every one of them. Very nice work indeed!

But they still lack the speed (1ms) of the native progress bar. And I have to call that twice!

It's in a very tight loop. If it were not for that, perhaps one of your solutions would work.

I imagine someone will get use of them. It's was a good exercise. Thanks again for your time.

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted (edited)

What do you mean by "lack the speed" - response time from call?

Heres a vertical bar using Taietel's _Gradient()

#include <WindowsConstants.au3>


$gui = GUICreate("", 40, @DesktopHeight, 0 , 0 , $WS_POPUPWINDOW)
GUISetBkColor (0x000000, $gui)
GUISetState(@SW_SHOW)

;   Example
_Gradient(0xFF0000, 0x00ff00,40,@DesktopHeight,0,0,1)

While 1

    Sleep(10)
    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch
WEnd


; #FUNCTION# ====================================================================================================
; Name...........:  _Gradient
; Description....:  Create gradient between two colors
; Syntax.........:  _Gradient($lColor1, $lColor2, $iW=100, $iH=20, $iX=0, $iY=0, $iDirection=0)
; Parameters.....:  $lColor1 - First color to begin with
;                   $lColor2 - Second color
;                   $iW - width of the area, [Optional]
;                   $iH - height of the area, [Optional]
;                   $iX - position from left, [Optional]
;                   $iY - position from top, [Optional]
;                   $iY - direction to fill the gradient, [Optional]
;                           0 - vertical fill
;                           1 - horizontal fill
;
; Return values..:  none
;
; Author.........:  taietel
; Reference.....:   http://www.tannerhelland.com/
; ===============================================================================================================
Func _Gradient($lColor1, $lColor2, $iW=100, $iH=20, $iX=0, $iY=0, $iDirection=0)
    Local $m, $Ri,$Rf,$Rs,$Gi,$Gf,$Gs,$Bi,$Bf,$Bs
    Switch $iDirection
        Case 0
            $m = $iW
        Case 1
            $m = $iH
    EndSwitch

    $Ri = Mod($lColor1,256)
    $Gi = BitAND($lColor1/256,255)
    $Bi = BitAND($lColor1/65536,255)

    $Rf = Mod($lColor2,256)
    $Gf = BitAND($lColor2/256,255)
    $Bf = BitAND($lColor2/65536,255)

    $Rs = Abs($Ri - $Rf)/$m
    $Gs = Abs($Gi - $Gf)/$m
    $Bs = Abs($Bi - $Bf)/$m

    If $Rf < $Ri Then $Rs = -$Rs
    If $Gf < $Gi Then $Gs = -$Gs
    If $Bf < $Bi Then $Bs = -$Bs

    For $i = 0 To $m
        $Rf = $Ri + $Rs * $i
        $Gf = $Gi + $Gs * $i
        $Bf = $Bi + $Bs * $i
        GUICtrlCreateLabel(" ", $iX+$i-$i*$iDirection, $iY + $i*$iDirection, 2+$iDirection*$iW, 2+(1-$iDirection)*$iH)
        GUICtrlSetBkColor(-1, "0x"&Hex($Bf,2) & Hex($Gf,2) & Hex($Rf,2))
;~      sleep(10) ; running items in this loop
    Next
EndFunc
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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