Sign in to follow this  
Followers 0
Didonet

GUICtrlCreateMenuitem update on every click

3 posts in this topic

#1 ·  Posted (edited)

I have a drop-down menu in my program.

Like that:

$connectitem = GUICtrlCreateMenuitem ("Login",$filemenu)

If Ping("my.site.com",250) Then GUICtrlSetState(-1,$GUI_DISABLE)

$disconnectitem = GUICtrlCreateMenuitem ("Logout",$filemenu)

If Not Ping("my.site.com",250) Then GUICtrlSetState(-1,$GUI_DISABLE)

When the program loads it pings the site. But when the connection is lost the info is still the old. Can i refresh it ? I try with WHILE, but it didn't works.

I try this:

$disconnectitem = GUICtrlCreateMenuitem ("Logout",$filemenu)

While 1

$msg = GUIGetMsg()

Select

Case $msg = $disconnectitem

If Not Ping("forum.recbg.net",250) Then

GUICtrlSetState(-1,$GUI_DISABLE)

EndIf

EndSelect

WEnd

Error:

myscript.au3 (28) : ==> Variable used without being declared.:

If Ping("my.site.com",250) Then GUICtrlSetState(-1,$GUI_DISABLE)

If Ping("my.site.com",250) Then GUICtrlSetState(-1,^ ERROR

:)

What a spammer am i... :)

Edited by Didonet

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$disconnectitem = GUICtrlCreateMenuitem ("Logout",$filemenu)

While 1
    $msg = GUIGetMsg()
        Select
        Case $msg = $disconnectitem
        If Not Ping("forum.recbg.net",250) Then
            GUICtrlSetState($disconnectitem, $GUI_DISABLE)
        EndIf
        EndSelect
WEnd

your error is that you use GUICtrlSetState(-1, $GUI_DISABLE) and -1 indicates the latest variable (item) used, so you cant use -1 you have to insert the variable of your menu item

(i suggest that you change 250 [timeout] to a larger value, cause there is a possibility that it wont ping that site in 250 and there might be a false result)

Edited by Gif

Share this post


Link to post
Share on other sites

Thanks again, @Gif! Thie ping timeout is 250, because the site is local and the timeout there is <4ms :)

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  
Followers 0