Sign in to follow this  
Followers 0
duketrapp

Kill Drag Ability From Listview

13 posts in this topic

#1 ·  Posted (edited)

Hi again...

I have a small prob with a listview item.. cant find any threads about that...maybe u can help me out..

prob is:

i have a listview filled with some listviewitems.. when the user select an item of the listview, different other controls get there specific settings.. = works great

..BUT.. when u click on an item in listview, than hold the mousebutton down and move the mouse in any direction (curser change to drag/drop icon) over the listview and release the selected item, the other controls DONT get there settings!!!..

i thnk the prob is that the listview dont send the id from the click on the listviewitem, when u click,drag and release the listviewitem... the listview thnks its an drag/drop action and dont notice the click...

..so i thinked about it and best possible choice for me is to completely DISABLE the DRAG ABILITY of the listview.. how can i do that???... i found some comands that set the ability to accept droped files but no comands for disable the ability of a control to be "draggable"... :think:

.. i hope u understand my prob.. maybe u know a hint...

thnks for help..

salute..

Edited by duketrapp

Share this post


Link to post
Share on other sites



from styles

WS_EX_ACCEPTFILES 0x00000010 Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_DROPACCEPTED state set by GUICtrlSetState.

make sure that this "WS_EX_ACCEPTFILES" is NOT in the create line

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

from styles

make sure that this "WS_EX_ACCEPTFILES" is NOT in the create line

8)

:think: hey man.. ive seen that in docu but it says "Allow an edit or input control within the created GUI window to >>>!!!!"""RECEIVE"""!!!!<<< filenames".. Thats not my prob.....i want to kill the ability to GRAB an item out of the list....

check this out...

#include <GUIConstants.au3>

GUICreate("check", 300, 300, 1, 1)
    GUICtrlSetState( -1, $GUI_SHOW)
        
        $check_list = GUICtrlCreateListView("col1|col2|col3", 5, 5, 290, 150, $LVS_SHOWSELALWAYS+$LVS_SINGLESEL)
        $1 = GUICtrlCreateListViewItem ( "text1|text1|text1", $check_list )
        $2 = GUICtrlCreateListViewItem ( "text2|text2|text2", $check_list )
        
        $getit = GUICtrlCreateLabel("test", 5, 200, 290, 20)

GUISetState ()

Do
  $msg = GuiGetMsg ()
  
    Select
        Case $msg = $1
            GUICtrlSetData($getit, GUICtrlRead($1))
        Case $msg = $2
            GUICtrlSetData($getit, GUICtrlRead($2))
    EndSelect
     
Until $msg = $GUI_EVENT_CLOSE

..u see i try to create without "WS_EX_ACCEPTFILES" and it still not workin.... click on "text1" listviewitem, DONT release the mousebutton and pull the item under the list... label text will not change... voila... still shit.. :(

.. other ideas?..

Edited by duketrapp

Share this post


Link to post
Share on other sites

Requires beta and uses listview events

; Events - ListView
#include <GuiConstants.au3>;Inclusion file for the GUI interface controls
#include <GuiListView.au3>

Global $ListView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1

;ListView Events
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
;~ Global Const $NM_RETURN = ($NM_FIRST - 4)
;~ Global Const $NM_RCLICK = ($NM_FIRST - 5)
;~ Global Const $NM_RDBLCLK = ($NM_FIRST - 6)
;~ Global Const $NM_SETFOCUS = ($NM_FIRST - 7)
;~ Global Const $NM_KILLFOCUS = ($NM_FIRST - 8)
;~ Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12)
;~ Global Const $NM_HOVER = ($NM_FIRST - 13)
;~ Global Const $NM_NCHITTEST = ($NM_FIRST - 14)
;~ Global Const $NM_KEYDOWN = ($NM_FIRST - 15)
;~ Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16)
;~ Global Const $NM_SETCURSOR = ($NM_FIRST - 17)
;~ Global Const $NM_CHAR = ($NM_FIRST - 18)
;~ Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19)
Global Const $LVN_FIRST = -100
Global Const $LVN_BEGINDRAG = ($LVN_FIRST - 9)

#endregion End Global variables

Opt("WinTitleMatchMode", 2)

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX))

$ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 100)
_GUICtrlListViewSetColumnWidth ($ListView, 1, 100)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("Name 1|Category 1", $ListView)
GUICtrlCreateListViewItem("Name 2|Category 2", $ListView)
GUISetState()

;Register WM_NOTIFY  events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
   
   $msg = GUIGetMsg()
   
   Switch $msg
      
   ;-----------------------------------------------------------------------------------------
   ;This case statement exits and updates code if needed
      Case $GUI_EVENT_CLOSE
         Exit
         
         
      ;-----------------------------------------------------------------------------------------
      ;put all the misc. stuff here
        Case Else
        ;;;
   EndSwitch
WEnd

Func ListView_Click()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader ("$NM_CLICK"))
;----------------------------------------------------------------------------------------------
EndFunc  ;==>ListView_Click

Func ListView_DoubleClick()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader ("$NM_DBLCLK"))
;----------------------------------------------------------------------------------------------
    MsgBox(0,"Double Clicked", _GUICtrlListViewGetItemText ($ListView, _GUICtrlListViewGetSelectedIndices($ListView)))
EndFunc  ;==>ListView_DoubleClick

;
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code, $tagNMLISTVIEW
    $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
    Case $wParam = $ListView
        Select
            Case $event = $NM_CLICK
                ListView_Click ()
            Case $event = $NM_DBLCLK
                ListView_DoubleClick ()
            Case Else
                $tagNMLISTVIEW = DllStructCreate("int;int;int;int;int;uint;uint;uint;int;int;int", $lParam)
                Select
                    Case $event = $LVN_BEGINDRAG
                        ConsoleWrite("Drag Event:" & @LF)
                        ConsoleWrite("Item: " & _GUICtrlListViewGetItemText ($ListView, DllStructGetData($tagNMLISTVIEW,4)) & @LF)
                EndSelect
        EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc  ;==>WM_Notify_Events

Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
EndFunc  ;==>_DebugHeader

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Requires beta and uses listview events

.. :) .. i thnk its a lot of goodlookin stuff over there but can u give ur hint a bit more transparency.. :think: .. im still learnin autoit.. so... beta is ok.. im usin it... and the code u posted... when i look at it i thnk my problem should be killed here :

Select
                    Case $event = $LVN_BEGINDRAG
                        ConsoleWrite("Drag Event:" & @LF)
                        ConsoleWrite("Item: " & _GUICtrlListViewGetItemText ($ListView, DllStructGetData($tagNMLISTVIEW,4)) & @LF)
                EndSelect

..but... :( ..i realy dont know what to do with this.. :"> .. so maybe u can give me a small advise...

..btw .. i thought this would be easy.. but.. when its that kínda difficult to kill the ability i thnk i can survive with this small bug in my script.. cause i dont want start and change anythng in the autoit standards or includes if this affects any other control devices... maybe i need drag and drop ability later in an listview...

Edited by duketrapp

Share this post


Link to post
Share on other sites

.. :) .. i thnk its a lot of goodlookin stuff over there but can u give ur hint a bit more transparency.. :think: .. im still learnin autoit.. so... beta is ok.. im usin it... and the code u posted... when i look at it i thnk my problem should be killed here :

Select
                    Case $event = $LVN_BEGINDRAG
                        ConsoleWrite("Drag Event:" & @LF)
                        ConsoleWrite("Item: " & _GUICtrlListViewGetItemText ($ListView, DllStructGetData($tagNMLISTVIEW,4)) & @LF)
                EndSelect

..but... :( ..i realy dont know what to do with this.. :"> .. so maybe u can give me a small advise...

..btw .. i thought this would be easy.. but.. when its that kínda difficult to kill the ability i thnk i can survive with this small bug in my script.. cause i dont want start and change anythng in the autoit standards or includes if this affects any other control devices... maybe i need drag and drop ability later in an listview...

I don't know how to kill the ability, maybe Holger does, but you said the info wasn't filling in when the user clicked and dragged, I was showing you that you could get the info, then it would be up to you to use that info to fill in what needs to be done.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

...it would be up to you to use that info to fill in what needs to be done.

y..... i knowed that u say somethng like that... :( .. i can do a lot with the autoit comands and scite till now... but this code above looks like chinese for me.. :)

..but thnks a lot for ur hint... maybe ill find a way when im deeper in autoit :think:

Share this post


Link to post
Share on other sites

y..... i knowed that u say somethng like that... :( .. i can do a lot with the autoit comands and scite till now... but this code above looks like chinese for me.. :)

..but thnks a lot for ur hint... maybe ill find a way when im deeper in autoit :think:

Sorry it looks chinese for you, but you didn't provide any code to adapt it to.

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Sorry it looks chinese for you, but you didn't provide any code to adapt it to.

Gary

:think:

.. look above..

#include <GUIConstants.au3>

GUICreate("check", 300, 300, 1, 1)
    GUICtrlSetState( -1, $GUI_SHOW)
        
        $check_list = GUICtrlCreateListView("col1|col2|col3", 5, 5, 290, 150, $LVS_SHOWSELALWAYS+$LVS_SINGLESEL)
        $1 = GUICtrlCreateListViewItem ( "text1|text1|text1", $check_list )
        $2 = GUICtrlCreateListViewItem ( "text2|text2|text2", $check_list )
        
        $getit = GUICtrlCreateLabel("test", 5, 200, 290, 20)

GUISetState ()

Do
  $msg = GuiGetMsg ()
  
    Select
        Case $msg = $1
            GUICtrlSetData($getit, GUICtrlRead($1))
        Case $msg = $2
            GUICtrlSetData($getit, GUICtrlRead($2))
    EndSelect
     
Until $msg = $GUI_EVENT_CLOSE

..no code?... :(

Share this post


Link to post
Share on other sites

; Events - ListView
#include <GuiConstants.au3>;Inclusion file for the GUI interface controls
#include <GuiListView.au3>

Global $ListView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1

;ListView Events
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
;~ Global Const $NM_RETURN = ($NM_FIRST - 4)
;~ Global Const $NM_RCLICK = ($NM_FIRST - 5)
;~ Global Const $NM_RDBLCLK = ($NM_FIRST - 6)
;~ Global Const $NM_SETFOCUS = ($NM_FIRST - 7)
;~ Global Const $NM_KILLFOCUS = ($NM_FIRST - 8)
;~ Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12)
;~ Global Const $NM_HOVER = ($NM_FIRST - 13)
;~ Global Const $NM_NCHITTEST = ($NM_FIRST - 14)
;~ Global Const $NM_KEYDOWN = ($NM_FIRST - 15)
;~ Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16)
;~ Global Const $NM_SETCURSOR = ($NM_FIRST - 17)
;~ Global Const $NM_CHAR = ($NM_FIRST - 18)
;~ Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19)
Global Const $LVN_FIRST = -100
Global Const $LVN_BEGINDRAG = ($LVN_FIRST - 9)

#endregion End Global variables

Opt("WinTitleMatchMode", 2)

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, -1,-1, BitOR($WS_THICKFRAME, $WS_SIZEBOX))

$ListView = GUICtrlCreateListView("Entry Name|Category", 5, 5, 215, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 100)
_GUICtrlListViewSetColumnWidth ($ListView, 1, 100)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("Name 1|Category 1", $ListView)
GUICtrlCreateListViewItem("Name 2|Category 2", $ListView)
$getit = GUICtrlCreateLabel("test", 5, 290, 215, 20)
GUISetState()

;Register WM_NOTIFY  events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
   
   $msg = GUIGetMsg()
   
   Switch $msg
      
  ;-----------------------------------------------------------------------------------------
  ;This case statement exits and updates code if needed
      Case $GUI_EVENT_CLOSE
         Exit
         
         
     ;-----------------------------------------------------------------------------------------
     ;put all the misc. stuff here
        Case Else
       ;;;
   EndSwitch
WEnd

Func ListView_Click()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader ("$NM_CLICK"))
;----------------------------------------------------------------------------------------------
EndFunc ;==>ListView_Click

Func ListView_DoubleClick()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader ("$NM_DBLCLK"))
;----------------------------------------------------------------------------------------------
    MsgBox(0,"Double Clicked", _GUICtrlListViewGetItemText ($ListView, _GUICtrlListViewGetSelectedIndices($ListView)))
EndFunc ;==>ListView_DoubleClick

;
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code, $tagNMLISTVIEW
    $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
    Case $wParam = $ListView
        Select
            Case $event = $NM_CLICK
                ListView_Click ()
            Case $event = $NM_DBLCLK
                ListView_DoubleClick ()
            Case Else
                $tagNMLISTVIEW = DllStructCreate("int;int;int;int;int;uint;uint;uint;int;int;int", $lParam)
                Select
                    Case $event = $LVN_BEGINDRAG
                        GUICtrlSetData($getit,_GUICtrlListViewGetItemText ($ListView, DllStructGetData($tagNMLISTVIEW,4)))
                EndSelect
        EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc ;==>WM_Notify_Events

Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
EndFunc ;==>_DebugHeader


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

:think: .. y works fine.. thnks for ur help... there r still few chinese parameters for me, but i thnks ill get this after a time... :(

btw... the debug part... is that just for testin output or is it needed for this to run correctly?..

Share this post


Link to post
Share on other sites

:think: .. y works fine.. thnks for ur help... there r still few chinese parameters for me, but i thnks ill get this after a time... :(

btw... the debug part... is that just for testin output or is it needed for this to run correctly?..

debug or not to debug, just for testing, if you take it out, make sure you remove all references to it.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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