Jump to content

HDN_ENDDRAG - How to check where the item is dropped?


MrCreatoR
 Share

Recommended Posts

Hi,

Simple question here - How to "know" where the column item was dropped? (when using the $LVS_EX_HEADERDRAGDROP style).

Here is an example that shows when user start to drag the item and when it's dropped (we can see the item that was selected to drop), but how to check where to it was dropped, in what position (index)?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
;

$GUI = GUICreate("Restrict Drag & Drop Columns", 420, 240)

$ListView = GUICtrlCreateListView("Column1|Column2|Column3|Column4|Column5", 20, 20, 380, 200, _
    BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOSORTHEADER), _
    BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_EVENTS")

GUISetState(@SW_SHOW)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func WM_NOTIFY_EVENTS($hWndGUI, $MsgID, $wParam, $lParam)
    Local $TagNMHDR = DllStructCreate("int hWndFrom;int iIDFrom;int iCode;int iItem;int iButton;ptr pitem", $lParam)
    If @error Then Return $GUI_RUNDEFMSG
    
    Local $hWndFrom = DllStructGetData($TagNMHDR, "hWndFrom")
    Local $iEvent = DllStructGetData($TagNMHDR, "iCode")
    Local $iItem = DllStructGetData($TagNMHDR, "iItem")
    
    Local $hLV_Header = GUICtrlSendMsg($ListView, $LVM_GETHEADER, 0, 0)
    
    If $hLV_Header = $hWndFrom Then
        Switch $iEvent
            Case $HDN_BEGINDRAG
                ConsoleWrite("Begin drag item: " & $iItem & @CRLF) ;Here we can see only the item that is currently dragged
            Case $HDN_ENDDRAG
                ConsoleWrite("End drag item: " & $iItem & @CRLF) ;Here we can see only the item that was dropped (the same :( )
        EndSwitch
    EndIf
    
    Return $GUI_RUNDEFMSG
EndFunc

Any ideas? :P

P.S

I need it only because i want to restrict the drag & drop operation, so the user be able to drag & drop all items except the first one (Column1).

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

MrCreatoR

Hi friend! Hope this will help you:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIHeader.au3>
;

$GUI = GUICreate("Restrict Drag & Drop Columns", 420, 240)

$ListView = GUICtrlCreateListView("Column1|Column2|Column3|Column4|Column5", 20, 20, 380, 200, _
    BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOSORTHEADER), _
    BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))

$hLV_Header = GUICtrlSendMsg($ListView, $LVM_GETHEADER, 0, 0)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_EVENTS")

GUISetState(@SW_SHOW)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func WM_NOTIFY_EVENTS($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
   
    Local $hWndFrom = DllStructGetData($tNMHEADER, "hWndFrom")
    Local $iEvent = DllStructGetData($tNMHEADER, "Code")
    Local $iItem = DllStructGetData($tNMHEADER, "Item")
    
    Switch $hWndFrom
        Case $hLV_Header
            Switch $iEvent
                Case $HDN_BEGINDRAG
                    If $iItem = 0 Then Return 1
                Case $HDN_ENDDRAG
                    Local $tPOINT = _WinAPI_GetMousePos(True, $hLV_Header)
                    Local $iX = DllStructGetData($tPOINT, "X")
                    Local $iY = DllStructGetData($tPOINT, "Y")
                    
                    Local $aHit = _GUICtrlHeader_HitTest($hWndFrom, $iX, $iY)
                    
                    If ($aHit[0] = 0) Or ($aHit[0] = -1 And $aHit[10] = True) Then Return 1
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc

:P

Link to comment
Share on other sites

MrCreatoR

Hi friend! Hope this will help you:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIHeader.au3>
;

$GUI = GUICreate("Restrict Drag & Drop Columns", 420, 240)

$ListView = GUICtrlCreateListView("Column1|Column2|Column3|Column4|Column5", 20, 20, 380, 200, _
    BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOSORTHEADER), _
    BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))

$hLV_Header = GUICtrlSendMsg($ListView, $LVM_GETHEADER, 0, 0)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_EVENTS")

GUISetState(@SW_SHOW)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func WM_NOTIFY_EVENTS($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
   
    Local $hWndFrom = DllStructGetData($tNMHEADER, "hWndFrom")
    Local $iEvent = DllStructGetData($tNMHEADER, "Code")
    Local $iItem = DllStructGetData($tNMHEADER, "Item")
    
    Switch $hWndFrom
        Case $hLV_Header
            Switch $iEvent
                Case $HDN_BEGINDRAG
                    If $iItem = 0 Then Return 1
                Case $HDN_ENDDRAG
                    Local $tPOINT = _WinAPI_GetMousePos(True, $hLV_Header)
                    Local $iX = DllStructGetData($tPOINT, "X")
                    Local $iY = DllStructGetData($tPOINT, "Y")
                    
                    Local $aHit = _GUICtrlHeader_HitTest($hWndFrom, $iX, $iY)
                    
                    If ($aHit[0] = 0) Or ($aHit[0] = -1 And $aHit[10] = True) Then Return 1
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc

:P

Another nice solution rasim. :(

The section

Case $HDN_BEGINDRAG
                    If $iItem = 0 Then Return 1

Doesn't works correctly for me despite what msdn says it is supposed to do. If you want to prevent a column being dragged then this works for me.

Case $HDN_BEGINDRAG
                    If $iItem = $FixedItem Then MouseUp("Left")
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks again rasim!

BTW, i tried with HitTest function too, but i had problems with the coords checking, i didn't thought about -1 and $aHT[10] :P

I changed a little the script, instead of using Mouse on iY position, i just used 5 (it is relative to Top position of header control), because when you drag the column you can do it under the header (when the mouse is under the header area), and the position will be not correct...

If you want to prevent a column being dragged then this works for me.

Thanks martin, good workaround :(

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIHeader.au3>
;

Global $iFixedColumn = 0

$GUI = GUICreate("Restrict Drag & Drop Columns", 420, 240)

$ListView = GUICtrlCreateListView("Column1|Column2|Column3|Column4|Column5", 20, 20, 380, 200, _
    BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOSORTHEADER), _
    BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))

$hLV_Header = GUICtrlSendMsg($ListView, $LVM_GETHEADER, 0, 0)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_EVENTS")

GUISetState(@SW_SHOW)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func WM_NOTIFY_EVENTS($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
    
    Local $hWndFrom = DllStructGetData($tNMHEADER, "hWndFrom")
    Local $iEvent = DllStructGetData($tNMHEADER, "Code")
    Local $iItem = DllStructGetData($tNMHEADER, "Item")
    
    Switch $hWndFrom
        Case $hLV_Header
            Switch $iEvent
                Case $HDN_BEGINDRAG
                    If $iItem = $iFixedColumn Then
                        MouseUp("Main")
                        Return 1
                    EndIf
                Case $HDN_ENDDRAG
                    Local $iOld_Opt_MCM = Opt("MouseCoordMode", 0)
                    
                    Local $iX = MouseGetPos(0)
                    
                    Opt("MouseCoordMode", $iOld_Opt_MCM)
                    
                    Local $aHit = _GUICtrlHeader_HitTest($hLV_Header, $iX, 5)
                    If ($aHit[0] = $iFixedColumn) Or ($aHit[0] = -1 And $aHit[10] = True) Then Return 1
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Hm, there is a problem with the MouseUp issue. If the columns are sortable, then obviously they sorted every time user trying to drag the fixed column :(

I fixed it by preliminary mouse move from the column:

Case $HDN_BEGINDRAG
                    If $iItem = $iFixedColumn Then
                        Local $iOld_Opt_MCM = Opt("MouseCoordMode", 2)
                        
                        Local $aMousePos = MouseGetPos()
                        Local $aHeader_Pos = ControlGetPos($hWndGUI, "", $hWndFrom)
                        
                        MouseMove($aHeader_Pos[0]-10, $aHeader_Pos[1]-10, 0)
                        MouseUp("Main")
                        MouseMove($aMousePos[0], $aMousePos[1], 0)
                        
                        Opt("MouseCoordMode", $iOld_Opt_MCM)
                    EndIf

But maybe there is a better solution for this issue? :P

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

EDIT - Updated code below. This should be a satisfactory solution I think. Thoughts?

This is a little less code. The only visual issue is that it doesn't stop the Column1 drag animation if the user drags out of the Column1 bounding rectangle. It seems that the BEGINDRAG $iItem changes even though the user has not let go of the mouse button once out of the rectangle. But the ENDDRAG $iItem remains 0.

I thought it was maybe a conflict somehow with AutoIt's management of the control, so I tried subclassing it. Unfortunately, same results. Looks like a windows bug.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIHeader.au3>
;

Global $iFixedColumn = 0
$f = False

$GUI = GUICreate("Restrict Drag & Drop Columns", 420, 240)

$ListView = GUICtrlCreateListView("Column1|Column2|Column3|Column4|Column5", 20, 20, 380, 200, _
    BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOSORTHEADER), _
    BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))

$hLV_Header = GUICtrlSendMsg($ListView, $LVM_GETHEADER, 0, 0)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_EVENTS")

GUISetState(@SW_SHOW)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(50)
    If $f Then
        $m = GUIGetCursorInfo()
        If $m[2] == 0 Then $f = False ; primary mouse up
    EndIf
WEnd

Func WM_NOTIFY_EVENTS($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
   
    Local $hWndFrom = DllStructGetData($tNMHEADER, "hWndFrom")
    Local $iEvent = DllStructGetData($tNMHEADER, "Code")
    Local $iItem = DllStructGetData($tNMHEADER, "Item")
   
    Switch $hWndFrom
        Case $hLV_Header
            Switch $iEvent
                Case $HDN_BEGINDRAG
                    If $f Then Return 1
                    If $iItem == 0 Then
                        $f = True
                        Return 1
                    EndIf
                Case $HDN_ENDDRAG
                    If $iItem == 0 Then Return 1
                    Local $iOld_Opt_MCM = Opt("MouseCoordMode", 0)
                    Local $iX = MouseGetPos(0)
                    Opt("MouseCoordMode", $iOld_Opt_MCM)
                    Local $aHit = _GUICtrlHeader_HitTest($hLV_Header, $iX, 5)
                    If ($aHit[0] = $iFixedColumn) Or ($aHit[0] = -1 And $aHit[10] = True) Then Return 1
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc
Edited by wraithdu
Link to comment
Share on other sites

  • 2 weeks later...

Thanks wraithdu, this seems to work well.

But now i notice another (main issue) problem - If the first column width is small (around 35 and less), then we can drop other columns to the first position (before first column) :(

Any idea how to fix that? :mellow:

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Try this. The HitTest X coord is wrong because MouseGetPos(0) returns window client coords, not control coords. So just subtract the ListView X position from the $iX value in the HitTest -

Local $aHit = _GUICtrlHeader_HitTest($hLV_Header, $iX - $iOffset, 5)

where $iOffset = 20 in your example case.

Link to comment
Share on other sites

Here's something I found:

Case $HDN_ENDDRAG; Sent by a header control when a drag operation has ended on one of its items
    $tNMHEADER = DllStructCreate($tagNMHEADER, $ilParam)
    _DebugPrint("$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"))
    Return False; To allow the control to automatically place and reorder the item
        Return True; To prevent the item from being placed


Func _DebugPrint($s_text, $line = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+======================================================" & @LF & _
            "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
            "+======================================================" & @LF)
EndFunc  ;==>_DebugPrint

Edit: Added the _DebugPring

Edited by Achilles
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Try this. The HitTest X coord is wrong because MouseGetPos(0) returns window client coords, not control coords. So just subtract the ListView X position from the $iX value in the HitTest -

Local $aHit = _GUICtrlHeader_HitTest($hLV_Header, $iX - $iOffset, 5)

where $iOffset = 20 in your example case.

Excelent! Thanks, now works as it should.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...