Sign in to follow this  
Followers 0
RabidGnome

Listview assistance

5 posts in this topic

After spending quite a bit of time looking through the help files, I've decided to seek assistance instead since I can't seem to find what I'm looking for. Essentially, I am having a few issues here and I'm not sure how to remedy them.

Below is the code that I am using, aside from a few small modifications to the "GUICtrlSetData" section, it is basically still an example script.

The problem that I am having is that I can't seem to get my buttons or my listview items to do anything. Ideally, I would like to be able to highlight an item in the list, move it over to the right, press Ok and then have data presented to me.

However, that's the problem. I don't know how to accomplish the following:

1) Making the buttons (Ok, cancel, >, >>, etc...) actually work.

2) Once items are moved over into the right column view and I press ok, how do I associate data with that? For example, lets say that I select "PS1" from the list and I wanted something like "PS1 = teh win for everyone" to appear in a message box or window, how would I do that?

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Choices Dialog", 353, 262, 303, 219)
GUISetIcon("D:\007.ico")
$ListBox1 = GUICtrlCreateList("", 8, 8, 137, 201)
GUICtrlSetData(-1, "PS1|PS2|PS3|PS4|PS5|PF1|PF2|PF3|PF4|SS|DA")
$Button1 = GUICtrlCreateButton(">", 156, 15, 30, 25, 0)
$Button2 = GUICtrlCreateButton(">>", 156, 48, 31, 25, 0)
$Button3 = GUICtrlCreateButton("<", 157, 81, 31, 25, 0)
GUICtrlSetState(-1, $GUI_Enable)
$Button4 = GUICtrlCreateButton("<<", 157, 114, 32, 25, 0)
$ListBox2 = GUICtrlCreateList("", 200, 8, 137, 201)
$Button5 = GUICtrlCreateButton("&OK", 104, 225, 75, 25, 0)
$Button6 = GUICtrlCreateButton("&Cancel", 184, 225, 75, 25, 0)
$Button7 = GUICtrlCreateButton("&Help", 264, 225, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Sure, after reading my post, it's pretty easy to figure out that I am just starting out with using Autoit, so any assistance would be appreciated. An example would be fantastic, but a push in the right direction would be great as well.

Thanks in adance.

Share this post


Link to post
Share on other sites



Welcome to the forums.

First things first. To control a button using the loop mode you need to have a case statement check for the button

ie:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    Case $nMsg = $Button1
        ;do this code
    Case $nMsg = $Button2
        ;do this code
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

To mix it up a little more, you can read from the list (i also changed things to make it work)

While 1
    
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Button1
            MsgBox(0,'',GUICtrlRead($ListBox1))
            ;do this code
        Case $nMsg = $Button2
            ;do this code
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

Ah, excellent. That's helpful. Let me work on that part for a little while today and see if I can get it down (at least the button functionality) and I'll post back on here when I've made a somewhat decent script.

Share this post


Link to post
Share on other sites

Here's where I'm at with it now thanks to your assistance :D Making the buttons do random things seems pretty easy now.

Am I able to have the highlighted item refer to a file for an answer after I press the ">" button or will I have to use a different command?

Again, thanks for the help in adance!

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Choices Dialog", 353, 262, 303, 219)
GUISetIcon("D:\007.ico")
$ListBox1 = GUICtrlCreateList("", 8, 8, 137, 201)
GUICtrlSetData(-1, "PS1|PS2|PS3|PS4|PS5|PF1|PF2|PF3|PF4|SS|DA")
$Button1 = GUICtrlCreateButton(">", 156, 15, 30, 25, 0)
$Button2 = GUICtrlCreateButton(">>", 156, 48, 31, 25, 0)
$Button3 = GUICtrlCreateButton("<", 157, 81, 31, 25, 0)
GUICtrlSetState(-1, $GUI_Enable)
$Button4 = GUICtrlCreateButton("<<", 157, 114, 32, 25, 0)
$ListBox2 = GUICtrlCreateList("", 200, 8, 137, 201)
$Button5 = GUICtrlCreateButton("&OK", 104, 225, 75, 25, 0)
$Button6 = GUICtrlCreateButton("&Cancel", 184, 225, 75, 25, 0)
$Button7 = GUICtrlCreateButton("&Help", 264, 225, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Button1
            MsgBox(0,'Processing...',GUICtrlRead($ListBox1))
        Case $nMsg = $Button2
           ;do this code
        Case $nmsg = $Button5
            Msgbox(0, "Selected listbox entry", GUICtrlRead($Button5)); display the selected listbox entry
            Msgbox(0, "State and text of the menuitem", "state:" & $menustate & @LF & "text:" & $menutext)
        Case $nMsg = $Button6
            Exit
        Case $nmsg = $Button7
            MsgBox(0, "Help?", "No help here!",5)
    EndSelect
WEnd

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