BrewManNH Posted December 4, 2010 Posted December 4, 2010 Greetings PsaltyDS and Ghost21 there are two issues the guictrlgethandle() call for the listview is missing, so $hLV is set to control ID replace this line in _Fill() _GUICtrlListView_AddItem($hLV, $aSplit[1]) with _GUICtrlListView_AddItem($cLV, $aSplit[1], -1, _GUICtrlListView_GetItemCount($cLV) + 9999) I tried it this way and it still wouldn't sort when using the UDF add item functions. <these comments are relevant as of AU3 version 3.3.6.1> the help file remarks for _GUICtrlListView_RegisterSortCallBack omit to mention that you have to add the current item count and 9999 to the items LVITEM struct Param element when creating items for sorting to work, This shouldn't be necessary. When you call the additem UDF it calls internally the InsertItem function which automatically sets the index to 999999999. If $iIndex = -1 Then $iIndex = 999999999 **_GUICtrlListView_SortItems is currently coded for a handle only, unlike many LV udfs that take both a handle and control ID Actually, this function takes both, it will convert the CID to a handle if you pass it the CID. **these two functions are special: use a handle for UDF added items - use a control id for GUICtrlCreateListViewItem added items _GUICtrlListView_DeleteItem($hWnd, $iIndex) _GUICtrlListView_DeleteAllItems($hWnd) I pulled out a lot of hair before I found out that these worked vastly different depending upon whether you used a handle of CID, because I tried to use a CID with _DeleteItem(. It caused my media player's next and previous buttons to stop working right until I figured that part out. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
rover Posted December 5, 2010 Posted December 5, 2010 Greetings BrewManNH I tried it this way and it still wouldn't sort when using the UDF add item functions. sorting works for me with both native and udf listview with that example I posted $cLV = GUICtrlCreateListView() $hLV = GUICtrlGetHandle($cLV) swap $hLV = _GUICtrlListView_Create() $cLV = $hLV $hLV being used to compare to $hWndFrom in WM_NOTIFY This shouldn't be necessary. When you call the additem UDF it calls internally the InsertItem function which automatically sets the index to 999999999. If $iIndex = -1 Then $iIndex = 999999999that 999999999 sets the index to the next number the line of code I posted is from the help file for _GUICtrlListView_RegisterSortCallBack and is seen in examples posted on the forum it sets the param element of an item, not the index Item param in native AutoIT stores the pseudo control id for added lv items in native listview using GUICtrlCreateListViewItem. when using sorting and using the udfs to add items, param must be set above max value used for native listview. this is 9999 + new index of item Actually, this function takes both, it will convert the CID to a handle if you pass it the CID.Re _GUICtrlListView_SortItems : I should have been clearer (was going to reword that after posting, but left it, as OP has left this thread anyway) I was referring to native versus dllcall sendmesage in udfs in this case the function aquires the listview sysheader control handle so ctrl ids do not apply internally, as all sendmessage calls use handle - this was purely about optimization with listview udfs - to use GuiCtrlSendMsg() wherever possible. I pulled out a lot of hair before I found out that these worked vastly different depending upon whether you used a handle of CID, because I tried to use a CID with _DeleteItem(. It caused my media player's next and previous buttons to stop working right until I figured that part out. I recall the discussions on the forum about this, especially before those functions where rewritten to accommodate handle and IDs in the help file, there are no usage directions in the remarks section instead the remarks are in the example for those two functions they should be in the remarks section as well. Cheers I see fascists...
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