TheDcoder Posted May 7, 2015 Share Posted May 7, 2015 (edited) Hello, I am confused about using these 2 macrosI already have a program with some ListView controls in it... I am thinking about adding drag & drop functionality to them.. but... I can't explain...Here is my GUI:#include-once ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> #include <GuiListView.au3> Local $hGUI = GUICreate("GUI",350,215,-1,-1,-1,-1) GUISetBkColor(0xFFFFFF,$hGUI) Local $hListView = GUICtrlCreatelistview("Column 1|Column 2",5,7,339,169,4,544) Local $hButtonCopy2 = GUICtrlCreateButton("Copy Column 2",245,180,100,30,-1,-1) Local $hButtonAdd = GUICtrlCreateButton("Add ListViewItem",110,180,128,30,-1,-1) Local $hButtonCopy1 = GUICtrlCreateButton("Copy Column 1",4,180,100,30,-1,-1) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $hButtonAdd GUICtrlCreateListViewItem(InputBox("Enter", "Enter text for column 1") & '|' & InputBox("Enter", "Enter text for column 2"), $hListView) Case $hButtonCopy1 $aData = StringSplit(GUICtrlRead(GUICtrlRead($hListView)), '|') If IsArray($aData) = 1 Then ClipPut($aData[1]) ; Avoid error Case $hButtonCopy2 $aData = StringSplit(GUICtrlRead(GUICtrlRead($hListView)), '|') If IsArray($aData) = 1 Then ClipPut($aData[2]) ; Avoid error EndSwitch WEnd So, what I need is a good example of using them in a normal my GUI with a ListView control. Thanks in Advance, TD P.S Don't blame for using magic numbers, my GUI designer did it. Edited May 7, 2015 by TheDcoder Added GUI Code EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
guinness Posted May 7, 2015 Share Posted May 7, 2015 So you have code, but would rather people create something from scratch? Doesn't really seem fair does it now! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 7, 2015 Moderators Share Posted May 7, 2015 TheDcoder,Dragging and dropping inside and between ListViews is not that easy - look in my GUIListViewEx UDF to see how I did it. If you need help to integrate the UDF into your script then do not hesitate to ask.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
TheDcoder Posted May 7, 2015 Author Share Posted May 7, 2015 Doesn't really seem fairI know but I am busy. Will work on a simple GUI EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
MikahS Posted May 7, 2015 Share Posted May 7, 2015 I know but I am busy. Who Isn't?! Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
TheDcoder Posted May 7, 2015 Author Share Posted May 7, 2015 Added the GUI EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
TheDcoder Posted May 8, 2015 Author Share Posted May 8, 2015 Bump EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
ahmet Posted May 8, 2015 Share Posted May 8, 2015 Here is a simple example. expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode",1) $hGUI=GUICreate("test",500,420) $idListView1=GUICtrlCreateListView("Col1|Col2",10,10,200,150) GUICtrlCreateListViewItem("1:Row1-Col1|Row1-Col2",$idListView1) GUICtrlCreateListViewItem("1:Row2-Col1|Row2-Col2",$idListView1) $idListView2=GUICtrlCreateListView("Col1|Col2",220,10,200,150) GUICtrlCreateListViewItem("2:Row1-Col1|Row1-Col2",$idListView2) GUICtrlCreateListViewItem("2:Row2-Col1|Row2-Col2",$idListView2) $idListView3=GUICtrlCreateListView("Col1|Col2",10,170,200,150) GUICtrlSetState(-1,$GUI_DROPACCEPTED) $idListView4=GUICtrlCreateListView("Col1|Col2",220,170,200,150) GUICtrlSetState(-1,$GUI_DROPACCEPTED) GUISetOnEvent($GUI_EVENT_CLOSE,"Close") GUISetOnEvent($GUI_EVENT_DROPPED,"DragDrop") GUISetState() While 1 Sleep(10) WEnd Func Close() Exit EndFunc Func DragDrop() ConsoleWrite("DragID=" & @GUI_DragId & @CRLF) GUICtrlCreateListViewItem(GUICtrlRead(GUICtrlRead(@GUI_DragId)),@GUI_DropId) EndFunc TheDcoder 1 Link to comment Share on other sites More sharing options...
TheDcoder Posted May 8, 2015 Author Share Posted May 8, 2015 @ahmet Thanks for the nice example but,So, what I need is a good example of using them in my GUIOk ? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
ahmet Posted May 8, 2015 Share Posted May 8, 2015 (edited) Do you actually want to copy item into the same listview? Edited May 8, 2015 by ahmet Link to comment Share on other sites More sharing options...
TheDcoder Posted May 8, 2015 Author Share Posted May 8, 2015 @ahmet I think you have misunderstood, The code is just a decoy. I wanted to know the ideal way of implementation of D&D in a already complete script EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
TheDcoder Posted May 9, 2015 Author Share Posted May 9, 2015 Hello, I found the Ideal way (IMHO) to make your (existing) GUI Drag & Drop friendly...All you need is:Case $GUI_EVENT_DROPPED ; This will go in your GUI loop Drag_N_DropManager(@GUI_DropId, @GUI_DragFile) Func Drag_N_DropManager($hDropID, $sDropFile) ; Your D&D Manager ; Modify as required EndFuncSo implementing this method in my GUI would result in:expandcollapse popup#include-once ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> #include <GuiListView.au3> Local $hGUI = GUICreate("GUI", 350, 215, -1, -1, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0xFFFFFF,$hGUI) Local $hListView = GUICtrlCreatelistview("Column 1|Column 2",5,7,339,169,4,544) GUICtrlSetState(-1, $GUI_DROPACCEPTED) Local $hButtonCopy2 = GUICtrlCreateButton("Copy Column 2",245,180,100,30,-1,-1) Local $hButtonAdd = GUICtrlCreateButton("Add ListViewItem",110,180,128,30,-1,-1) Local $hButtonCopy1 = GUICtrlCreateButton("Copy Column 1",4,180,100,30,-1,-1) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hButtonAdd GUICtrlCreateListViewItem(InputBox("Enter", "Enter text for column 1") & '|' & InputBox("Enter", "Enter text for column 2"), $hListView) Case $hButtonCopy1 $aData = StringSplit(GUICtrlRead(GUICtrlRead($hListView)), '|') If IsArray($aData) = 1 Then ClipPut($aData[1]) ; Avoid error Case $hButtonCopy2 $aData = StringSplit(GUICtrlRead(GUICtrlRead($hListView)), '|') If IsArray($aData) = 1 Then ClipPut($aData[2]) ; Avoid error Case $GUI_EVENT_DROPPED Drag_N_DropManager(@GUI_DropId, @GUI_DragFile) EndSwitch WEnd Func Drag_N_DropManager($hDropID, $sDropFile) GUICtrlCreateListViewItem(FileRead(FileOpen($sDropFile)), $hListView) EndFunc Thanks @ahmet for the Idea . Hope it may help you, TD EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now