Bonjour , j'espere que ma question est un peut moins exaspérante cette fois-ci
Et bien voila , j'ai un ensemble de controles simples devant accpter des fichiers en Drag&Drop , jusque la , je m'en sort bien avec $WS_EX_ACCEPTFILES
mais la ou j'ai un petit problème c'est que j'aimerai inclure cette fonctionnalité a un treeview (liste de fichiers avec dossiers parrents), et donc, quand je glisse un fichier au dessu du treeview , et que je le lache , faire apparitre une Gui avec un champ qui contient le Chemin du dit Fichier
Merci d'avance
Drag & Drop
Règles du forum
- Merci de consulter la section "Règles du forum" et plus particulièrement "Règles et Mentions Légales du site autoitscript.fr" avant d'écrire un message.
- Nicoloquinte
- Niveau 4
- Messages : 70
- Enregistré le : ven. 15 juil. 2016 11:57
- Status : Hors ligne
Drag & Drop
Nico ¤_¤
- mikell
- Spammer !
- Messages : 6292
- Enregistré le : dim. 29 mai 2011 17:32
- Localisation : Deep Cévennes
- Status : Hors ligne
Re: Drag & Drop
Ouala
C'est une compil de 2 exemples du fichier d'aide. J'ai mis une msgbox pour la démo, mais ce n'est pas recommandé de mettre une fonction bloquante à cet endroit... à toi d'aménager le truc
Note que tu peux drag/dropper un ou plusieurs fichiers
C'est une compil de 2 exemples du fichier d'aide. J'ai mis une msgbox pour la démo, mais ce n'est pas recommandé de mettre une fonction bloquante à cet endroit... à toi d'aménager le truc
Note que tu peux drag/dropper un ou plusieurs fichiers
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPISys.au3>
OnAutoItExitRegister('OnAutoItExit')
GUICreate("My GUI with treeview", 350, 215)
Local $idTreeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$hTreeview = GuiCtrlGetHandle($idTreeview)
_WinAPI_DragAcceptFiles($hTreeview)
Local $idGeneralitem = GUICtrlCreateTreeViewItem("General", $idTreeview)
GUICtrlSetColor(-1, 0x0000C0)
Local $idDisplayitem = GUICtrlCreateTreeViewItem("Display", $idTreeview)
GUICtrlSetColor(-1, 0x0000C0)
Local $idAboutitem = GUICtrlCreateTreeViewItem("About", $idGeneralitem)
Local $idCompitem = GUICtrlCreateTreeViewItem("Computer", $idGeneralitem)
GUICtrlCreateTreeViewItem("User", $idGeneralitem)
GUICtrlCreateTreeViewItem("Resolution", $idDisplayitem)
GUICtrlCreateTreeViewItem("Other", $idDisplayitem)
GUICtrlSetState($idGeneralitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
GUICtrlSetState($idDisplayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
; Allow WM_DROPFILES to be received from lower privileged processes (Windows Vista or later)
#cs
If IsAdmin() Then
_WinAPI_ChangeWindowMessageFilterEx($hTreeview, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW)
_WinAPI_ChangeWindowMessageFilterEx($hTreeview, $WM_DROPFILES, $MSGFLT_ALLOW)
EndIf
#ce
; Register treeview window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Global $g_pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($hTreeview, $GWL_WNDPROC, $g_pDll)
GUISetState(@SW_SHOW)
While 1
$idMsg = GUIGetMsg()
Select
Case $idMsg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd
Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_DROPFILES
Local $aFileList = _WinAPI_DragQueryFileEx($wParam)
If not @error Then
Local $list
For $i = 1 To $aFileList[0]
$list &= $aFileList[$i] & @crlf
Next
_WinAPI_DragFinish($wParam)
Return 0*Msgbox(0,"", StringTrimRight($list, 1))
; Return 0
EndIf
EndSwitch
Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>_WinProc
Func OnAutoItExit()
_WinAPI_SetWindowLong($hTreeview, $GWL_WNDPROC, $g_hProc)
DllCallbackFree($g_hDll)
EndFunc
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPISys.au3>
OnAutoItExitRegister('OnAutoItExit')
GUICreate("My GUI with treeview", 350, 215)
Local $idTreeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$hTreeview = GuiCtrlGetHandle($idTreeview)
_WinAPI_DragAcceptFiles($hTreeview)
Local $idGeneralitem = GUICtrlCreateTreeViewItem("General", $idTreeview)
GUICtrlSetColor(-1, 0x0000C0)
Local $idDisplayitem = GUICtrlCreateTreeViewItem("Display", $idTreeview)
GUICtrlSetColor(-1, 0x0000C0)
Local $idAboutitem = GUICtrlCreateTreeViewItem("About", $idGeneralitem)
Local $idCompitem = GUICtrlCreateTreeViewItem("Computer", $idGeneralitem)
GUICtrlCreateTreeViewItem("User", $idGeneralitem)
GUICtrlCreateTreeViewItem("Resolution", $idDisplayitem)
GUICtrlCreateTreeViewItem("Other", $idDisplayitem)
GUICtrlSetState($idGeneralitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
GUICtrlSetState($idDisplayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
; Allow WM_DROPFILES to be received from lower privileged processes (Windows Vista or later)
#cs
If IsAdmin() Then
_WinAPI_ChangeWindowMessageFilterEx($hTreeview, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW)
_WinAPI_ChangeWindowMessageFilterEx($hTreeview, $WM_DROPFILES, $MSGFLT_ALLOW)
EndIf
#ce
; Register treeview window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Global $g_pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($hTreeview, $GWL_WNDPROC, $g_pDll)
GUISetState(@SW_SHOW)
While 1
$idMsg = GUIGetMsg()
Select
Case $idMsg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd
Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_DROPFILES
Local $aFileList = _WinAPI_DragQueryFileEx($wParam)
If not @error Then
Local $list
For $i = 1 To $aFileList[0]
$list &= $aFileList[$i] & @crlf
Next
_WinAPI_DragFinish($wParam)
Return 0*Msgbox(0,"", StringTrimRight($list, 1))
; Return 0
EndIf
EndSwitch
Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>_WinProc
Func OnAutoItExit()
_WinAPI_SetWindowLong($hTreeview, $GWL_WNDPROC, $g_hProc)
DllCallbackFree($g_hDll)
EndFunc
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
- Nicoloquinte
- Niveau 4
- Messages : 70
- Enregistré le : ven. 15 juil. 2016 11:57
- Status : Hors ligne
Re: Drag & Drop
ça ne semble fonctionner qu'en retirant la partie comentée , mais ça parche super bien merci beaucoup Mikell
Nico ¤_¤