Jump to content
Sign in to follow this  
fenix114

_GUICtrlListBox_AddString add after last string

Recommended Posts

fenix114

I got this code created with help of melba a few days ago, if you run this code and press "addname" a new name will appear in "list1"

my question is if a new string can be added after the last name instead of adding a new name before the first name

(in this case creating a new name after "example9" instead of creating a new name before "example1")

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

Global $iIndex = 0

$Form1 = GUICreate("Form1", 487, 437, 368, 124)

$List1 = GUICtrlCreateList("", 136, 24, 345, 396)
$Button1 = GUICtrlCreateButton("start function", 8, 24, 113, 41)
$addname = GUICtrlCreateInput("(add new name)", 16, 112, 113, 21)
$Button2 = GUICtrlCreateButton("add new name", 16, 144, 113, 25)

GUISetState(@SW_SHOW)

GUICtrlSetData($List1, "example1|example2|example3|example4|example5|example6|example7|example8|example9")
_GUICtrlListBox_SetCurSel($List1, $iIndex)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            _GUICtrlListBox_AddString($List1, GUICtrlRead($addname))
        Case $Button1
            ; Function
            MsgBox("", "Function", "Running on: " & GUICtrlRead($List1))
            ; Move on
            $iIndex += 1
            If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List1, $iIndex)

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
FireFox

Hi,

From the MSDN :


If the list box does not have the LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list and the list is sorted.

 

As the default style for the list is : $LBS_SORT, $WS_BORDER, $WS_VSCROLL, you need to remove the $LBS_SORT style.

#include <WindowsConstants.au3>

...

$List1 = GUICtrlCreateList("", 136, 24, 345, 396, BitOR($WS_BORDER, $WS_VSCROLL))

...

_

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
fenix114

I also want the list to select the next automaticly ( I know how to do that :) ) but I want it to stop when it selects the last name,

something like: stop function(function= select next one) when ""example9" is selected in list1

but i dont know how to practice this.

Share this post


Link to post
Share on other sites
FireFox

Maybe the GUICtrlRead function on the list.

Or :

If _GUICtrlListBox_GetCount($List1) -1 == _GUICtrlListBox_GetCurSel($List1) Then
...
Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

×