Sign in to follow this  
Followers 0
Peter89

Edit Listview function kills drag'n'drop

3 posts in this topic

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
 

$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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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
 

$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 by Peter89

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0