Sign in to follow this  
Followers 0
Ebenezer

Drag & Drop On Tabs

6 posts in this topic

Hi,

I use a GUI where Items should be drag&dropped from one listview to another. Both listviews are created on a tab.

When I get the @GUI_DragId and @GUI_DropId results, @GUI_DragId works fine. @GUI_DropId however always returns the identifier of the tab, not the control on it. So, what did I miss when doing this?

Thanks for your help :think:

$tab0=GUICtrlCreateTabitem ("Item Management")

$Inventory_Listview = GuiCtrlCreateListView("Items in Inventory|Amount", $vCoordinates[0]+$vCoordinates[2]+25, $vCoordinates[1], 170, 180, BitOR($LVS_SORTASCENDING,$LVS_SHOWSELALWAYS))
    _GUICtrlListViewSetColumnWidth ($Inventory_Listview, 0, 135)        ;Set Width of first and second column
    _GUICtrlListViewSetColumnWidth ($Inventory_Listview, 1, 56)
    GUICtrlSendMsg($Inventory_Listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

$vCoordinates = ControlGetPos("", "", $Inventory_Listview)
$SDB_Listview = GuiCtrlCreateListView("SDB Items|Amount|Type", $vCoordinates[0]+$vCoordinates[2]+25, $vCoordinates[1], 170, 380, BitOR($LVS_SORTASCENDING,$LVS_SHOWSELALWAYS))
    _GUICtrlListViewSetColumnWidth ($SDB_Listview, 0, 135)      ;Set Width of first and second column
    _GUICtrlListViewSetColumnWidth ($SDB_Listview, 1, 56)
    _GUICtrlListViewSetColumnWidth ($SDB_Listview, 2, 75)   
    GUICtrlSendMsg($SDB_Listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

...

Func ProcessDropEvent()
    MsgBox(0, "", "Dropped from: " & @GUI_DragId & " to " & @GUI_DropId)
    MsgBox(0, "Move", _GUICtrlListViewGetCurSel(@GUI_DragId))
EndFunc

Share this post


Link to post
Share on other sites



Hm, nobody?

Did I leave something out when describing the problem / is there something else you guys need to know or is there just no easy answer?

Thanks again...

Share this post


Link to post
Share on other sites

Hm, nobody?

Did I leave something out when describing the problem / is there something else you guys need to know or is there just no easy answer?

Thanks again...

How about a script stripped down to just enough to reproduce the problem, don't feel writing one to figure out your problem at this time.


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

Thanks for the reply.

Sorry that it took so long - busy day...

Here's the stripped down script replicating the problem. Bit of an hack job via copy&paste I fear.

I hope it's still readable :think:

#include <GuiListView.au3>
#include <GuiTab.au3>
#include <GuiConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

#region - Globals

Global $vCoordinates[4]
Global $vTreeViewSections
Global $element

#endregion


#region - Main GUI Creation

$Main_GUI = GUICreate("MyGUI", 840, 500, (@DesktopWidth - 700) / 2, (@DesktopHeight - 500) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$vCoordinates = ControlGetPos("", "", $Main_GUI)
$tabMain = GUICtrlCreateTab(10, 10, 820, 483)

#region - Tab Itemverwaltung

$tab0 = GUICtrlCreateTabItem("Item Management")

$vCoordinates = ControlGetPos("", "", $tabMain)
$Itemverwaltung_Treeview = GUICtrlCreateTreeView($vCoordinates[0] + 25, $vCoordinates[1] + 40, 170, 380, $WS_BORDER, $TVS_HASBUTTONS)

$vTreeViewSections = IniReadSectionNames("Itemdatabase.ini")
_ArrayDelete($vTreeViewSections, 0)
_ArrayDelete($vTreeViewSections, _ArraySearch ($vTreeViewSections, "Items"))
For $element In $vTreeViewSections
    GUICtrlCreateTreeViewItem($element, $Itemverwaltung_Treeview)
Next

$vCoordinates = ControlGetPos("", "", $Itemverwaltung_Treeview)
$Shop_Listview = GUICtrlCreateListView("Shop Items|Amount", $vCoordinates[0] + $vCoordinates[2] + 25, $vCoordinates[1], 170, 380, $LVS_SHOWSELALWAYS)
;~ GUICtrlSetBkColor($SDB_Listview, $Controlbackground)
_GUICtrlListViewSetColumnWidth ($Shop_Listview, 0, 135);Set Width of first and second column
_GUICtrlListViewSetColumnWidth ($Shop_Listview, 1, 56)
GUICtrlSendMsg($Shop_Listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

$vCoordinates = ControlGetPos("", "", $Shop_Listview)
$Inventory_Listview = GUICtrlCreateListView("Items in Inventory|Amount", $vCoordinates[0] + $vCoordinates[2] + 25, $vCoordinates[1], 170, 180, $LVS_SHOWSELALWAYS)
;~ GUICtrlSetBkColor($List_1, $Controlbackground)
_GUICtrlListViewSetColumnWidth ($Inventory_Listview, 0, 135);Set Width of first and second column
_GUICtrlListViewSetColumnWidth ($Inventory_Listview, 1, 56)
GUICtrlSendMsg($Inventory_Listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

$vCoordinates = ControlGetPos("", "", $Inventory_Listview)
$Button_Moveleft = GUICtrlCreateButton("Moveleft", $vCoordinates[0] - 10, $vCoordinates[1] + $vCoordinates[3] + 15, 40, 40, $BS_ICON)
GUICtrlSetImage($Button_Moveleft, "media-seek-backward.bmp")

$Button_MoveThemNow = GUICtrlCreateButton("MoveThemNow", $vCoordinates[0] + $vCoordinates[2] / 2 - 20, $vCoordinates[1] + $vCoordinates[3] + 15, 40, 40, $BS_ICON)

$Button_Moveright = GUICtrlCreateButton("Moveright", $vCoordinates[0] + $vCoordinates[2] - 40 + 10, $vCoordinates[1] + $vCoordinates[3] + 15, 40, 40, $BS_ICON)
GUICtrlSetImage($Button_Moveright, "media-seek-forward.bmp")

$vCoordinates = ControlGetPos("", "", $Inventory_Listview)
$SDB_Listview = GUICtrlCreateListView("SDB Items|Amount|Type", $vCoordinates[0] + $vCoordinates[2] + 25, $vCoordinates[1], 170, 380, $LVS_SHOWSELALWAYS)
;~ GUICtrlSetBkColor($SDB_Listview, $Controlbackground)
_GUICtrlListViewSetColumnWidth ($SDB_Listview, 0, 135);Set Width of first and second column
_GUICtrlListViewSetColumnWidth ($SDB_Listview, 1, 56)
_GUICtrlListViewSetColumnWidth ($SDB_Listview, 2, 75)
GUICtrlSendMsg($SDB_Listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

#endregion

#region - Tab Preisverwaltung

$tab1 = GUICtrlCreateTabItem("Price Management")

$vCoordinates = ControlGetPos("", "", $tabMain)
$Preisverwaltung_Shoplist = GUICtrlCreateListView("Shop Item|Old|New", $vCoordinates[0] + 25, $vCoordinates[1] + 40, 225, 380, $LVS_SHOWSELALWAYS)
_GUICtrlListViewSetColumnWidth ($Preisverwaltung_Shoplist, 0, 135);Set Width of first and second column
_GUICtrlListViewSetColumnWidth ($Preisverwaltung_Shoplist, 1, 45)
_GUICtrlListViewSetColumnWidth ($Preisverwaltung_Shoplist, 2, 45)
GUICtrlSendMsg($Preisverwaltung_Shoplist, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

$vCoordinates = ControlGetPos("", "", $Preisverwaltung_Shoplist)
$Group_EnterPrice = GUICtrlCreateGroup("Please enter price for selected Item", $vCoordinates[0] + $vCoordinates[2] + 25, $vCoordinates[1], 200, 200)

$vCoordinates = ControlGetPos("", "", $Group_EnterPrice)
$Tab1_Selected_Item = GUICtrlCreateLabel(_GUICtrlListViewGetItemText ($Preisverwaltung_Shoplist, -1, 0), $vCoordinates[0] + 10, $vCoordinates[1] + 25, $vCoordinates[2] - 20, 20, BitOR($SS_CENTER, $SS_SUNKEN))

$Tab1_Price = GUICtrlCreateInput("$$$", $vCoordinates[0] + 10, $vCoordinates[1] + 60, $vCoordinates[2] - 100, 20)
$vCoordinates = ControlGetPos("", "", $Tab1_Price)
$Tab1_Price_OK = GUICtrlCreateButton("OK", $vCoordinates[0] + $vCoordinates[2] + 10, $vCoordinates[1], 20, 20)
GUICtrlCreateLabel("", $vCoordinates[0], $vCoordinates[2] + 50, 180, 10, $SS_ETCHEDHORZ)
$Tab1_Price_Radio1 = GUICtrlCreateRadio("  Only unpriced Items", $vCoordinates[0], $vCoordinates[1] + 55, 180, 20)
GUICtrlSetState($Tab1_Price_Radio1, $GUI_CHECKED)
$Tab1_Price_Radio2 = GUICtrlCreateRadio("  Only priced Items", $vCoordinates[0], $vCoordinates[1] + 80, 180, 20)
$Tab1_Price_Radio3 = GUICtrlCreateRadio("  All Items", $vCoordinates[0], $vCoordinates[1] + 105, 180, 20)


$vCoordinates = ControlGetPos("", "", $Group_EnterPrice)
$Group_Autopricer = GUICtrlCreateGroup("Autopricing", $vCoordinates[0] + $vCoordinates[2] + 25, $vCoordinates[1], 200, 190)

$vCoordinates = ControlGetPos("", "", $Group_Autopricer)
$Tab1_AutoPrice_Button = GUICtrlCreateButton("AutoPrice them !", $vCoordinates[0] + 10, $vCoordinates[1] + 25, $vCoordinates[2] - 20, 20)
GUICtrlCreateLabel("", $vCoordinates[0] + 10, $vCoordinates[1] + 60, 180, 10, $SS_ETCHEDHORZ)
$Tab1_AutoPrice_Radio1 = GUICtrlCreateRadio("  Make me cheapest !", $vCoordinates[0] + 10, $vCoordinates[1] + 70, 180, 20)
$Tab1_AutoPrice_Radio2 = GUICtrlCreateRadio("  No, maximize profit", $vCoordinates[0] + 10, $vCoordinates[1] + 95, 180, 20)
$Tab1_AutoPrice_Check1 = GUICtrlCreateCheckbox("But keep me in the top ", $vCoordinates[0] + 34, $vCoordinates[1] + 110, 160, 40, $BS_MULTILINE)
$Tab1_AutoPrice_Input1 = GUICtrlCreateInput(10, $vCoordinates[0] + 34, $vCoordinates[1] + 150, 50, 20)
$Tab1_AutoPrice_UpDown1 = GUICtrlCreateUpdown($Tab1_AutoPrice_Input1)
$Tab1_AutoPrice_Label1 = GUICtrlCreateLabel("results", $vCoordinates[0] + 93, $vCoordinates[1] + 153, 50, 20, $SS_LEFT)

$vCoordinates = ControlGetPos("", "", $Group_Autopricer)
$Group_Autopricer_Settings = GUICtrlCreateGroup("Please choose Autoprice options", $vCoordinates[0], $vCoordinates[1] + $vCoordinates[3] + 10, 200, 90)
$vCoordinates = ControlGetPos("", "", $Group_Autopricer_Settings)
$Tab1_Autoricer_Radio1 = GUICtrlCreateRadio("  Only unpriced Items", $vCoordinates[0] + 10, $vCoordinates[1] + 20, 180, 20)
GUICtrlSetState($Tab1_Autoricer_Radio1, $GUI_CHECKED)
$Tab1_Autoricer_Radio2 = GUICtrlCreateRadio("  Only priced Items", $vCoordinates[0] + 10, $vCoordinates[1] + 40, 180, 20)
$Tab1_Autoricer_Radio3 = GUICtrlCreateRadio("  All Items", $vCoordinates[0] + 10, $vCoordinates[1] + 60, 180, 20)


GUICtrlCreateTabItem("")  ; end tabitem definition

#endregion - Tab 2

#endregion - GUI

#region - Globals - Convenient Declarations

Dim $InventoryContent[2][2] = [["1", "1"], ["2", "2"]]
Dim $ShopContent[2][2] = [["3", "3"], ["4", "4"]]
Global $SDBContent[2][3] = [["5", "5", "5"], ["6", "6", "6"]]

#endregion


GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_DROPPED, "ProcessDropEvent")

DisplaySDB()
DisplayShop()
DisplayInventory()

While 1
    Sleep(200)
WEnd

Exit

Func ProcessDropEvent()
    MsgBox(0, "Drag&Drop", "You dragged Item from " & @GUI_DragId & " to " & @GUI_DropId)
EndFunc  ;==>ProcessDropEvent


#region - Various Functions

Func _LockAndWait($vLock)
    If $vLock = 1 Then
        Local $Cursor_WAIT
        GUISetState(@SW_LOCK)
        GUISetCursor($Cursor_WAIT, 1)
    ElseIf $vLock = 0 Then
        Local $Cursor_ARROW
        GUISetState(@SW_UNLOCK)
        GUISetCursor($Cursor_ARROW, 1)
    Else
        Return -1
    EndIf
EndFunc  ;==>_LockAndWait

Func CLOSEClicked()
    Exit
EndFunc  ;==>CLOSEClicked

;===============================================================================
;
; Function Name:    DisplaySDB()
; Description:    Populates the $SDB_Listview with the content of the $SDB_content array
; Parameter(s):  None
; Requirement(s):   AutoIt3 Beta with COM support (post 3.1.1)
; Return Value(s):  On Success -
;                  On Failure -
; Author(s):        FMH
;
;===============================================================================
;
Func DisplaySDB()
    _LockAndWait(1)
    _GUICtrlListViewDeleteAllItems ($SDB_Listview)
    For $i = 0 To UBound($SDBContent, 1) - 1
        GUICtrlCreateListViewItem($SDBContent[$i][0] & "|" & $SDBContent[$i][1] & "|" & $SDBContent[$i][2], $SDB_Listview)
    Next
    _LockAndWait(0)
EndFunc  ;==>DisplaySDB

Func DisplayShop()
    _GUICtrlListViewDeleteAllItems ($Shop_Listview)
    For $i = 0 To UBound($ShopContent, 1) - 1
        GUICtrlCreateListViewItem($ShopContent[$i][0] & "|" & $ShopContent[$i][1], $Shop_Listview)
    Next
EndFunc  ;==>DisplayShop

Func DisplayInventory()
    _GUICtrlListViewDeleteAllItems ($Inventory_Listview)
    For $i = 0 To UBound($InventoryContent, 1) - 1
        GUICtrlCreateListViewItem($InventoryContent[$i][0] & "|" & $InventoryContent[$i][1], $Inventory_Listview)
    Next
EndFunc  ;==>DisplayInventory

#endregion

Try dragging the items between the listviews on tab 0.

What puzzles me, is that it detects the dragid correctly. I would have expected to either succeed or fail completely if there are problems with the tab control.

Thanks again, Ebenezer

Share this post


Link to post
Share on other sites

FYI: I created a couple of test files using your code a passed them onto one of the devs, he's looking into it.

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

#6 ·  Posted (edited)

Here coming a Dev.

to have it working you need to set the control you drop in as

GuiCtrlSetState (-1,$GUI_DROPACCEPTED)

There is a small bug as you are notified even if you don't set it, I will investigate.

For now just add GuiCtrlSetState after the control definition in your case the listview creation. :think:

EDit will be fixed in 3.1.1.120

Edited by jpm

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