Jump to content

Need help with...


Alek
 Share

Recommended Posts

im makeing a colord progressbar but i want the % done in a label on the bar but the label hides a the part of the bar the label is over.

#include <GuiConstants.au3>
$x = 0
$gui = GuiCreate("MyGUI", 350, 42,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Pic_1 = GUICtrlCreateLabel("", 10, 10, 340, 20)
GUICtrlSetBkColor($Pic_1,0xff0000) ;Red
$Label_2 = GuiCtrlCreateLabel("", 10, 10, 340, 20)


GuiSetState()
do

    $msg = GuiGetMsg()
    if $msg = $GUI_EVENT_CLOSE then ExitLoop
    $pos = ControlGetPos($gui,"",$Label_2)
    if $pos[0] < 340 then GUICtrlSetPos($Label_2,$pos[0]+((360/100)*1),10)
    Sleep(20)
    if $x = 0 then
        if $pos[0] > 339.9 then 
            MsgBox(0,"test","Done!")
            $x = 1
        EndIf
    EndIf
    $msg = GuiGetMsg()
    if $msg = $GUI_EVENT_CLOSE then Exit
until $msg = $GUI_EVENT_CLOSE

just an example on how i was thinking of doing it

Edit: im useing Win xp so i cant use GUICtrlSetColor($progressbar,0xff0000)

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

Maybe...

#include <GuiConstants.au3>
Dim $XS_n, $x = 0
$gui = GuiCreate("MyGUI", 350, 42,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
 XPStyle(1)  
$Pic_1 = GUICtrlCreateLabel("", 10, 10, 340, 20)
GUICtrlSetBkColor($Pic_1,0xff0000) ;Red
$Label_2 = GuiCtrlCreateLabel("", 10, 10, 340, 20)
$Label_3 = GUICtrlCreateLabel("", 10, 13, 5, 15, $SS_CENTER)
GUICtrlSetBkColor( -1, $GUI_BKCOLOR_TRANSPARENT )
 XPStyle(0)  

GuiSetState()
do

    $msg = GuiGetMsg()
    if $msg = $GUI_EVENT_CLOSE then ExitLoop
    $pos = ControlGetPos($gui,"",$Label_2)
    if $pos[0] < 340 then
        GUICtrlSetPos($Label_2,$pos[0]+((360/100)*1),10)
        GUICtrlSetPos($Label_3, 10, 13, $pos[0]+((360/100)*1),15)
        GUICtrlSetData( $Label_3, int($pos[0]+((360/100)*1)) & "%")
    EndIf
    Sleep(20)
    if $x = 0 then
        if $pos[0] > 339.9 then
            MsgBox(0,"test","Done!")
            $x = 1
        EndIf
    EndIf
    $msg = GuiGetMsg()
    if $msg = $GUI_EVENT_CLOSE then Exit
until $msg = $GUI_EVENT_CLOSE
 
 Func XPStyle($OnOff = 1)   
    If $OnOff And StringInStr(@OSTYPE, "WIN32_NT") Then
        $XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return 1
    ElseIf StringInStr(@OSTYPE, "WIN32_NT") And IsArray($XS_n) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
        $XS_n = ""
        Return 1
    EndIf
    Return 0
EndFunc   ;==>XPStyle

8)

NEWHeader1.png

Link to comment
Share on other sites

this workd great for me

#include <GuiConstants.au3>

$gui = GuiCreate("MyGUI", 350, 42,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Pic_1 = GUICtrlCreateLabel("", 10, 10, 340, 20)
GUICtrlSetBkColor($Pic_1,0xff0000)
$Label_2 = GuiCtrlCreateLabel("", 10, 10, 340, 20)
$Label_3 = GUICtrlCreateLabel("", 10, 13, 5, 15, $SS_CENTER)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GuiSetState()

do
    $msg = GuiGetMsg()
    $pos = ControlGetPos($gui,"",$Label_2)
    if $pos[0] < 340 then
        GUICtrlSetPos($Label_2,$pos[0]+((340/100)*1),10)
        GUICtrlSetPos($Label_3, 10, 13, 360,15)
        GUICtrlSetData( $Label_3, int($pos[0]/(340/100)+1) & "%")
    EndIf
    Sleep(20)
    if $pos[0] = 340 then
        MsgBox(0,"test","Done!")
        exit
    EndIf
    $msg = GuiGetMsg()
until $msg = $GUI_EVENT_CLOSE
oÝ÷ Ú(Z½æª¹ë-ð+ay«­¢+Ø(Õ¹aAMÑå± ÀÌØí=¹=ôĤ(%ÀÌØí=¹=¹MÑÉ¥¹%¹MÑÈ¡=MQeA°ÅÕ½Ðí]%8ÌÉ}9PÅÕ½Ðì¤Q¡¸(ÀÌØíaM}¸ô±±
±° ÅÕ½ÐíÕáÑ¡µ¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑQ¡µÁÁAɽÁÉÑ¥ÌÅÕ½Ðì¤(±±
±° ÅÕ½ÐíÕáÑ¡µ¹±°ÅÕ½Ðì°ÅÕ½Ðí¹½¹ÅÕ½Ðì°ÅÕ½ÐíMÑQ¡µÁÁAɽÁÉÑ¥ÌÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À¤(IÑÕɸÄ(±Í%MÑÉ¥¹%¹MÑÈ¡=MQeA°ÅÕ½Ðí]%8ÌÉ}9PÅÕ½Ð줹%ÍÉÉä ÀÌØíaM}¸¤Q¡¸(±±
±° ÅÕ½ÐíÕáÑ¡µ¹±°ÅÕ½Ðì°ÅÕ½Ðí¹½¹ÅÕ½Ðì°ÅÕ½ÐíMÑQ¡µÁÁAɽÁÉÑ¥ÌÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíaM}¹lÁt¤(ÀÌØíaM}¸ôÅÕ½ÐìÅÕ½Ðì(IÑÕɸÄ(¹%(IÑÕɸÀ)¹Õ¹ìôôÐíaAMÑå±

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

from help this does not work... unless you "control" xp theme

#include <GUIConstants.au3>
Dim $XS_n
GUICreate("My GUI Progressbar",220,100, 100,200)
XPStyle(1)   
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
GUICtrlSetColor(-1,32250); not working with Windows XP Style
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$button = GUICtrlCreateButton ("Start",75,70,70,20)
XPStyle(0)   
GUISetState ()

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
do
$msg = GUIGetMsg()
If $msg = $button Then
    GUICtrlSetData ($button,"Stop")
    For $i = $s To 100
    If GUICtrlRead($progressbar1) = 50 Then Msgbox(0,"Info","The half is done...", 1)
    $m = GUIGetMsg ()
    
    If $m = -3 Then ExitLoop
    
    If $m = $button Then
      GUICtrlSetData ($button,"Next")
      $s = $i;save the current bar-position to $s
      ExitLoop
    Else
        $s=0
      GUICtrlSetData ($progressbar1,$i)
      GUICtrlSetData ($progressbar2,(100 - $i))
      Sleep($wait)
    EndIf
    Next
    if $i >100 then
;        $s=0
        GUICtrlSetData ($button,"Start")
    endif
EndIf
until $msg = $GUI_EVENT_CLOSE


Func XPStyle($OnOff = 1)   
    If $OnOff And StringInStr(@OSTYPE, "WIN32_NT") Then
        $XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return 1
    ElseIf StringInStr(@OSTYPE, "WIN32_NT") And IsArray($XS_n) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
        $XS_n = ""
        Return 1
    EndIf
    Return 0
EndFunc   ;==>XPStyle

no pic is needed here, however the XPStyle function is not needed with your pic...

Of-Course, if you just use red here, you won't need a pic

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