E1M1 Posted June 6, 2009 Posted June 6, 2009 (edited) How to change that listview so I can edit item's text if I click on item? #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 629, 461, 460, 262) $ListView1 = GUICtrlCreateListView("list|List1", 0, 0, 626, 454, BitOR($LVS_REPORT,$LVS_EDITLABELS,$LVS_SHOWSELALWAYS),$LVS_EX_GRIDLINES) GUICtrlCreateListViewItem("item11|item12",$ListView1) GUICtrlCreateListViewItem("item21|item22",$ListView1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited June 6, 2009 by E1M1 edited
ReFran Posted June 6, 2009 Posted June 6, 2009 How to change that listview so I can edit item's text if I click on item?Mmmh,if I remeber right there is a UDF exactly for that - under GUIListview-managment. So if you don't want to search here start scite and press F1. (or Help->Help)HTH, Reinhard
E1M1 Posted June 6, 2009 Author Posted June 6, 2009 all I found was : #Include <GuiListView.au3> _GUICtrlListView_EditLabel($hWnd, $iIndex) But it don't let me edit any item, when I finished item editing on that example, I didn't had any other chance to edit it.I need ability to edit item I click on.I also searched from this froum for GUIListview-managment ... didn't find that udf. ***************** can anyone help me understand that example from help there is many DllStructGetData() commands in that example, I know only that I gets DLL data, what what dll it uses? what data it get's and how this thing work? how I know what Struct must be? and how i know which Element I need to use? where it all came from? edited
martin Posted June 6, 2009 Posted June 6, 2009 all I found was :#Include <GuiListView.au3>_GUICtrlListView_EditLabel($hWnd, $iIndex)But it don't let me edit any item, when I finished item editing on that example, I didn't had any other chance to edit it.I need ability to edit item I click on.I also searched from this froum for GUIListview-managment ... didn't find that udf.*****************can anyone help me understand that example from helpthere is many DllStructGetData() commands in that example, I know only that I gets DLL data, what what dll it uses? what data it get's and how this thing work?how I know what Struct must be? and how i know which Element I need to use? where it all came from?I think what you need is eltorro's _EIPLISTVIEW. He hasn't updated it recently and I posted an update here. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Bowmore Posted June 6, 2009 Posted June 6, 2009 all I found was :#Include <GuiListView.au3>_GUICtrlListView_EditLabel($hWnd, $iIndex)But it don't let me edit any item, when I finished item editing on that example, I didn't had any other chance to edit it.I need ability to edit item I click on.I also searched from this froum for GUIListview-managment ... didn't find that udf.*****************can anyone help me understand that example from helpthere is many DllStructGetData() commands in that example, I know only that I gets DLL data, what what dll it uses? what data it get's and how this thing work?how I know what Struct must be? and how i know which Element I need to use? where it all came from?The example for _GUICtrlListView_GetEditControl() in the help file is a working example of how it is done. The example will need modifying slightly to work with sub items as well as items. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
E1M1 Posted June 6, 2009 Author Posted June 6, 2009 The example for _GUICtrlListView_GetEditControl() in the help file is a working example of how it is done. The example will need modifying slightly to work with sub items as well as items.you re right but I don't know how I have to modify it, and do I need to work with all these DllStructGetData() commands? edited
Bowmore Posted June 6, 2009 Posted June 6, 2009 you re right but I don't know how I have to modify it, and do I need to work with all these DllStructGetData() commands?rasim has posted a much better example here. Posted by rasim "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
E1M1 Posted June 6, 2009 Author Posted June 6, 2009 thanks. I have few more questions. how to change script if I want to use single click instead of double click to edit item? How I enable left,right arrows for moving inside Listview? I want that I can move with arrow keys inside listview and I want automatically enable item editing on item select. I also want get rid of that red border, And I want to add option fot automatically select text it should be variablethat will be checked every time item selected. for example if $SelecAll = 0 then dont select text when item is selected if $SelecAll = 1 then select all text when Item is selected so if I press any text symbol, item's text will be automatically replaced. edited
Zedna Posted June 7, 2009 Posted June 7, 2009 Look here at elegant script for editable listview: http://www.autoitscript.com/forum/index.ph...st&p=467479Look here at script for catch selection change in listview: http://www.autoitscript.com/forum/index.ph...st&p=691927 Resources UDF ResourcesEx UDF AutoIt Forum Search
E1M1 Posted June 7, 2009 Author Posted June 7, 2009 But how i connect all these nice examples to 1 big script? they all use WM_NOTIFY(), But don't understand how it works.And it's not easy to operate with function that i cant understand. I Dont know where All these variables come from, and how DllStruct* commands work? how these commands know what they have to do? all autoit funcs with DllStruct are black area for me,I simply cant understand how It works. edited
Zedna Posted June 7, 2009 Posted June 7, 2009 (edited) In this case don't try to do complicated projects/tasks and do only simple ones (for the start of your scripting). EDIT: I mean it without any offence here Edited June 7, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
E1M1 Posted June 7, 2009 Author Posted June 7, 2009 In this case don't try to do complicated projects/tasks and do only simple ones (for the start of your scripting).Well I know some autoit commands and I have some autoit programming experience.Here I would mention some of things Ive done in autoit:notepad (it has more functions that windows original notepad)apt - looks and acts like Adept under linux but my program is for windows and coded in autoitMainMenu - alternative for windows start menuIf sentence interpretatorProgram to to limit usage of programs, that program can use server to get blacklist, whitelist and main conf, this program can also use plugins.ECP Edit Control Poisoner - turn random edit control into powerful command line.I found ~400 self made scripts from my computer.now I am trying to make simple excel, but problem is: I dont have any editable ListView control.But if u can recommend me something easier to do then let me know. edited
KaFu Posted June 8, 2009 Posted June 8, 2009 This is a nice example using auto-generated GuiCtrlCreateInput() fields.http://www.autoitscript.com/forum/index.php?showtopic=95854 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
E1M1 Posted June 8, 2009 Author Posted June 8, 2009 but it takes lot's of time if I have 10000x5 size table. edited
KaFu Posted June 8, 2009 Posted June 8, 2009 (edited) For that kind of burden, I fear the only way to go is like Zedna pointed out already above by using WM_Notify type of editing. Check out the examples, there's really not magic involved, you don't have to mess around with dlls but just copy and adjust the examples. Edited June 8, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
E1M1 Posted June 8, 2009 Author Posted June 8, 2009 yeh,but How i enable editing soon as I select item? How I enable moving with left/right arrows between columns? edited
KaFu Posted June 8, 2009 Posted June 8, 2009 (edited) Thats exactly what Windows is nice enough to track and notify you via WM_Notify, it's a message broadcast in the background. Take this exampleexpandcollapse popup#include <GuiListView.au3> #include<GUIConstants.au3> #include<Constants.au3> #include<WindowsConstants.au3> $Gui = GUICreate("Test", 400, 250) $hListView = GUICtrlCreateListView("Items", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) ;$hListView = _GUICtrlListView_Create($Gui, "Items", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) $ListItem1 = _GUICtrlListView_AddItem($hListView, "Item 1",0) $ListItem2 = _GUICtrlListView_AddItem($hListView, "Item 2",2) $ListItem3 = _GUICtrlListView_AddItem($hListView, "Item 3",1) $ListItem4 = _GUICtrlListView_AddItem($hListView, "Item 4",3) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $Edit_Button = GUICtrlCreateButton("Edit Item", 10, 200) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $Edit_Button $iSelected = _GUICtrlListView_GetSelectedIndices($hListView) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hListView, $iSelected) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") consolewrite($iCode & @crlf) Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_BEGINLABELEDIT Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDIT Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then Return True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunccopied from here:#467479and changed$iCode = DllStructGetData($tNMHDR, "Code")to$iCode = DllStructGetData($tNMHDR, "Code")consolewrite($iCode & @crlf)open the GUI, move your mouse over the listview, use cursors and you'll see the $iCode notify codes in the console. Each code is unique and represents a certain action. Look up the examples or the AU constant includes for listview to learn what they mean (focus set, focus lost, clicked, doubleclicked...). Edited June 8, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
E1M1 Posted June 8, 2009 Author Posted June 8, 2009 (edited) Thanks, now I can start making my modifications (I already did) but now I cant use up/down arrow to jump from row to another (anymore). How I enable it again? Edit: I cant create another column! GUI doesn't display that! Here's modification: expandcollapse popup#include <GuiListView.au3> #include<GUIConstants.au3> #include<Constants.au3> #include<WindowsConstants.au3> $Gui = GUICreate("Test", 400, 250) $hListView = GUICtrlCreateListView("Items|Items2", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) ;$hListView = _GUICtrlListView_Create($Gui, "Items", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) $ListItem1 = _GUICtrlListView_AddItem($hListView, "Item 1|Item 21",0) $ListItem2 = _GUICtrlListView_AddItem($hListView, "Item 2|Item 22",2) $ListItem3 = _GUICtrlListView_AddItem($hListView, "Item 3|Item 23",1) $ListItem4 = _GUICtrlListView_AddItem($hListView, "Item 4|Item 24",3) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $Edit_Button = GUICtrlCreateButton("Edit Item", 10, 200) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $Edit_Button $iSelected = _GUICtrlListView_GetSelectedIndices($hListView) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hListView, $iSelected) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") consolewrite($iCode & @crlf) If $iCode = -2 Then $iSelected = _GUICtrlListView_GetSelectedIndices($hListView) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hListView, $iSelected) EndIf Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_BEGINLABELEDIT Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDIT Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then Return True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Edited June 8, 2009 by E1M1 edited
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