ISI360 Posted May 24, 2015 Share Posted May 24, 2015 Thx for your help in advance! (and no stress ^^) Link to comment Share on other sites More sharing options...
LarsJ Posted May 28, 2015 Author Share Posted May 28, 2015 (edited) Cancel drag/drop functionalityA drag operation in Windows Explorer right pane window based on IExplorerBrowser interface (virtual listview on Vista and later) can be identified by a 0x04CB message. In the Wine Wiki "List of Windows Messages" this message is described with the name IE_GETGESTURE. It's probably the message that's used to generate the drag image.The drag operation can be canceled with this code:; Cancel drag Switch $iMsg Case $WM_MOUSEMOVE, $WM_TIMER, $WM_PAINT Return 0 Case 0x04CB ; Send when drag/drop operation is initiated ControlSend( $hExplorerWin, "", $hExplorerLvWin, "{ESC}" ) ; Cancel drag Return 0 EndSwitchIn a right pane window based on a SysListView32 listview a drag operation can be identified by a LVN_BEGINDRAG notification.A drop operation can be identified by WM_USER (0x0400) messages and a pressed primary mouse button. This applies to both a virtual and a SysListView32 listview.The drop operation can be canceled with this code:; Cancel drop Switch $iMsg Case $WM_TIMER Return 0 Case $WM_PAINT If $fWM_USER Then Return 0 Case $WM_USER If $fWM_USER Then Return 0 If Not BitAND( DllCall( $dllUser32, "short", "GetAsyncKeyState", "int", $iMouseBut )[0], 0x8000 ) Then Return 0 MouseClick( "secondary" ) ; Cancel drop $fWM_USER = 1 Return 0 Case Else $fWM_USER = 0 EndSwitchWM_USER is accompanied by WM_TIMER and WM_PAINT messages. Several WM_USER messages are generated. The drop operation should only be canceled once. This code works on XP and Vista and later.A complete example for Vista and later is included in the zip. When I get time I'll add an example to each of the three implementations in first post, that shows how to cancel drag/drop.Windows Explorer example.7z Edited May 28, 2015 by LarsJ Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
ISI360 Posted May 29, 2015 Share Posted May 29, 2015 Wow! It´s simply perfect! <3Thank you very much and a nice weekend LarsJ!!! Link to comment Share on other sites More sharing options...
LarsJ Posted May 30, 2015 Author Share Posted May 30, 2015 Thank you. I agree. It works surprisingly well. And it provides some more opportunities.For example, you can add a drop area to your GUI. Since the drop function is canceled in the Explorer control, the user is forced to drop the files in the drop area. In this area you can get a list of full names of the files and implement validation e.g. file type and source folder, before the files are copied to the folder in the Explorer control. Files that do not meet the conditions are skipped. This could be an answer to your question about replacing the default drop function with your own function.The drop function is canceled immediately after it is detected. If the function is detected very near the border of the Explorer control a possibility is to move the mouse just outside the Explorer control instead of canceling the entire drag/drop operation. That would be a little bit more user friendly, if the user is dragging files from one window to another and accidentally drag over the Explorer control. This gives him a chance to drag around the Explorer control.The drag function in the Explorer control is canceled directly on initiation. Another possibility is to just set a flag that a drag operation is started. Only if the files are dragged outside the Explorer control, the drag operation is canceled. In that way you could allow drag/drop internally in the Explorer control, while dragging files to an external program, or dropping files from an external program is not allowed.Since it's easy to detect initiation of a drag operation in the Explorer control, and it's easy to get a list of selected files and folders, it would also be easy to implement validation of a drag selection. E.g. a drag selection containing folders is not allowed and is canceled.I'll definitely test some of these opportunities. If it works good, I'll probably add an example.Your question turned out to be very interesting. Let me know if there are any issues.Regards, Lars. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
TJF Posted August 18, 2015 Share Posted August 18, 2015 Wow... Amazing... Thank you for sharing!Could someone help me, how to use this script like an embedded FileSelectFolder-func ? Means not to show files, only folders and return the clicked folderpath ...?Best regards!Thomas Link to comment Share on other sites More sharing options...
LarsJ Posted August 19, 2015 Author Share Posted August 19, 2015 (edited) In this example the file filter is modified to exclude all files. And code is added to return the path when a folder is double clicked (or press Enter key) in the listview. Here the path is just shown in the label. Note that the default code on double click (to browse to the folder) is still executed.The GUI looks like this:Windows Explorer example.7zRegards, Lars. Edited August 19, 2015 by LarsJ Danyfirex 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted August 19, 2015 Author Share Posted August 19, 2015 Thank you, Danyfirex. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
TJF Posted August 20, 2015 Share Posted August 20, 2015 Thats's great! Thank you very much, Lars ... Best regardsThomas Link to comment Share on other sites More sharing options...
LarsJ Posted August 21, 2015 Author Share Posted August 21, 2015 (edited) This is the same as the code in post 66, but the default code (to browse to the folder) is not executed when you double click or press Enter in the listview. This means that you have to do all the browsing in the treeview, and you can only select the folder in the listview.Windows Explorer example.7zRegards, Lars. Edited August 21, 2015 by LarsJ Danyfirex 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
RichardL Posted February 23, 2016 Share Posted February 23, 2016 Hi LarsJ, I've recently understood the pattern of a bad behaviour in W7 Explorer. If I browse using the arrow keys in the treeview, when I expand a folder it scrolls the treeview so that folder is 2 lines above the bottom of the window. (Even if you were half-way up the treeview to start with.) Now the sub-folders you want to see are off the bottom of the screen. Sadly your explorer does this as well, presumably inherited from W7. Is this something that you can change? (I hope). best regards, RichardL Link to comment Share on other sites More sharing options...
LarsJ Posted February 24, 2016 Author Share Posted February 24, 2016 RichardL, I'm working on another project for the moment which has priority. When the project is finished in 2 - 3 weeks I'll look into this issue. I cannot promise you an answer before mid-March. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted March 28, 2016 Author Share Posted March 28, 2016 A little late. Sorry. I'm seeing the same behaviour. But there is an easy workaround. Press left arrow to collapse the folder. Press right arrow to expand the folder. If there are many subfolders in the parent folder (I've been testing with Windows and System32 on C-drive), the parent folder will now be the topmost visible folder in the treeview. The next time you expand the folder, you don't need the workaround. The folder will automatically be positioned as the topmost visible folder. It seems as if Windows Explorer needs the number of subfolders to position the parent folder as the topmost folder in the treeview. The first time a folder is expanded the number is not known, and the parent folder is positioned 2 lines above the bottom of the treeview window. When the folder is expanded the number of subfolders is counted. The next time the same folder is expanded the number of subfolders is known and the parent folder can be positioned as the topmost folder. I've tried to automate the workaround by sending left and right arrow key presses to the treeview control. And this works. The parent folder is now the topmost visible folder in the treeview. But the parent folder is not the selected folder anymore. The selected folder is important when you navigate the treeview with the keyboard. All navigation is relative to the selected folder. The selected folder must be set to the proper parent folder. Because the treeview is a normal TreeView32 control the folder can easily be selected with ControlTreeView "Select" command. But guess where the parent folder is positioned after this command: 2 lines above the bottom of the treeview window. This means that I've not found a way to automate the workaround. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
RichardL Posted March 30, 2016 Share Posted March 30, 2016 Lars, you're very kind to have looked at this. Thanks. Richard. Link to comment Share on other sites More sharing options...
RichardL Posted March 30, 2016 Share Posted March 30, 2016 (edited) sorry, double post. Edited March 30, 2016 by RichardL oops. Link to comment Share on other sites More sharing options...
AIG Posted April 26, 2023 Share Posted April 26, 2023 I need to call the Windows dialog box for selecting multiple files and folders. The problem is that standard functions don't allow for this, so I have to look for other tools.In a thread I created, a kind person named Melba23 suggested a good working solution "UDF ChooseFileFolder", but I would like my version to work like the standard Windows file selection window.. That's why I turned my attention to this post. In the "Context Menu" example, the "Selected" option can display selected files using "_ArrayDisplay". Most likely, using this feature, it is possible to create a "Select files/folders" button in the "4. Toolbar example" or "6. Cut-copy-paste" example that will produce a list of file names, similar to what "FileOpenDialog" or the "Select" option in the "Context Menu" example does. Thank you in advance for your help.If there is a simpler solution to this problem, I would greatly appreciate your advice here. Link to comment Share on other sites More sharing options...
pixelsearch Posted April 26, 2023 Share Posted April 26, 2023 "4. Toolbar example" is great as it displays icons to navigate through folders, like Windows Explorer do. "5. Context menu" is also great as it adds 2 new menu items at the very end of the Windows Explorer context menu (one of them is the interesting "Display files and folders" as shown in the pic below) I tried to combine both examples (Toolbar + Context menu) leading to this : The result is a list of folders / files names displayed in an ArrayDisplay window, as you already experimented. Let's wait for LarsJ to have his opinion about this (additional icon, combining both examples, maybe another alternative etc...) Link to comment Share on other sites More sharing options...
AIG Posted April 27, 2023 Share Posted April 27, 2023 17 hours ago, pixelsearch said: "4. Toolbar example" is great as it displays icons to navigate through folders, like Windows Explorer do. I think it would be great to add a panel with a folder tree on the left and a working directory address bar on the top for more convenient navigation.😊 Like this: And Replacing the bottom pane with details and meta information with a panel that includes "open" and "cancel" buttons and allows filtering by file extension would be ideal. I believe LarsJ has created a good tool that can be customized to resemble Windows Vista/7-style dialog boxes. However, I'm not sure if it's possible to implement a fully functional "openfiles" window similar to the fileopendialog in this case, but it would be really cool.😊 Link to comment Share on other sites More sharing options...
pixelsearch Posted April 28, 2023 Share Posted April 28, 2023 Have a look at this other LarsJ's script found in a thread named "Get multiple files selected from the file explorer context menu" (2019) In 10 lines and no include files, he was able to get a list of anything selected in Windows Explorer ! Well done LarsJ Link to comment Share on other sites More sharing options...
AIG Posted April 28, 2023 Share Posted April 28, 2023 (edited) 20 hours ago, pixelsearch said: Well done LarsJ I completely agree with you Edited April 28, 2023 by AIG 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