SlimShady Posted January 13, 2005 Share Posted January 13, 2005 (edited) I have alot of work to do. I was wondering if someone could make me a UDF that "renames" list box items. I'll list some information that you'll need. - GUICtrlRead - GUICtrlSendMsg with the following messages: * LB_DELETESTRING message to delete a string in a list box * LB_ADDSTRING message to add a string to a list box So: $oldstring = GUICtrlRead($List_1) then: add item $substring + $oldstring I would really appreciate it. If not, I'll make it myself when I'm done (4 hours from now). Edited January 13, 2005 by SlimShady Link to comment Share on other sites More sharing options...
SlimShady Posted January 13, 2005 Author Share Posted January 13, 2005 *busy, busy, busy* Here's the function: Func ListItemRename($ListBox, $CurItem, $NewStr) Local $LB_DELETESTRING = 0x0182 Local $LB_INSERTSTRING = 0x0181 GUICtrlSendMsg($ListBox, $LB_DELETESTRING, $CurItem, 0) GUICtrlSendMsg($ListBox, $LB_INSERTSTRING, $CurItem, $NewStr) EndFunc Here's a working example: expandcollapse popup#include <GUIConstants.au3> AutoItSetOption("TrayIconDebug", 1) ;Initialize variables Global $style1 Global $IniFile Global $GUIWidth Global $GUIHeight $GUIWidth = 250 $GUIHeight = 250 GUICreate("New GUI", $GUIWidth, $GUIHeight) $List_1 = GUICtrlCreateList("", 10, 10, 200, 200) $Button_1 = GUICtrlCreateButton("OK", 70, 210, 70, 25) Dim $Items For $i = 0 To 9 $Items = $Items & "Item " & $i & "|" Next GUICtrlSetData($List_1, $Items) GUISetState(@SW_SHOW) While 1 Sleep(25) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $Button_1 $SelItem = SelectedListItem($List_1) If $SelItem Then ListItemRename($List_1, $SelItem, "COPIED - " & GUICtrlRead($List_1)) EndIf EndSelect WEnd Func SelectedListItem($ListBox) Local $CurSel Local $LB_GETCURSEL = 0x0188 $CurSel = GUICtrlSendMsg($ListBox, $LB_GETCURSEL, 0, 0) If $CurSel < 0 Then $CurSel = 0 Return $CurSel EndFunc Func ListItemRename($ListBox, $CurItem, $NewStr) Local $LB_DELETESTRING = 0x0182 Local $LB_INSERTSTRING = 0x0181 GUICtrlSendMsg($ListBox, $LB_DELETESTRING, $CurItem, 0) GUICtrlSendMsg($ListBox, $LB_INSERTSTRING, $CurItem, $NewStr) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now