MyEarth Posted October 29, 2016 Share Posted October 29, 2016 expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form = GUICreate("Form", 346, 280, 192, 124) $iListView = GUICtrlCreateListView("A|B|C|D|", 8, 8, 329, 257) $hListview = GUICtrlGetHandle($iListView) $hHeader =_GUICtrlListView_GetHeader($iListview) GUICtrlSendMsg($iListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_HEADERDRAGDROP)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 50) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iCode Local $tNMHDR, $tNMHEADER, $tNMHDFILTERBTNCLICK, $tNMHDDISPINFO $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hHeader Switch $iCode Case $HDN_ENDDRAG ; Sent by a header control when a drag operation has ended on one of its items $tNMHEADER = DllStructCreate($tagNMHEADER, $ilParam) ;~ ConsoleWrite("$HDN_ENDDRAG" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @LF & _ ;~ "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @LF & _ ;~ "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @LF & _ ;~ "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @LF & _ ;~ "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button")) Local $sColumnOrder = _GUICtrlListView_GetColumnOrder($iListView) ConsoleWrite($sColumnOrder & @CRLF) Return False ; To allow the control to automatically place and reorder the item EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Try to move the column D to C but is doing with whatever column. The result is: 0|1|2|3 But is wrong! The correct one is 0|1|3|2 $HDN_ENDDRAG ; Sent by a header control when a drag operation has ended on one of its items So why since i'll do _GUICtrlListView_GetColumnOrder when is end the draggin operation i'll get the previus order of the column? What i have miss this time? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 29, 2016 Moderators Share Posted October 29, 2016 MyEarth, As so often with ListViews, you need to wait for the handler to exit before getting the new column order: expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Global $fColDrag = False $Form = GUICreate("Form", 346, 280, 192, 124) $iListView = GUICtrlCreateListView("A|B|C|D|", 8, 8, 329, 257) $hListview = GUICtrlGetHandle($iListView) $hHeader =_GUICtrlListView_GetHeader($iListview) GUICtrlSendMsg($iListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_HEADERDRAGDROP)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 50) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $fColDrag Then $fColDrag = False Local $sColumnOrder = _GUICtrlListView_GetColumnOrder($iListView) ConsoleWrite($sColumnOrder & @CRLF) EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iCode Local $tNMHDR, $tNMHEADER, $tNMHDFILTERBTNCLICK, $tNMHDDISPINFO $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hHeader Switch $iCode Case $HDN_ENDDRAG ; Sent by a header control when a drag operation has ended on one of its items $fColDrag = True Return False ; To allow the control to automatically place and reorder the item EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY That works fine for me. 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...
MyEarth Posted October 29, 2016 Author Share Posted October 29, 2016 Thanks Melba, that will complicate the things as always but ok 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