Sign in to follow this  
Followers 0
litlmike

Guictrlcreatelist() And $msg = Guigetmsg()

6 posts in this topic

I would like to have 3 Lists with Data in it, and a 4th that gives a 'Running Total' of the 3 lists. So when the user selects items from the 3 lists and presses "add", the 4th list gives a summation of the selected items. How do I do this?

So, if the user selects the letters A, B, C, in the 4th list it should read: A, B, C. Here is my screwed up code below

#include <GUIConstants.au3>

Global Const $LBS_MULTIPLESEL = 0x8

$A_F = "A|B|C|D|E|F"
$G_L = "G|H|I|J|K|L"
$M_R = "M|N|O|P|Q|R"

HotKeySet ("^!+8", "GUI_3_Pick_Categories")

While 1 
    Sleep (100)
WEnd



Func GUI_3_Pick_Categories ()

GLOBAL $MESSAGE = "The following buttons have been clicked"
GUICreate("My GUI list", 700, 400); will create a dialog box that when displayed is centered

$listbox_1 = GUICtrlCreateList("", 50, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $A_F)

$listbox_2 = GUICtrlCreateList("", 250, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $G_L)

$listbox_3 = GUICtrlCreateList("", 500, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $M_R)

$add_list =  GUICtrlCreateList("", 350, 240, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))


$add=GUICtrlCreateButton ("Add", 65,250,75,25)
$clear=GUICtrlCreateButton ("Clear", 160,250,75,25)

GUICtrlSetLimit(-1,200); to limit horizontal scrolling

GUISetState ()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

    If $msg = $add Then
        $msg_set_data_1 = GUICtrlRead ($listbox_1)
                GUICtrlSetData($add_list,$msg_set_data_1)
    EndIf
            
    If $msg = $add Then
        $msg_set_data_2 = GUICtrlRead ($listbox_2)
                GUICtrlSetData($add_list,$msg_set_data_2)
    EndIf

        If $msg = $add Then
        $msg_set_data_3 = GUICtrlRead ($listbox_3)
                GUICtrlSetData($add_list,$msg_set_data_3)
    EndIf
    
    If $msg = $clear Then
        GUICtrlSetData($add_list,"")
    EndIf
Wend

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

this should work i think :think: coied alot out of the help file

#include <GUIConstants.au3>
#include <GuiList.au3>
$A_F = "A|B|C|D|E|F"
$G_L = "G|H|I|J|K|L"
$M_R = "M|N|O|P|Q|R"

HotKeySet ("^!+8", "GUI_3_Pick_Categories")

While 1
    Sleep (100)
WEnd



Func GUI_3_Pick_Categories ()

GLOBAL $MESSAGE = "The following buttons have been clicked"
GUICreate("My GUI list", 700, 400); will create a dialog box that when displayed is centered

$listbox_1 = GUICtrlCreateList("", 50, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $A_F)

$listbox_2 = GUICtrlCreateList("", 250, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $G_L)

$listbox_3 = GUICtrlCreateList("", 500, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $M_R)

$add_list =  GUICtrlCreateList("", 350, 240, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))


$add=GUICtrlCreateButton ("Add", 65,250,75,25)
$clear=GUICtrlCreateButton ("Clear", 160,250,75,25)

GUICtrlSetLimit(-1,200); to limit horizontal scrolling
Dim $msg_set_data_1
GUISetState ()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

    If $msg = $add Then
        $ret = _GUICtrlListGetSelItemsText ($listbox_1)
            If (Not IsArray($ret)) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
            Else
                For $i = 1 To $ret[0]
                GUICtrlSetData($add_list,$ret[$i])
                Next
            
            
        $ret = _GUICtrlListGetSelItemsText ($listbox_2)
            If (Not IsArray($ret)) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
            Else
                For $i = 1 To $ret[0]
                GUICtrlSetData($add_list,$ret[$i])
                Next
            
                
        $ret = _GUICtrlListGetSelItemsText ($listbox_3)
            If (Not IsArray($ret)) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
            Else
                For $i = 1 To $ret[0]
                GUICtrlSetData($add_list,$ret[$i])
                Next
            EndIf   
            EndIf
            EndIf
            EndIf
    If $msg = $clear Then
        GUICtrlSetData($add_list,"")
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
        EndIf
Wend

EndFunc
Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

this should work i think :think: coied alot out of the help file

#include <GUIConstants.au3>
#include <GuiList.au3>
$A_F = "A|B|C|D|E|F"
$G_L = "G|H|I|J|K|L"
$M_R = "M|N|O|P|Q|R"

HotKeySet ("^!+8", "GUI_3_Pick_Categories")

While 1
 Sleep (100)
WEnd
Func GUI_3_Pick_Categories ()

GLOBAL $MESSAGE = "The following buttons have been clicked"
GUICreate("My GUI list", 700, 400); will create a dialog box that when displayed is centered

$listbox_1 = GUICtrlCreateList("", 50, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $A_F)

$listbox_2 = GUICtrlCreateList("", 250, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $G_L)

$listbox_3 = GUICtrlCreateList("", 500, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $M_R)

$add_list =  GUICtrlCreateList("", 350, 240, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
$add=GUICtrlCreateButton ("Add", 65,250,75,25)
$clear=GUICtrlCreateButton ("Clear", 160,250,75,25)

GUICtrlSetLimit(-1,200); to limit horizontal scrolling
Dim $msg_set_data_1
GUISetState ()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
 $msg = GUIGetMsg()

 If $msg = $add Then
  $ret = _GUICtrlListGetSelItemsText ($listbox_1)
   If (Not IsArray($ret)) Then
    MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
   Else
    For $i = 1 To $ret[0]
    GUICtrlSetData($add_list,$ret[$i])
    Next
   
   
  $ret = _GUICtrlListGetSelItemsText ($listbox_2)
   If (Not IsArray($ret)) Then
    MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
   Else
    For $i = 1 To $ret[0]
    GUICtrlSetData($add_list,$ret[$i])
    Next
   
    
  $ret = _GUICtrlListGetSelItemsText ($listbox_3)
   If (Not IsArray($ret)) Then
    MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
   Else
    For $i = 1 To $ret[0]
    GUICtrlSetData($add_list,$ret[$i])
    Next
   EndIf 
   EndIf
   EndIf
   EndIf
 If $msg = $clear Then
  GUICtrlSetData($add_list,"")
 EndIf
 If $msg = $GUI_EVENT_CLOSE Then
  Exit
  EndIf
Wend

EndFunc
cool. i will try this first thing morrow. never seen guilist.au3 before. looks useful

Share this post


Link to post
Share on other sites

Gave it a try, seems to work mostly. Now I need to get the Data from $add_list. I am trying to use _GUICtrlListGetSelItemsText ($add_list), but I don't know what it returns, an array? Take a look at my messed up code below, and tell me what you think.

#include <GUIConstants.au3>
#include <GuiList.au3>
#include <Array.au3>

$A_F = "A|B|C|D|E|F"
$G_L = "G|H|I|J|K|L"
$M_R = "M|N|O|P|Q|R"

HotKeySet ("^!+8", "GUI_3_Pick_Categories")

While 1
    Sleep (100)
WEnd



Func GUI_3_Pick_Categories ()

GLOBAL $MESSAGE = "The following buttons have been clicked"
GUICreate("My GUI list", 700, 400); will create a dialog box that when displayed is centered

$listbox_1 = GUICtrlCreateList("", 50, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $A_F)

$listbox_2 = GUICtrlCreateList("", 250, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $G_L)

$listbox_3 = GUICtrlCreateList("", 500, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData (-1, $M_R)

$add_list =  GUICtrlCreateList("", 350, 240, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))


$add=GUICtrlCreateButton ("Add", 65,250,75,25)
$clear=GUICtrlCreateButton ("Clear", 160,250,75,25)
$done=GUICtrlCreateButton ("Done", 260,250,75,25)

GUICtrlSetLimit(-1,200); to limit horizontal scrolling
Dim $msg_set_data_1
GUISetState ()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

    If $msg = $add Then
        $ret = _GUICtrlListGetSelItemsText ($listbox_1)
            If (Not IsArray($ret)) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
            Else
                For $i = 1 To $ret[0]
                GUICtrlSetData($add_list,$ret[$i])
                Next
            
            
        $ret = _GUICtrlListGetSelItemsText ($listbox_2)
            If (Not IsArray($ret)) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
            Else
                For $i = 1 To $ret[0]
                GUICtrlSetData($add_list,$ret[$i])
                Next
            
                
        $ret = _GUICtrlListGetSelItemsText ($listbox_3)
            If (Not IsArray($ret)) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
            Else
                For $i = 1 To $ret[0]
                GUICtrlSetData($add_list,$ret[$i])
                Next
            EndIf   
            EndIf
            EndIf
            EndIf
    If $msg = $clear Then
        GUICtrlSetData($add_list,"")
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    
            If $msg = $done Then
        $list_array = _GUICtrlListGetSelItemsText ($add_list)
        _ArrayDisplay ( $list_array, "Title" )
;~      ToolTip ($list_array)
    EndIf
        
;~      For $list_array[0] to $list_array[$i]
;~          MsgBox (4096,"", $list_array)
;~      Next
    
Wend

EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <GUIConstants.au3>
#include <GuiList.au3>
#include <Array.au3>

$A_F = "A|B|C|D|E|F"
$G_L = "G|H|I|J|K|L"
$M_R = "M|N|O|P|Q|R"

HotKeySet("^!+8", "GUI_3_Pick_Categories")

While 1
    Sleep(100)
WEnd



Func GUI_3_Pick_Categories()
    
    Global $MESSAGE = "The following buttons have been clicked"
    GUICreate("My GUI list", 700, 400); will create a dialog box that when displayed is centered
    
    $listbox_1 = GUICtrlCreateList("", 50, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
    GUICtrlSetData(-1, $A_F)
    
    $listbox_2 = GUICtrlCreateList("", 250, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
    GUICtrlSetData(-1, $G_L)
    
    $listbox_3 = GUICtrlCreateList("", 500, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
    GUICtrlSetData(-1, $M_R)
    
    $add_list = GUICtrlCreateList("", 350, 240, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
    
    
    $add = GUICtrlCreateButton("Add", 65, 250, 75, 25)
    $clear = GUICtrlCreateButton("Clear", 160, 250, 75, 25)
    $done = GUICtrlCreateButton("Done", 260, 250, 75, 25)
    
    GUICtrlSetLimit(-1, 200); to limit horizontal scrolling
    Dim $msg_set_data_1
    GUISetState()
    $msg = 0
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $add
                $ret = _GUICtrlListGetSelItemsText($listbox_1)
                If IsArray($ret) Then
                    For $i = 1 To $ret[0]
                        GUICtrlSetData($add_list, $ret[$i])
                    Next
                EndIf
                
                
                $ret = _GUICtrlListGetSelItemsText($listbox_2)
                If IsArray($ret) Then
                    For $i = 1 To $ret[0]
                        GUICtrlSetData($add_list, $ret[$i])
                    Next
                EndIf
                
                
                $ret = _GUICtrlListGetSelItemsText($listbox_3)
                If IsArray($ret) Then
                    For $i = 1 To $ret[0]
                        GUICtrlSetData($add_list, $ret[$i])
                    Next
                EndIf
            Case $msg = $clear
                GUICtrlSetData($add_list, "")
            Case $msg = $GUI_EVENT_CLOSE
                Exit
                
            Case $msg = $done
                Dim $list_array[1] = [0]
                For $x = 0 To _GUICtrlListCount($add_list) - 1
                    ReDim $list_array[UBound($list_array) + 1]
                    $list_array[0] = $list_array[0] + 1
                    $list_array[UBound($list_array) - 1] = _GUICtrlListGetText($add_list, $x)
                Next
                _ArrayDisplay($list_array, "Title")
        EndSelect
        
    WEnd
    
EndFunc ;==>GUI_3_Pick_Categories

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Gary, you scare me. I would have never gotten that. Thanks soo much.

I think I can take it from here.

Really Gary...I dont think I would ever have gotten that. The way you pumped that out gives me the chills...*BRRR* :think:

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