Moderators Melba23 Posted November 21, 2016 Author Moderators Share Posted November 21, 2016 (edited) Tankbuster, What exactly do you want to do? Initialise an existing ListView or reload an already-intialised one dynamically with new data? By the way, you might like to Beta test this new version for me: <snip> Make sure you read the attached Guide as I have changed a fair few things - intended (I hope) to simplify the UDF for the user, such as only having the one idle loop function which looks after all the UDF events rather then a whole slew of them. And yes, it does drag/drop checkboxes! Let me know what you think, M23 Edited December 8, 2016 by Melba23 Beta code removed Tankbuster 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted November 21, 2016 Share Posted November 21, 2016 I think the answer to my question is (How to reload a already initialised LV with completly new data?) _GUIListViewEx_Close before the init. Just as you wrote even in the previous guide. I run exactly in the issue you descibed in the guide. I used the DeleteAllItems and the init of the ListViewEx, but sometimes the array was just not right (and raised And I will check the Checkboxes. Realy thank you for beeing again patient (while I ask things that should be clear by reading the guide......). Maybe and this is only a suggestion for people like me : Add a button to eg. example 4 to reset one of the views and reload different data. (I'm always impatient and try to learn it from the examples :-) ) Thank you already for the new version. Link to comment Share on other sites More sharing options...
Mbee Posted November 23, 2016 Share Posted November 23, 2016 (edited) Hi, Maestro @Melba23 ! I'm about to develop an app for my own use that seems like it would not only benefit enormously from your UDF, but it would be ridiculously tricky to code if it were not centrally based on your amazing UDF. And since you noted on Monday that you would appreciate some Beta testing of your new version (GUIListViewEx_EventMonitor.au3), I decided to help since you've done so very much for me. This might also be worthwhile to you because I always run in 64-bit mode, so I can test for that compatibility. So I decided the place to start would be to modify the examples you posted in your original zip (on page 1) to #include your new UDF and add the bare-bones processing in the examples' code (but not yet to actually respond to the new events - I'm too much of a noob to your UDF (either one) to try that yet). I've finished this initial step for the first two example files, and I've run into a problem: Your new version doesn't include a function named "_GUIListViewEx_EditOnClick()", probably because the new version doesn't do things that way anymore. But these first two examples (at least so far) call it, so obviously the code won't pass the syntax tests or compile. I'm going to attach a zip file containing the modified two example files for you to examine. When you look at the code I've added in the message loop, please understand that since I'm Beta testing, I've added a crazy amount of error checking which I'd never code for a production UDF, so bear that in mind, please, rather than think me a moron... ETA: The function "_GUIListViewEx_ToolTipShow()" also appears to be missing... PreliminaryExamples.zip Edited November 23, 2016 by Mbee Added new problem Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 23, 2016 Author Moderators Share Posted November 23, 2016 (edited) Mbee, Did you read the Guide I posted with the Beta? It explains that you now only need the _GUIListViewEx_EventMonitor function in the idle loop rather than the whole slew of functions that were needed before for editing, showing tooltips, reporting drags and sorts, and correctly recolouring. Here are the examples I have rewritten for the Beta: . You will need to rename the Beta GLVEx include file line to match your saved Beta filename - it is currently set to GUIListViewEx_EventMonitor.au3 which is what I used for testing. Thanks for trying out the Beta - do let me know if you run into any problems now you have the modified examples. M23 Edited April 17, 2017 by Melba23 Beta code removed Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Mbee Posted November 23, 2016 Share Posted November 23, 2016 6 minutes ago, Melba23 said: Mbee, Did you read the Guide I posted with the Beta? It explains that you now only need the _GUIListViewEx_EventMonitor function in the idle loop rather than the whole slew of functions that were needed before for editing, showing tooltips, reporting drags and sorts, and correctly recolouring. Here are the examples I have rewritten for the Beta: GLVEx_Beta_Examples.zip. You will need to rename the Beta GLVEx include file line to match your saved Beta filename - it is currently set to GUIListViewEx_EventMonitor.au3 which is what I used for testing. Thanks for trying out the Beta - do let me know if you run into any problems now you have the modified examples. M23 Thanks for your fast reply, Melba! But is it possible that you forgot to post the most recent version of the Guide document? Otherwise, perhaps you were too familiar with the material, since I've read and re-read it, yet I can't find anyplace in the posted document where it explicitly states or even strongly suggests that now only the _GUIListViewEX_EventMonitor() function is needed in the message loop (other than ancillary event processing such as that required for manually specified registered messages, etc). Instead, it states: Quote Adding the _GUIListViewEx_EventMonitor function to the idle loop allows you to monitor 3 types of UDF event... ... The _GUIListViewEx_EventMonitor function should also be placed in the idle loop in 2 other cases... ... Basically - if in doubt, add this function to the idle loop! All of which strongly implies that the function is useful and recommended, but generally optional (not essential in the message loop processing). The document does not appear (to my eyes) to state that the function in question totally replaces all other non-ancillary message/event processing, nor that the EditOnClick and ToolTip-related functions have been eliminated. I apologize if I've given offense! It's just that while I may well be an AutoIt noob, I'm pretty good at reading and comprehending English, and I've long made it a habit to read documentation... In any event, the Beta examples you've provided resolve these issues much more succinctly than the Guide alone! If they had been posted earlier, I would not have troubled you (though I would still have volunteered for Beta testing). Thank you again for your time and your awesome code! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 23, 2016 Author Moderators Share Posted November 23, 2016 Mbee, No offence taken - I really should have posted the modified examples along with the Beta UDF, but I had not yet finished testing them to my satisfaction. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
InunoTaishou Posted November 25, 2016 Share Posted November 25, 2016 How can I update the internal array that holds my listview information? I have items deleted and re-added in my listview constantly and can't track down how to update the internal array. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 25, 2016 Author Moderators Share Posted November 25, 2016 InunoTaishou, You need to use the UDF functions to change the ListView content - that way it all happens automatically. If you could provide more details I can suggest how you might manage the data changes within the UDF. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted November 25, 2016 Share Posted November 25, 2016 I like the monitor feature. I think this makes using the UDF more easy and flexible/controllable Btw. Guess what on user request I needed to remove the checkboxes from the Listview......(see my question in previous post) BUT ! I already got a new script that uses this kind of feature. So thank you again. Will watch this until it goes out of Beta. Awesome work. Link to comment Share on other sites More sharing options...
InunoTaishou Posted November 26, 2016 Share Posted November 26, 2016 I PM'd you, hopefully it was detailed enough. I didn't play too much with it earlier but I noticed that editing a cell in the list view, and then clicking out of it does not return the value from the edit. Maybe I used the wrong value to initialize the edit. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 27, 2016 Author Moderators Share Posted November 27, 2016 Tankbuster, Sorry, missed your post #129 yesterday. Glad you like the new EventMonitor version of the UDF - I will see about releasing it next week. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted December 7, 2016 Share Posted December 7, 2016 Hello Melba23, in my first app, I included the monitor version. It works fine. Adding, reset, ordering , just everything as expected. But it crashes on a certain feature, but maybe I did not used it in the correct way. Let me describe, how and why and I attached a modified version of the example 2 (of the beta) to show you what I did . I got a LV. Got it initialized and also the Tooltip activated in my idle loop. I load data to the LV. Tool tip is shown. So far so good. Now a "reset" button resets the LV: {snip from my code - I attached the lines to the example, so you see what I try. The rest is pretty much the same.} (just check Line 116 in the example "Case $cDelete_Button....." and start it and press the delete on the left LV and finally click in the LV) _GUICtrlListView_DeleteAllItems($lvMain) _GUIListViewEx_Close($lvMain_ExInit) ReDim $aTC[0] $lvMain_ExInit = _GUIListViewEx_Init($lvMain, "", 0, 0, True, 64 + 128 + 256) _GUIListViewEx_ToolTipInit($lvMain_ExInit, "*", 2000) $aTC = _GUIListViewEx_ReturnArray($lvMain_ExInit) It looks like $vRet = _GUIListViewEx_EventMonitor() does not like it in case the _GUIListViewEx_Close($lvMain_ExInit) is called .$sText = $aItemText[$aGLVEx_Data[0][5] + 1] $sText = ^ ERROR Is this a issue? Something that the UDF does not expect to happen ("close" while using monitor?) Do I need to call the _GUIListViewEx_MsgRegister() again on the close? GLVEx_Example_2_withCloseCrash.au3 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 8, 2016 Author Moderators Share Posted December 8, 2016 (edited) Tankbuster, Nothing to do with the EventMonitor function. I did not test for a valid return before trying to access the item text to create the tooltip - hence the crash when the code tries to do so. Try this version: <snip> M23 Edited December 8, 2016 by Melba23 Beta code removed Tankbuster 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted December 8, 2016 Share Posted December 8, 2016 (edited) Yep, works as expected now. Crash is not seen anymore. And a new question: In case I want no "internal" drag, I need to set the _GUIListViewEx_MsgRegister($fMOUSEMOVE = False) But that would affect all initialized LVs, right? Is it possible to remove the internal drag from a certain LV? And question 2: On the tooltip in example2, after the text it displays always a "number" , what is this? The init says "0", so only col 0 should be displayed, right? Edited December 8, 2016 by Tankbuster Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 8, 2016 Author Moderators Share Posted December 8, 2016 (edited) Tankbuster, There is currently no way to remove the internal drag/drop from a single ListView - mostly because no-one has ever asked for that functionality. I will look at how it might be implemented. As for the tooltip question: I see what you mean and I will look into why that happens. M23 Edit: I see the tooltip problem and I am working on fixing it. Edit 2: I think I have both changes working. Note that if you use single cell selection you need to change the _Init $iAdded value as I have used its old value for the new functionality: ; + 64 - No external drag ; + 128 - No external drop ; + 256 - No delete on external drag/drop ; + 512 - No drag/drop < new functionality ; + 1024 - Single cell selection (forces single selection) < used to be 512 How does it work for you? M23 Edited April 17, 2017 by Melba23 Beta code removed Tankbuster 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted December 8, 2016 Share Posted December 8, 2016 Nice. I confirm, the MOD version of the last post works for both requests. For the _Init $iAdded I only needed to add 512 in my case as I did not used 512 before. Good job - and fast as hell again. Thx. Will wait for the final UDF but up to now for me the UDF works as expected. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 8, 2016 Author Moderators Share Posted December 8, 2016 Tankbuster, And thank you for the testing - you never find all the bugs yourself! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
robertocm Posted December 10, 2016 Share Posted December 10, 2016 (edited) Dear Melba23, First Many Thank! Below is an example that i'm using to learn about your UDF. Basically it looks for a name in a MS Access table and display results in a listview. I'm having to difficulties: If any row of the access table has a pipe character ("|") in the first field, then seems to produce an error in the _GUIListViewEx_ReadToArray: 'Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aLVArray[$i + $iStart][$j - 1] = $aRow[$j] ' (Examples of use of the character in a phone book could be: Roberto | CompanyA while other 'name' could be Roberto | DepartmentB ) I'm not able to edit ListView contents. Any suggestions would be appreciated. Thanks in advance. Edited Nov, 11 (solved) expandcollapse popup#include <GuiConstants.au3> #include <EditConstants.au3> #include <GuiMenu.au3> ;GUIListViewEx from Melba23 https://www.autoitscript.com/forum/topic/182492-guilistviewex-new-version-27-may-16 #include "GUIListViewEx.au3" Global $iEditMode = 23 ;Gui adapted From Ayman Henry (aymhenry@gmail.com), Phone Book Rev 02 ;Sorry but don't remember where _GUI_ToTray function was found nor the name of the author #Include <Constants.au3> Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) Opt("TrayIconHide", 1) Opt( "MustDeclareVars", 1 ) ;_ErrADODB From spudw2k ;https://www.autoitscript.com/forum/topic/105875-adodb-example/ Global $errADODB = ObjEvent("AutoIt.Error","_ErrADODB") Local Const $sTitle = "Phone Book" Const $conOK = 1, $conEdit = 1, $conAdd = 0 Global $cmdAdd, $cmdEdit, $cmdDelete, $cmdCancel Global $cmdNext, $cmdFirst, $cmdPrev, $cmdLast Global $cmdSave Global $InStr Global $n_RecCount, $n_RecPos ; Sreen Fields Global $txtFirstName, $txtMidName, $txtLastName Global $txtMobile, $txtHomePhone, $txtAddress Global $lblRecPos Global $sAnswer, $TempAr Global $sSQL Global $iCursorType = 0 ;0 adOpenForwardOnly, 1 adOpenKeyset Global $iLockType = 3 ;1 adLockReadOnly, 3 adLockOptimistic Global $iOptions = 1 ; Options, 1 Evaluates as a textual definition of a command or stored procedure call Global $cn = ObjCreate("ADODB.Connection") ; Create a connection object Global $rst = ObjCreate("ADODB.Recordset") ; Create a recordset object Global $sFilename = @ScriptDir & "\db.mdb" Global $cString = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $sFilename ;Global $cString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $sFilename & ";Jet OLEDB:Database Password=123" ;$cString = 'DRIVER={Microsoft Access Driver (*.mdb)};Dbq=' & $sFilename & ';uid=;pwd=MyPassword;' $cn.Open($cString) ; Open the connection Global $tblname = "Tel", $w Global $GuiWidth = @DesktopWidth-2, $GuiHight = @DesktopHeight-77 Global Enum $idExit = 1000, $idFavorites, $idCustomFavs1, $idCustomFavs2 Global $hGui, $hMenu Local $hFile, $hCustomFavs, $hPrograms, $hCustomProgs ;Create GUI $hGui = GUICreate($sTitle, $GuiWidth, $GuiHight) GUISetBkColor(0xA9A9A9) ;Register a function for WM_COMMAND messages GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Create File menu $hFile = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hFile, 0, "Exit", $idExit) ;This is from LarsJ: ShowFavsProgsMenu. Create custom Favorites menu. $hCustomFavs = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hCustomFavs, 0, "A&utoIt", $idCustomFavs1) _GUICtrlMenu_InsertMenuItem($hCustomFavs, 1, "&Microsoft", $idCustomFavs2) ; Create Main menu $hMenu = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Fa&vorites", $idFavorites) _GUICtrlMenu_InsertMenuItem($hMenu, 2, "Custom Fav&orites", 0, $hCustomFavs) ;Set window menu _GUICtrlMenu_SetMenu($hGui, $hMenu) Local $Label1, $Label2, $Label3, $Label4, $Label5, $Label6 $Label1 = GUICtrlCreateLabel("N", 8, 45, 20, 20) $Label2 = GUICtrlCreateLabel("T1", 8, 81, 20, 20) $Label3 = GUICtrlCreateLabel("T2", 8, 117, 20, 20) $Label4 = GUICtrlCreateLabel("T3", 8, 153, 20, 20) $Label5 = GUICtrlCreateLabel("T4", 8, 189, 20, 20) $Label6 = GUICtrlCreateLabel("A", 8, 225, 20, 20) Global $KeyW = GUICtrlCreateInput("", 30, 2, 205, 33) GUICtrlSetBkColor(-1, 0xD3D3D3) GUICtrlSetFont(-1, 11) $txtFirstName = GUICtrlCreateInput("", 30, 40, 1130, 30) GUICtrlSetLimit(-1, 200) GUICtrlSetFont(-1, 12) $txtMidName = GUICtrlCreateInput("", 30, 76, 1130, 30) GUICtrlSetLimit(-1, 100) GUICtrlSetFont(-1, 12) $txtLastName = GUICtrlCreateInput("", 30, 112, 1130, 30) GUICtrlSetLimit(-1, 100) GUICtrlSetFont(-1, 12) $txtMobile = GUICtrlCreateInput("", 30, 148, 1130, 30) GUICtrlSetLimit(-1, 100) GUICtrlSetFont(-1, 12) $txtHomePhone = GUICtrlCreateInput("", 30, 184, 1130, 30) GUICtrlSetLimit(-1, 100) GUICtrlSetFont(-1, 12) $txtAddress = GUICtrlCreateInput("", 30, 220, 1130, 30) GUICtrlSetLimit(-1, 250) GUICtrlSetFont(-1, 9) ;This is from Melba23 GUIListViewEx Global $cLV, $iLV, $hLV $cLV = GUICtrlCreateListView("Name|T1|T2|T3", 2, 255, $GuiWidth-4, 530) ;$cLV = GUICtrlCreateListView("Name|T1|T2|T3", 2, 255, $GuiWidth-4, 440, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS)) ;_GUICtrlListView_SetExtendedListViewStyle($cLV, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) _GUICtrlListView_SetColumnWidth($cLV, 0, 600) _GUICtrlListView_SetColumnWidth($cLV, 1, 250) _GUICtrlListView_SetColumnWidth($cLV, 2, 250) _GUICtrlListView_SetColumnWidth($cLV, 3, 250) ;Initiate GLVEx - no array passed - count parameter set - default insert mark colour (black) - drag image $iLV = _GUIListViewEx_Init($cLV, "", 1, 0, True, 4) ;All columns editable _GUIListViewEx_SetEditStatus($iLV, "*") ;Insert blank rows ;For $i = 0 To 9 ; _GUIListViewEx_Insert("") ;Next $cmdFirst = GUICtrlCreateButton("|<", 250, 2, 33, 33, 0) $cmdPrev = GUICtrlCreateButton("<", 286, 2, 33, 33, 0) $lblRecPos = GUICtrlCreateLabel("", 318, 8, 80, 24, $ES_CENTER) GUICtrlSetFont(-1, 11) $cmdNext = GUICtrlCreateButton(">", 396, 2, 33, 33, 0) $cmdLast = GUICtrlCreateButton(">|", 432, 2, 33, 33, 0) $cmdAdd = GUICtrlCreateButton("Add", 1170, 40, 92, 31, 0) GUICtrlSetState(-1, $GUI_DISABLE) $cmdEdit = GUICtrlCreateButton("Edit", 1170, 76, 92, 31, 0) GUICtrlSetState(-1, $GUI_DISABLE) $cmdDelete = GUICtrlCreateButton("Delete", 1170, 112, 92, 31, 0) GUICtrlSetState(-1, $GUI_DISABLE) $cmdSave = GUICtrlCreateButton("Save", 1170, 148, 92, 31, 0) $cmdCancel = GUICtrlCreateButton("Cancel", 1170, 184, 92, 31, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState($KeyW, $GUI_FOCUS) GUISetState(@SW_SHOW) #cs ;Now trying to detect the index of highlighted item in the ListView ;From 'A Beginner’s Guide To Melba23’s GUIListViewEx UDF': The UDF registers 4 messages automatically – if you already have message handlers in your script, do not register them again using the UDF function (set the relevant parameter of _GUIListViewEx_MsgRegister to False) but call the relevant UDF handler function (_GUIListViewEx_WM_NOTIFY_Handler) from within your existing handler. ;Here an example from Melba23: https://www.autoitscript.com/forum/topic/182492-guilistviewex-new-version-27-may-16/?do=findComment&comment=1325933 #ce GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') ;Register for editing & dragging ;prevent the UDF from initially registering the WM_NOTIFY _GUIListViewEx_MsgRegister(False) Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Shtdown() GUIDelete( $hGui ) Exit Case $GUI_EVENT_MINIMIZE ;; -4 _GUI_ToTray() Case $KeyW OnFilt() Case $cmdNext cmdNext_Click() Case $cmdPrev cmdPrev_Click() Case $cmdFirst cmdFirst_Click() Case $cmdLast cmdLast_Click() Case $cmdAdd cmdAdd_Click() Case $cmdEdit cmdEdit_CLick() Case $cmdDelete cmdDelete_Click() Case $cmdSave cmdSave_Click() Case $cmdCancel cmdCancel_Click() EndSwitch _GUIListViewEx_EditOnClick($iEditMode) WEnd ;From Zedna, in 'Highlighted item in the ListView?' ;https://www.autoitscript.com/forum/topic/96234-highlighted-item-in-the-listview/?do=findComment&comment=691927 Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ;From Melba23: pass the same parameters to the UDF handler as you received in your WM_NOTIFY handler: _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $IDFrom = DllStructGetData($tNMHDR, 'IDFrom') Local $Index = DllStructGetData($tNMHDR, 'Index') Local $Code = DllStructGetData($tNMHDR, 'Code') Switch $IDFrom Case $cLV Switch $Code Case $LVN_ITEMCHANGED Local $NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) ; if state has changed If BitAND(DllStructGetData($NMLISTVIEW, "Changed"), $LVIF_STATE) = $LVIF_STATE And _ DllStructGetData($NMLISTVIEW, "NewState") <> DllStructGetData($NMLISTVIEW, "OldState") Then ; take care of only newly selected items (not deselected ones) If BitAND(DllStructGetData($NMLISTVIEW, "NewState"), $LVIS_SELECTED) = $LVIS_SELECTED Then ;Local $Item = _GUICtrlListView_GetItem($cLV, $Index) ;ConsoleWrite("Index:" & @TAB & $Index & @CRLF & "Item:" & @TAB & $Item[3] & @CR) GUICtrlSetData($txtFirstName, $aLV[$Index][0]) GUICtrlSetData($txtMidName, $aLV[$Index][1]) GUICtrlSetData($txtLastName, $aLV[$Index][2]) GUICtrlSetData($txtMobile, $aLV[$Index][3]) GUICtrlSetData($txtHomePhone, $aLV[$Index][4]) GUICtrlSetData($txtAddress, $aLV[$Index][5]) GUICtrlSetData($lblRecPos, $Index + 1 & " of " & $n_RecCount) $n_RecPos = $Index EndIf EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func OnFilt() $sAnswer = GUICtrlRead($KeyW) GUICtrlSetData($KeyW, "") If $sAnswer <> "" Then $w = " WHERE N LIKE '%" & $sAnswer & "%'" $sSQL = "SELECT * FROM " & $tblname & $w $rst.Open($sSQL, $cn, $iCursorType, $iLockType, $iOptions) ;Issue the SQL query #cs Global $aLV[100][6] Local $f = 0 If Not $rst.EOF Then With $rst While Not .EOF ; repeat until End-Of-File (EOF) is reached $aLV[$f][0]=.Fields(0).Value $aLV[$f][1]=.Fields(1).Value $aLV[$f][2]=.Fields(2).Value $aLV[$f][3]=.Fields(3).Value $aLV[$f][4]=.Fields(4).Value $aLV[$f][5]=.Fields(5).Value .MoveNext ; Move To the Next record $f = $f + 1 WEnd EndWith EndIf $rst.Close $n_RecCount = UBound($aLV) ReDim $aLV[$f][6] #ce If $rst.EOF = True Then $rst.Close Return -3 EndIf Global $aLV = $rst.GetRows() $rst.Close $n_RecCount = UBound($aLV) Else $n_RecCount = 0 EndIf If $n_RecCount = 0 Then cmdAdd_Click() Else ;reload the ListView with new data, first clear the current content _GUICtrlListView_DeleteAllItems($cLV) ;close it within the UDF _GUIListViewEx_Close(0) ;reload the ListView with the new data _GUICtrlListView_AddArray($cLV, $aLV) ;Initiate LVEx - using filling array $iLV = _GUIListViewEx_Init($cLV, $aLV, 0, 0, True, 4) ;Set all columns editable _GUIListViewEx_SetEditStatus($iLV, "*") KeysSetup(0) cmdFirst_Click() EndIf EndFunc Func ShowData() If $n_RecCount = 0 Then ; Blank Table GUICtrlSetData($lblRecPos, "") GUICtrlSetData($txtFirstName, "") GUICtrlSetData($txtMidName, "") GUICtrlSetData($txtLastName, "") GUICtrlSetData($txtMobile, "") GUICtrlSetData($txtHomePhone, "") GUICtrlSetData($txtAddress, "") Return EndIf GUICtrlSetData($lblRecPos, $n_RecPos + 1 & " of " & $n_RecCount) GUICtrlSetData($txtFirstName, $aLV[$n_RecPos][0]) GUICtrlSetData($txtMidName, $aLV[$n_RecPos][1]) GUICtrlSetData($txtLastName, $aLV[$n_RecPos][2]) GUICtrlSetData($txtMobile, $aLV[$n_RecPos][3]) GUICtrlSetData($txtHomePhone, $aLV[$n_RecPos][4]) GUICtrlSetData($txtAddress, $aLV[$n_RecPos][5]) EndFunc Func cmdAdd_Click() $n_RecCount = 0 ShowData() KeysSetup(1) GUICtrlSetState($txtFirstName, $GUI_FOCUS) EndFunc Func cmdEdit_Click() $InStr = GUICtrlRead($txtFirstName) KeysSetup(1) EndFunc Func cmdCancel_Click() If $n_RecCount = 0 Then ; Blank Table Return EndIf ShowData() KeysSetup(0) GUICtrlSetState($KeyW, $GUI_FOCUS) EndFunc Func cmdSave_Click() If $InStr <> "" Then $sSQL = "DELETE FROM Tel WHERE N = '" & $InStr & "'" $rst.Open($sSQL, $cn, $iCursorType, $iLockType, $iOptions) EndIf $sSQL = "INSERT INTO Tel (N, T1, T2, T3, T4, D) VALUES ('" & GUICtrlRead($txtFirstName) & "', '" & GUICtrlRead($txtMidName) & "', '" & GUICtrlRead($txtLastName) & "', '" & GUICtrlRead($txtMobile) & "', '" & GUICtrlRead($txtHomePhone) & "', '" & GUICtrlRead($txtAddress) & "')" $rst.Open($sSQL, $cn, $iCursorType, $iLockType) KeysSetup(0) GUICtrlSetState($KeyW, $GUI_FOCUS) EndFunc Func cmdDelete_Click() If 6 = MsgBox(32 + 4, "Delete", "Are you sure delete the current record Permanently?") Then $sSQL = "DELETE FROM Tel WHERE N = '" & GUICtrlRead($txtFirstName) & "'" $rst.Open($sSQL, $cn, $iCursorType, $iLockType) $n_RecCount = 0 ShowData() KeysSetup(1) EndIf GUICtrlSetState($KeyW, $GUI_FOCUS) EndFunc Func cmdNext_Click() $n_RecPos = $n_RecPos + 1 If $n_RecPos = $n_RecCount Then $n_RecPos = $n_RecCount - 1 If $n_RecPos < 0 Then $n_RecPos = 0 ShowData() GUICtrlSetState($KeyW, $GUI_FOCUS) EndFunc Func cmdPrev_Click() $n_RecPos = $n_RecPos - 1 If $n_RecPos < 0 Then $n_RecPos = 0 ShowData() GUICtrlSetState($KeyW, $GUI_FOCUS) EndFunc Func cmdFirst_Click() $n_RecPos = 0 ShowData() EndFunc Func cmdLast_Click() $n_RecPos = $n_RecCount -1 ShowData() GUICtrlSetState($KeyW, $GUI_FOCUS) EndFunc Func Shtdown() ; Close conexion $rst = 0 ; Release the recordset object $cn = 0 ; Release the connection object EndFunc Func _GUI_ToTray() GUISetState(@SW_HIDE, $hGui) TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "_GUI_Restore") TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "_Quit") TrayTip($sTitle, "Left click to restore" & @CRLF & "Right click to Exit", 5, 1) TraySetToolTip($sTitle & @CRLF & @CRLF & "Left click to restore" & @CRLF & "Right click to Exit") TraySetToolTip("") Opt("TrayIconHide", 0) Return $hGui EndFunc ;==>_GUI_ToTray Func _GUI_Restore() GUISetState(@SW_SHOW, $hGui) WinActivate($hGui) TraySetState(2) Opt("TrayIconHide", 1) EndFunc ;==>_GUI_Restore Func _Quit() Shtdown() Exit EndFunc ;==>_Quit Func KeysSetup($lngMode) Local $nState1, $nState2 Local $n_State, $n_Color, $n_Cursor If $lngMode = 1 Then ; Blank Table $nState1 = $GUI_ENABLE $nState2 = $GUI_DISABLE $n_State = Not $ES_READONLY $n_Color = 0x000000 $n_Cursor = 5 Else $nState1 = $GUI_DISABLE $nState2 = $GUI_ENABLE $n_State = $ES_READONLY $n_Color = 0x0000ff $n_Cursor = 2 EndIf GUICtrlSetState($cmdSave, $nState1) GUICtrlSetState($cmdAdd, $nState2) GUICtrlSetState($cmdEdit, $nState2) GUICtrlSetState($cmdCancel, $nState1) GUICtrlSetState($cmdDelete, $nState2) GUICtrlSetState($cmdNext, $nState2) GUICtrlSetState($cmdPrev, $nState2) GUICtrlSetState($cmdFirst, $nState2) GUICtrlSetState($cmdLast, $nState2) ; Screen Fields GUICtrlSetStyle($txtFirstName, $n_State) GUICtrlSetStyle($txtMidName, $n_State) GUICtrlSetStyle($txtLastName, $n_State) GUICtrlSetStyle($txtMobile, $n_State) GUICtrlSetStyle($txtHomePhone, $n_State) GUICtrlSetStyle($txtAddress, $n_State) GUICtrlSetColor($txtFirstName, $n_Color) GUICtrlSetColor($txtMidName, $n_Color) GUICtrlSetColor($txtLastName, $n_Color) GUICtrlSetColor($txtMobile, $n_Color) GUICtrlSetColor($txtHomePhone, $n_Color) GUICtrlSetColor($txtAddress, $n_Color) GUICtrlSetColor($txtFirstName, $n_Color) GUICtrlSetColor($txtMidName, $n_Color) GUICtrlSetColor($txtLastName, $n_Color) GUICtrlSetColor($txtMobile, $n_Color) GUICtrlSetColor($txtHomePhone, $n_Color) GUICtrlSetColor($txtAddress, $n_Color) GUICtrlSetCursor($txtFirstName, $n_Cursor) GUICtrlSetCursor($txtMidName, $n_Cursor) GUICtrlSetCursor($txtLastName, $n_Cursor) GUICtrlSetCursor($txtMobile, $n_Cursor) GUICtrlSetCursor($txtHomePhone, $n_Cursor) GUICtrlSetCursor($txtAddress, $n_Cursor) EndFunc Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) ; high word Local $nID = BitAND($wParam, 0xFFFF) ; low word Local $hCtrl = $lParam Switch $nID Case $idExit Shtdown() Exit Case $idFavorites Msgbox(0, "", "This is only an example") Case $idCustomFavs1 Msgbox(0, "", "This would be same action") Case $idCustomFavs2 Msgbox(0, "", "Last example") EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _ErrADODB() Msgbox(0,"ADODB COM Error","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $errADODB.description & @CRLF & _ "err.windescription:" & @TAB & $errADODB.windescription & @CRLF & _ "err.number is: " & @TAB & hex($errADODB.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $errADODB.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $errADODB.scriptline & @CRLF & _ "err.source is: " & @TAB & $errADODB.source & @CRLF & _ "err.helpfile is: " & @TAB & $errADODB.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $errADODB.helpcontext _ ) Local $err = $errADODB.number If $err = 0 Then $err = -1 EndFunc This is the access database to reproduce the example: db.mdb Edited December 20, 2016 by robertocm Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 10, 2016 Author Moderators Share Posted December 10, 2016 robertocm, After a quick glance at your script I can see why you might have those 2 problems. 1. You never call the _GUIListViewEx_MsgRegister function to allow the UDF to access the user events required for most of its functions. You need to add a line calling that function just before your idle loop. 2. The default delimiter for ListView columns in AutoIt is the "|" character - so having that character within one of the elements means that the UDF believes that there are more columns than there should be and so fires an error. I suggest operating on the database return value to replace any "|" characters with another before loading the data into the ListView - then when you try to read it the UDF will not get confused. An alternative might be to use Opt("GUIDataSeparatorChar", "New_Char") to set the default delimiter to another character, but I would recommend trying to amend your own data first as it is less problematic for the rest of AutoIt. Try those 2 fixes and see if the script works correctly. if you still have problems, please supply some sample data as passed to the UDF as I do not have Access as so cannot run the code as it stands. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
robertocm Posted December 11, 2016 Share Posted December 11, 2016 21 hours ago, Melba23 said: Try those 2 fixes and see if the script works correctly. ... Dear Melba23, Many Thanks, I have updated the code of the example, and regarding the pipe character, i'll just try to avoid using it. There's another issue: When the listview is created it can be edited with BackSpace hotkey, but reloading the data (following the steps of your Beginner's Guide) seems to cause the BackSpace stops working for editing. Tested with this code: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" $hGUI = GUICreate("", 500, 340) $cReLoad = GUICtrlCreateButton("Reload ListView", 150, 300, 150, 30) $cExit = GUICtrlCreateButton("Exit", 350, 300, 110, 30) ; Create ListView $cLV = GUICtrlCreateListView("Zero Column|One Column|Two Column|Three Column", 10, 30, 480, 260, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS)) For $i = 0 To 3 _GUICtrlListView_SetColumnWidth($cLV, $i, 100) Next ;Add data For $i = 0 To 5 GUICtrlCreateListViewItem("Item 0-" & $i & "|SubItem 1-" & $i & "|SubItem 2-" & $i & "|SubItem 3-" & $i, $cLV) Next ;Read the current ListView content $aLV = _GUIListViewEx_ReadToArray($cLV) ; Inititate the ListView using that content $iLV = _GUIListViewEx_Init($cLV, $aLV) ;Set all column editable _GUIListViewEx_SetEditStatus($iLV, "*") ;Register for editing & dragging _GUIListViewEx_MsgRegister() GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE, $cExit Exit Case $cReLoad Reload_ListView() EndSwitch ; Allow edit on double click $aRet = _GUIListViewEx_EditOnClick() WEnd Func Reload_ListView() ;first clear the current content _GUICtrlListView_DeleteAllItems($cLV) ;close it within the UDF _GUIListViewEx_Close(0) ;reload the ListView with the same data _GUICtrlListView_AddArray($cLV, $aLV) ;Initiate LVEx - using same filling array _GUIListViewEx_Init($cLV, $aLV) ;Set all columns editable _GUIListViewEx_SetEditStatus($iLV, "*") 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