Jump to content
Sign in to follow this  
Helge

$LBS_SORT acts strange

Recommended Posts

Helge

This is just something I found out while testing something the other day.

There might be something logical about it, anyway check this out :

$LBS_SORT = 0x0002
$GUI_EVENT_CLOSE = -3

GUICreate("Strange",200,200)
$list = GUICtrlCreateList("",10,10,180,150,- $LBS_SORT)
$btn  = GUICtrlCreateButton("Button",10,170,180,20)
GUISetState()

AdlibEnable("_close",10)

While 1   
    GUICtrlSetData($list,"line 1|line 2|line 3|line 4")
    Sleep(1000)
    
    If GUICtrlRead($btn) = "line 1|line 2|line 3|line 4" Then
       GUICtrlSetData($btn,"Fuck off !")
       Sleep(1000)
    EndIf
Wend

Func _close()
   $msg = GUIGetMsg()
   If $msg = -3 Then Exit
EndFunc

Note the use of "- $LBS_SORT"...

Edited by Helge

Share this post


Link to post
Share on other sites
MHz

Maybe a couple of more lines may help? :idiot:

$LBS_SORT = 0x0002
$GUI_EVENT_CLOSE = -3

GUICreate("Strange",200,200)
$list = GUICtrlCreateList("",10,10,180,150,- $LBS_SORT)
$btn  = GUICtrlCreateButton("Button",10,170,180,20)
GUISetState()

AdlibEnable("_close",10)

While 1   
   GUICtrlSetData($list,"line 1|line 2|line 3|line 4")
   Sleep(1000)
   
   If GUICtrlRead($btn) = "line 1|line 2|line 3|line 4" Then
      GUICtrlSetData($btn,"Fuck off !")
      Sleep(1000)
      GUICtrlSetData($btn,"Should I say that ?")
      Sleep(1000)
   EndIf
Wend

Func _close()
  $msg = GUIGetMsg()
  If $msg = -3 Then Exit
EndFunc

Share this post


Link to post
Share on other sites
Helge

Maybe a couple of more lines may help?  :D

<{POST_SNAPBACK}>

Nah, strange enough that didn't work. Hmm.. :idiot:

Share this post


Link to post
Share on other sites
Jos

Nah, strange enough that didn't work. Hmm.. :idiot:

<{POST_SNAPBACK}>

It is not that strange. "- $LBS_SORT" is invalid and the Handle returned by GUICtrlCreateList() = -1.

Then GUICtrlSetData($List...) refers to the Last control (-1) , which is the Button, it updates the Button text.

Maybe this needs to be checked or the Helpfile updated, since that states that the returned handle will be 0 on error.

demo:

$LBS_SORT = 0x0002
$GUI_EVENT_CLOSE = -3

GUICreate("Strange",200,200)
$list = GUICtrlCreateList("",10,10,180,150,- $LBS_SORT)
If $list = -1 then msgbox(0,'','you coded the command wrong !!')
$btn  = GUICtrlCreateButton("Button",10,170,180,20)
GUISetState()

AdlibEnable("_close",10)

While 1   
   GUICtrlSetData($list,"line 1|line 2|line 3|line 4")
   Sleep(1000)
   
   If GUICtrlRead($btn) = "line 1|line 2|line 3|line 4" Then
      GUICtrlSetData($btn,"Fuck off !")
      Sleep(1000)
   EndIf
Wend

Func _close()
  $msg = GUIGetMsg()
  If $msg = -3 Then Exit
EndFunc

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Helge

Ok, I know it was a strange code but it was just a test..

And JdeB, do you really think that I was serious when I thought that

the additions that MHz did could fix it ? :idiot:

Edited by Helge

Share this post


Link to post
Share on other sites
Jos

And JdeB, do you really think that I was serious when I thought that

the additions that MHz did could fix it ?  :idiot:

<{POST_SNAPBACK}>

Nope, just explaining the reason why it goes wrong and to point out the fact that the function is returning a -1 ...which is not what the helpfile says. so either the Function is returning the wong value or the Helpfile needs updating... :D

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×