Jump to content

drag and drop files & title change


Recommended Posts

right i have to more really annoying problems but i think im just been thick first i really cant get the drag and drop files option to work. just have a list view and i want to be able to drag and drop files into it

$tab3 = GUICtrlCreateTabItem("Custom Files")
$listview = GUICtrlCreateListView("File Name | Size | Risk", 10, 35, 595, 342)
GUICtrlSetState(-1,$GUI_DROPACCEPTED) ; to allow drag and dropping
$nItem = GUICtrlCreateListViewItem("Drag files into the window or use the Add Files button to make your selection",$listview)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
_GUICtrlListViewSetColumnWidth($listview, 0, 460)
_GUICtrlListViewSetColumnWidth($listview, 1, 80)
$button31 = GUICtrlCreateButton("Add Files", 10, 385, 100, 20)
GUICtrlSetTip( -1, "This button allows you to add indevidual files you wish to delete to the list above")

$button32 = GUICtrlCreateButton("Remove Form List", 110, 385, 100, 20)
GUICtrlSetTip( -1, "This button allows you to remove an indevidual file from the list above")

$button33 = GUICtrlCreateButton("Remove All", 210, 385, 100, 20)
GUICtrlSetTip( -1, "This button allows you to remove all the file from the list above")

$prioratize = GUICtrlCreateButton("Prioratise", 400, 385, 100, 20)
GUICtrlSetTip( -1, "This button prioraises the files you have sulected acording to risk" & @CRLF & " 1 to 5, this will then apply a deletion algoritham acordingly")

$button34 = GUICtrlCreateButton("Delete", 505, 385, 100, 20)
GUICtrlSetTip( -1, "This button delete all of the files you have selected")

GUIRegisterMsg ($WM_DROPFILES, "WM_DROPFILES_FUNC")

Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i+1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc

thats what iv got am i just been stupid or what its well annoying i really don't know how to call the drag function or even if im doing it right?????

next id like it so if a button is pressed then the top most title of the gui is changed accordingly i.e. the one in the blue bare at the top of the gui. iv looked at theat to and it seem pritty simple but i just cant get it to work??????

Link to comment
Share on other sites

right i have to more really annoying problems but i think im just been thick first i really cant get the drag and drop files option to work. just have a list view and i want to be able to drag and drop files into it

[rant]

First, I hope you will excuse me for a bit of a digression. It is fairly certain from what you have done so far that you are not at all thick. Not knowing something is not related to intellegence and neither is knowing something despite what people who know things sometimes think. So I think you shouldn't even think you're thick and you shouldn't say it in case you start to believe it even if it's not true. Smart is finding out things you don't know and then applying them which is what you are doing.

[/rant]

I think the way to handle drag and drop is easier than you thought. It might be that your method can be made to work, but since there is a simple way then I think you could do this, but it means using events.

#include <guiconstants.au3>
#include <guilistview.au3>

Opt("GUIOnEventMode", 1)
$main = GUICreate('dragdrop',500,500,200,200,-1,$WS_EX_ACCEPTFILES); <--the main gui must have this style

$tab3 = GUICtrlCreateTabItem("Custom Files")
$listview = GUICtrlCreateListView("File Name | Size | Risk", 10, 35, 595, 342)
GUICtrlSetState(-1,$GUI_DROPACCEPTED); to allow drag and dropping
$nItem = GUICtrlCreateListViewItem("Drag files into the window or use the Add Files button to make your selection",$listview)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
_GUICtrlListViewSetColumnWidth($listview, 0, 460)
_GUICtrlListViewSetColumnWidth($listview, 1, 80)
$button31 = GUICtrlCreateButton("Add Files", 10, 385, 100, 20)
GUICtrlSetTip( -1, "This button allows you to add indevidual files you wish to delete to the list above")

$button32 = GUICtrlCreateButton("Remove Form List", 110, 385, 100, 20)
GUICtrlSetTip( -1, "This button allows you to remove an indevidual file from the list above")

$button33 = GUICtrlCreateButton("Remove All", 210, 385, 100, 20)
GUICtrlSetTip( -1, "This button allows you to remove all the file from the list above")

$prioratize = GUICtrlCreateButton("Prioratise", 400, 385, 100, 20)
GUICtrlSetTip( -1, "This button prioraises the files you have sulected acording to risk" & @CRLF & " 1 to 5, this will then apply a deletion algoritham acordingly")

$button34 = GUICtrlCreateButton("Delete", 505, 385, 100, 20)
GUICtrlSetTip( -1, "This button delete all of the files you have selected")
GUISetState()
GUISetOnEvent($GUI_EVENT_DROPPED, 'DropFile');this is the way I do it
;GUIRegisterMsg ($WM_DROPFILES, "WM_DROPFILES_FUNC"); I don't know how to do this (but I'm not thick)
While 1
    
WEnd


Func DropFile()
If @GUI_DropId <> $listview Then Return
$f = @GUI_DragFile
_GUICtrlListViewInsertItem($listview,-1,$f);may not be the way you want to do it but just to demonstrate

EndFunc

Func Quit()
Exit
EndFunc
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

lol thanks for the rant i know im knot thick but this program is really starting to get to me iv been doing it for ages and don't seem to be getting any were. the code is great and works a treat but when i embed it into my code it don't actual allow me to drop the file it all works fine and even gives the + sign when i drop the file onto the screen but it don't seem to actual add the file would it be possible for you to have a look at my code its a bit big, but it would be a great help

any how thanks again

Advanced.au3

Link to comment
Share on other sites

lol thanks for the rant i know im knot thick but this program is really starting to get to me iv been doing it for ages and don't seem to be getting any were. the code is great and works a treat but when i embed it into my code it don't actual allow me to drop the file it all works fine and even gives the + sign when i drop the file onto the screen but it don't seem to actual add the file would it be possible for you to have a look at my code its a bit big, but it would be a great help

any how thanks again

I'm afraid to use the method I suggested you have to have

Opt("GUIOnEventMode", 1)

and then write the script for events. In fact if you just add that line with your other Opt lines and run the script you will see that now the drag and drop works but nothing else does.

It's not difficult to change a script to events and I would guess that for your script it means about 20 minutes work.

For example to change this

While 1
    $msg = GUIGetMsg()
    
    Select
            Case $msg = $Filesitem
            GUIctrlSetState ($Iternettree,$GUI_HIDE)
            GUICtrlSetState ($Deletedtree,$GUI_HIDE)
            GUIctrlSetState ($Systemtree,$GUI_HIDE)
            GUICtrlSetState ($Nettree,$GUI_HIDE)
            GUICtrlSetState ($SelectallInt,$GUI_HIDE)
            GUICtrlSetState ($SelectallNet,$GUI_HIDE)
            GUICtrlSetState ($SelectallDel,$GUI_HIDE)
            GUICtrlSetState ($SelectallSys,$GUI_HIDE)
            GUICtrlSetState ($UnSelectallNet,$GUI_HIDE)
            GUICtrlSetState ($UnSelectallDel,$GUI_HIDE)
            GUICtrlSetState ($UnSelectallInt,$GUI_HIDE)
            GUICtrlSetState ($UnSelectallSys,$GUI_HIDE)
            GUICtrlSetState($button1,$GUI_SHOW)
            GUICtrlSetState($button2,$GUI_SHOW)
            GUICtrlSetState($User,$GUI_SHOW)

you need to have

GUISetOnEvent($Filesitem, "setfilestates")

Func setfilestates()
            GUIctrlSetState ($Iternettree,$GUI_HIDE)
            GUICtrlSetState ($Deletedtree,$GUI_HIDE)
            GUIctrlSetState ($Systemtree,$GUI_HIDE)
            GUICtrlSetState ($Nettree,$GUI_HIDE)
            GUICtrlSetState ($SelectallInt,$GUI_HIDE)
            GUICtrlSetState ($SelectallNet,$GUI_HIDE)
            GUICtrlSetState ($SelectallDel,$GUI_HIDE)
            GUICtrlSetState ($SelectallSys,$GUI_HIDE)
            GUICtrlSetState ($UnSelectallNet,$GUI_HIDE)
            GUICtrlSetState ($UnSelectallDel,$GUI_HIDE)
            GUICtrlSetState ($UnSelectallInt,$GUI_HIDE)
            GUICtrlSetState ($UnSelectallSys,$GUI_HIDE)
            GUICtrlSetState($button1,$GUI_SHOW)
            GUICtrlSetState($button2,$GUI_SHOW)
            GUICtrlSetState($User,$GUI_SHOW)
        endFunc

Apologies if I'm being a bit obvious.

Edited by martin
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

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...