Jump to content
Sign in to follow this  
Madza91

Little bug on GUI drag in my script...

Recommended Posts

Madza91

Hi, i maded this bugged example script and i want to fix it but i don't know how, when draging GUI called func stops... i don't know why...

Is possible to fix this or to made on another way ? :S

#include <GuiConstants.au3>
#include <GUIListBox.au3>

Dim $progress = 0
Dim $1 = 0

$inifile = @DesktopDir & "\ex.ini"
$guiname = "Example"

$hGui = GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$List1 = GUICtrlCreateList("", 16, 16, 201, 240)
$StartBtn = GUICtrlCreateButton("Start", 20, 250, 50, 25)
$StopBtn = GUICtrlCreateButton("Stop", 320, 250, 50, 25)

$Progress_1 = GuiCtrlCreateProgress(40, 120, 320, 20)
$label = GUICtrlCreateLabel("? %",300,300,100,20)

GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        TimerDisable($hGui)
        ExitLoop
    Case $msg = $StartBtn
        TimerEnable("_IniGetSectionNames", $hGui, 100)
    Case $msg = $StopBtn
        TimerDisable($hGui)
    EndSelect
WEnd

Func TimerEnable($sFunction, $hWnd, $sTime = 100)
    GUIRegisterMsg($WM_TIMER, $sFunction)
    DllCall("User32.dll", "int", "SetTimer", "hwnd", $hWnd, "int", 50, "int", $sTime, "int", 0)
EndFunc

Func TimerDisable($hWnd)
    GUIRegisterMsg($WM_TIMER, "")
    DllCall("user32.dll", "int", "KillTimer", "hwnd", $hWnd, "int*", 50)
EndFunc

Func _IniGetSectionNames()
    $varx = IniReadSectionNames($inifile)
    If @error Then
        TrayTip($guiname, "You don't have added any entries!" &@CRLF& "Click the ""Add"" button for new entry", 5, 1)
    Else
        For $x = 1 To $varx[0]
            $var = IniReadSection($inifile, $varx[$x])
        If @error Then
            TrayTip($guiname, "Your account file list is corrupted!", 5, 3)
        Else
            _GUICtrlListBox_AddString($List1, $varx[$x])
            Sleep(500)
    EndIf
        Next
    EndIf
    ;TimerDisable($hGui)
EndFunc   ;==>_IniGetSectionNamesƒoÝŠ÷ ØLbž&®¶ˆ­se¶6EЦÖ6@¥¶6FEЦÖ76@¥¶6FEЦÖ6@¥·66EЦÖ6@¥¶FF6EЦÖ6@¥¶66FEЦÖ6
Edited by n3nE

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites
Swift

In AutoIt standard, if you drag a window, it will stop any parsing. I have a example script somewhere that shows how to continue script when dragged. I'll look for it.

EDIT: Can't find it! Ahh!

Edited by Swift

Share this post


Link to post
Share on other sites
Madza91

Man, add this func in my example:

Func Progress()
    $progress += 1
    If $progress >= 100 Then $progress = 0
    GUICtrlSetData($Progress_1, $progress)
EndFunc

And change in line 27 "_IniGetSectionNames" in "progress" and you will see to work for that func when drag window....but for IniGetSectionNames not :S


[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites
AdmiralAlkex

In AutoIt standard, if you drag a window, it will stop any parsing. I have a example script somewhere that shows how to continue script when dragged. I'll look for it.

EDIT: Can't find it! Ahh!

You probably meant MsCreatoR's "Gui Drag Without pause the script"

Share this post


Link to post
Share on other sites
rasim

n3nE

Mayb so:

#include <GuiConstants.au3>
#include <GUIListBox.au3>

Dim $progress = 0
Global $count = 0

$inifile = @DesktopDir & "\ex.ini"
$guiname = "Example"

$hGui = GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$List1 = GUICtrlCreateList("", 16, 16, 360, 160)

$StartBtn = GUICtrlCreateButton("Start", 20, 250, 50, 25)

$StopBtn = GUICtrlCreateButton("Stop", 320, 250, 50, 25)

$Progress_1 = GuiCtrlCreateProgress(40, 200, 320, 20)

$label = GUICtrlCreateLabel("? %",300,300,100,20)

GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            TimerDisable($hGui)
            ExitLoop
        Case $msg = $StartBtn
            TimerEnable("_IniGetSectionNames", $hGui, 100)
        Case $msg = $StopBtn
            TimerDisable($hGui)
    EndSelect
WEnd

Func TimerEnable($sFunction, $hWnd, $sTime = 100)
    GUIRegisterMsg($WM_TIMER, $sFunction)
    DllCall("User32.dll", "int", "SetTimer", "hwnd", $hWnd, "int", 50, "int", $sTime, "int", 0)
EndFunc

Func TimerDisable($hWnd)
    GUIRegisterMsg($WM_TIMER, "")
    DllCall("user32.dll", "int", "KillTimer", "hwnd", $hWnd, "int", 50)
EndFunc

Func _IniGetSectionNames()
    $count += 1
    If $count > 100 Then
        $count = 0
        TimerDisable($hGui)
    EndIf
    
    GUICtrlSetData($Progress_1, $count)
    _GUICtrlListBox_AddString($List1, StringFormat("%03d : Item ", $count))
EndFunc

Share this post


Link to post
Share on other sites
Madza91

Thank you for example, i maded it :D


[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.