Peter89 Posted March 28, 2014 Posted March 28, 2014 Hi All, I have 2 Listviews with some columns and want to move Items from the right one to the left. This is working until I've edited one of the left entries via double click function. I think it has something todo with GUICtrlGetHandle but im not soure about it.. Facts: Listviews are $searchList & $selectList (drag from searchList to selectList); Edit happens in $selectList I've copied the related code below.. Thanks and best regards.. Peter expandcollapse popup$searchList = GUICtrlCreateListView("", 560, 352, 449, 344,BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS ), BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) $selectList = GUICtrlCreateListView("", 40, 352, 489, 266,BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_EDITLABELS), BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) GUICtrlSetState($selectList, $GUI_DROPACCEPTED) GUISetOnEvent($GUI_EVENT_DROPPED,DragnDrop) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Func DragnDrop() ;$aItem = _GUICtrlListView_GetItemTextArray($listview) ;_ArrayDisplay($aItem) $sItem = _GUICtrlListView_GetItemTextString($searchList) ; GUICtrlSetData($list2,$sItem) GUICtrlCreateListViewItem("1|"&$sItem,$selectList) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $selectList If Not IsHWnd($selectList) Then $hWndListView = GUICtrlGetHandle($selectList) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK $fDblClk = True Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW 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 While 1 Sleep(100) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch ; If an item was double clicked If $fDblClk Then $fDblClk = False If Not IsHWnd($selectList) Then $selectList = GUICtrlGetHandle($selectList) $iSelected = _GUICtrlListView_GetSelectedIndices($selectList) If $iSelected <> "" Then _GUICtrlListView_EditLabel($selectList, $iSelected) EndIf WEnd
Peter89 Posted March 28, 2014 Author Posted March 28, 2014 (edited) Hi All, I have 2 Listviews with some columns and want to move Items from the right one to the left. This is working until I've edited one of the left entries via double click function. I think it has something todo with GUICtrlGetHandle but im not soure about it.. Facts: Listviews are $searchList & $selectList (drag from searchList to selectList); Edit happens in $selectList I've copied the related code below.. Thanks and best regards.. Peter expandcollapse popup$searchList = GUICtrlCreateListView("", 560, 352, 449, 344,BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS ), BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) $selectList = GUICtrlCreateListView("", 40, 352, 489, 266,BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_EDITLABELS), BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) GUICtrlSetState($selectList, $GUI_DROPACCEPTED) GUISetOnEvent($GUI_EVENT_DROPPED,DragnDrop) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Func DragnDrop() ;$aItem = _GUICtrlListView_GetItemTextArray($listview) ;_ArrayDisplay($aItem) $sItem = _GUICtrlListView_GetItemTextString($searchList) ; GUICtrlSetData($list2,$sItem) GUICtrlCreateListViewItem("1|"&$sItem,$selectList) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $selectList If Not IsHWnd($selectList) Then $hWndListView = GUICtrlGetHandle($selectList) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK $fDblClk = True Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW 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 While 1 Sleep(100) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch ; If an item was double clicked If $fDblClk Then $fDblClk = False If Not IsHWnd($selectList) Then $selectList = GUICtrlGetHandle($selectList) $iSelected = _GUICtrlListView_GetSelectedIndices($selectList) If $iSelected <> "" Then _GUICtrlListView_EditLabel($selectList, $iSelected) EndIf WEnd Edited March 28, 2014 by Peter89
Moderators Melba23 Posted March 29, 2014 Moderators Posted March 29, 2014 Peter89,Just the one thread at a time please. 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
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