Jump to content

Implementing Windows Explorer right pane


LarsJ
 Share

Recommended Posts

Sunaj, The zip in first post contains code which is more or less common to all three versions. The starting point for these versions was the XP version, because the implementation under XP is much more difficult, than the implementation under Vista and later. All functionality that works under XP, also works under Vista+. Certainly not the opposite way around. That's the reason why there isn't much Vista+ specific functionality in the Vista+ version.

In first post I have called the last update for the final release. This means that I'll probably not add more code, which is common to all three versions. But that does not mean, I do not want to add more code to the Vista+ implementation. And I'll probably do this at some point. It would be nice to be able to handle all the different view modes. It would also be nice to be able to add more columns to the listview. If you right click the header it's easy to add more columns. But it only works in current folder. If you browse to a new folder, the columns are not filled out.

Regards Lars.

 

Thanks for the write-up Lars, I thought as much in regards to the extra work you would have had to commit to allow post-XP functionality full exposure in the examples! As a sidenote I just ran into interesting issue with the ExplorerWindowClose() function when compiled - sometimes I needed to exit the program without doing the full initialization of the Explorer window (due to _Singleton() use) and in these instances I would get "Object error" message but only on compiled exe. I modified your function mildly and it works for me:

Func ExplorerWindowClose()
    If $hExplorerWinHook <> '' Then
        _WinAPI_UnhookWindowsHookEx( $hExplorerWinHook )
        $oIExplorerBrowser.Unadvise( $iBrowserEvents )
        $oIExplorerBrowser.Destroy()
        OleUninitialize()
        DllClose( $dllOle32 )
        DllClose( $dllShell32 )
        DllClose( $dllShlwapi )
        DllClose( $dllUser32 )
    EndIf
EndFunc

Hoping you'll find time / will to keep updating this library: it provides critical functionality for Autoit community in my opinion!

Link to comment
Share on other sites

RichardL, If you mean an Explorer on Win 7, that looks and works like the Explorer on XP, then may be. I'm working on an Explorer with an address bar (Win 7 address bar), a toolbar (includes cut/copy/paste buttons), left and right panes, and a status bar. It'll probably be a mixture of the Explorer on XP and Win 7. May be this can help you. I think it'll be ready within a month.

If you search the net, I think it is possible to find an Explorer for Win 7, that looks and works like the Explorer on XP.

Sunaj, I'm working on an update of the code for the Vista, 7, 8 example, that will handle your comments in post 39 and 41. The update will be ready for the weekend.

Link to comment
Share on other sites

The Vista, 7, 8 example in first release dated 2013-11-28 was based on Vista code. The XP example was based on XP code. But most of the additional code in the next updates was XP code (see post 40). This meant that some functionality wasn't implemented completely under Vista and later. E.g. icon view modes.

Icon view modes

In XP, Vista and Windows 7/8 there are respectively 5, 7 and 8 view modes. To implement the new modes added in Vista and Windows 7, you need Vista code.

In this update, XP code in SysLv32 and Vista, 7, 8 versions to handle icon view modes, is replaced with Vista code. This means that all the icon view modes in Vista and later are available. All examples updated to use this code. The modes can be used as parameters in ExplorerWindowCreate().

The code is based on IFolderView2 interface and SetViewModeAndIconSize method. IFolderView2 runs on Vista and later.

Columns in details view

With IColumnManager interface available on Vista and later, you can store column information in a structure variable, and restore the columns when you browse to a new folder.

Since columns are stored in a variable and not saved anywhere, columns can only be restored in the current session. When you start the script next time, it'll start up with the columns, you have defined in Windows Explorer.

Implemented for SysLv32 and Vista, 7, 8 versions. All examples updated to use this code.

In previous versions the columns were not restored in a new folder. This is still the case for the XP version.

New zip in first post.

Link to comment
Share on other sites

  • 7 months later...

Hi LarsJ :)

You can replace the code in lines 31, 32?
Thank you
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <MsgBoxConstants.au3>
#include <Crypt.au3>

$Background = GUICreate ("Auto Album 2015 - Production AV MEDIA NB" ,922 ,570 ,50 ,50)
GUISetBkColor (0xABCDEF)
$Button1 = GUICtrlCreateButton ("1.Tự Động Đổi Tên",160,10,115,44)
$Button2 = GUICtrlCreateButton ("2.Khởi Động Auto",160,60,115,44)
$Button3 = GUICtrlCreateButton ("3.Sửa Mẫu - Nén File",160,110,115,44)
$Button4 = GUICtrlCreateButton ("4.Tạo DVD",160,160,115,44)
$Button5 = GUICtrlCreateButton ("5.In Đĩa",160,210,115,44)
$Button6 = GUICtrlCreateButton ("",160,260,115,44)
$Button7 = GUICtrlCreateButton ("Thoát Chương Trình ",160,460,115,44)
$Button8 = GUICtrlCreateButton ("Giới Thiệu",10,10,115,44)
$Button9 = GUICtrlCreateButton ("Bonus - Quảng Cáo",10,60,115,44)
$Button10 = GUICtrlCreateButton ("Bonus - Sửa Mẫu",10,110,115,44)
$Button11 = GUICtrlCreateButton ("Bonus - Xóa Cache",10,160,115,44)
$Button12 = GUICtrlCreateButton ("",10,210,115,44)
$Button19 = GUICtrlCreateButton ("",10,260,115,44)
$Button20 = GUICtrlCreateButton ("",10,310,115,44)
$Button17 = GUICtrlCreateButton ("",10,360,115,44)
$Button13 = GUICtrlCreateButton ("",10,460,115,44)
$Button14 = GUICtrlCreateButton ("",160,310,115,44)
$Button15 = GUICtrlCreateButton ("Liên Hệ Trợ Giúp",10,510,115,44)
$Button16 = GUICtrlCreateButton ("Action PTS -> Destop",10,410,115,44)
$Button21 = GUICtrlCreateButton ("",160,360,115,44)
$Button18 = GUICtrlCreateButton ("",160,410,115,44)
Local $Explorer = ObjCreate("Shell.Explorer")
GUICtrlCreateObj ($Explorer, 310, 10, 600, 550)
GUISetState(@SW_SHOW)
Link to comment
Share on other sites

lovev1, This example is only implementing the right pane (the listview) of Windows Explorer. As far as I can see, you want a more complete implementation, which also includes the other panes e.g. the left pane with the folder treeview.

It's actually very easy to implement the other panes in the Vista,7,8 code. It's just a matter of setting an option. And a really good news: The Control Panel is working, when all panes are included.

Your inquiry appears to be a good opportunity to add another update, that includes the other panes. So I'll add a new update. And then I'll add a simple example, that shows how you can use this update with your code.

But I need some time. I think I'll be able to add the update in the last half of March.

Edited by LarsJ
Link to comment
Share on other sites

  • 4 weeks later...

This example shows how to add the other panes in addition to the right pane for the Vista,7,8 example. The panes includes:

  • Top pane with the commands bar
  • Left pane is the treeview for folder navigation
  • Right pane is the listview with files and folders in current folder
  • Preview pane which shows up if you click the preview button in commands bar
  • Bottom pane with details and meta information
Force empty line after list

AllPanes_zpstnpdi2jp.png

Note that the Control Panel is working in this example.

The other panes are added with just one line of code:

$oIExplorerBrowser.SetOptions( $EBO_SHOWFRAMES ) ; Show all panes

The zip contains updated code for the Vista,7,8 implementation and six examples. See Examples section in first post.

Windows Explorer all panes.7z

Link to comment
Share on other sites

This is a simple example which shows how to create a GUI with a Windows Explorer and some buttons:

Example_zpslis7z9bj.png

All include files are merged into a single Include folder.

Windows Explorer example.7z

Link to comment
Share on other sites

Post 48 shows how to add the other panes in addition to the right pane for the Vista,7,8 example.

Post 49 is a simple example which creates a GUI with a Windows Explorer and some buttons.

Link to comment
Share on other sites

  • 2 weeks later...

Hi Larsj,  I tried the example in #49.  It had $GUI_DOCKALL undefined so I added #include <GUIConstantsEx.au3>.   (W7 SP1,  AutoIt v3.3.12.0)

Now it runs and is quite useable but I've found two issues that stop it being perfect for me.

If you arrow up and down the treeview the right pane does not update.  This is my main problem with Windows Explorer but at least with yours there's a chance of fixing it.

Tabbing around gets stuck. if you start on the treeview it never gets back to the treeview.

I'm going to start looking at these, at the very least I'll learn something, but you'll probably get there first.

Link to comment
Share on other sites

Link to comment
Share on other sites

with  "Vista, 7, 8WindowsExplorer.au3"  i get this error

 

"C:UsersXXXXXXXDesktopWindows Explorer right paneExplorerIncludeWERPFuncs.au3" (7) : ==> Variable used without being declared.:
Global Const $iBorderWidth    = _WinAPI_GetSystemMetrics( $SM_CXFRAME )
Global Const $iBorderWidth    = _WinAPI_GetSystemMetrics( ^ ERROR
>Exit code: 1    Time: 0.1268

 

 

my system is win 8.1 64 bit  italian   - AutoIt Version: 3.3.12.0

Link to comment
Share on other sites

You should not run this file. You can run Vista, 7, 8.au3 in one of these folders:

  • 1. Basic example
  • 2. Position and size
  • 3. Navigation buttons
  • 4. Toolbar example
  • 5. Context menu
  • 6. Cut-copy-paste
Link to comment
Share on other sites

RichardL, Up/down in TV. I have added this code to the MessageHandler function in WindowsExplorer2.au3:

Case $VK_UP, $VK_DOWN
  If ControlGetFocus( $hExplorerWin ) = "SysTreeView321" Then
    ControlSend( $hExplorerWin, "", "[CLASSNN:SysTreeView321]", "{ENTER}" )
    ;ConsoleWrite( "$VK_UP, $VK_DOWN" & @CRLF )
  EndIf

Added to the section for $WM_KEYUP events.

 

Tab key

Dummy control defined in Example.au3:

$idTabPress = GUICtrlCreateDummy()

Added this code to the MessageHandler function in WindowsExplorer2.au3:

Case $VK_TAB
  GUICtrlSendToDummy( $idTabPress, ControlGetFocus( $hExplorerWin ) & ( $fShift ? "Shift" : "" ) )
  ;ConsoleWrite( "$VK_TAB" & @CRLF )
  Return True

Added to the section for $WM_KEYDOWN events.

Added this code to the AutoIt message loop in Example.au3:

Case $idTabPress
  Local $sCtrlOld = GUICtrlRead( $idTabPress )
  Local $sCtrlNew = ControlGetFocus( $hExplorerWin )
  ;ConsoleWrite( "Old: " & $sCtrlOld & @CRLF )
  ;ConsoleWrite( "New: " & $sCtrlNew & @CRLF & @CRLF )
  If ( $sCtrlOld = "Button2" And $sCtrlNew = "DirectUIHWND2" ) Or _
     ( $sCtrlOld = "DirectUIHWND2Shift" And $sCtrlNew = "Button2" ) Then
        ControlFocus( $hExplorerWin, "", "[CLASSNN:SysTreeView321]" )
  EndIf

This defines the following tab order:

C:\-button --> C:\Windows --> TreeView --> ListView --> LV-Header

Opposite direction when the Shift key is pressed. See image in post 49.

If you add/modify/delete buttons, you must update the code accordingly.

 

Full code here: Windows Explorer example.7z

 

Replace the If-statement with a Select-statement to exclude LV-Header of the tab sequence:

Select
  Case $sCtrlOld = "Button2" And $sCtrlNew = "DirectUIHWND2"
    ControlFocus( $hExplorerWin, "", "[CLASSNN:SysTreeView321]" )
  Case $sCtrlOld = "DirectUIHWND2" And $sCtrlNew = "DirectUIHWND2"
    ControlFocus( $hExplorerWin, "", "[CLASSNN:Button1]" )
  Case $sCtrlOld = "Button1Shift" And $sCtrlNew = "DirectUIHWND2"
    ControlSend( $hExplorerWin, "", "[CLASSNN:SysTreeView321]", "+{TAB}" )
  Case $sCtrlOld = "DirectUIHWND2Shift" And $sCtrlNew = "Button2"
    ControlFocus( $hExplorerWin, "", "[CLASSNN:SysTreeView321]" )
EndSelect

 

Edited by LarsJ
Exclude LV-Header of the tab sequence
Link to comment
Share on other sites

LarsJ,  This is just amazing, going to save me 100s of keystrokes per day.  There are lots of forums with discussions how to get W7 explorer to work properly (as XP and before) and I can't find anyone who's done this.  Thanks.

Edited by RichardL
Link to comment
Share on other sites

  • 1 month later...

This is a big question. Can you be a little more precise? Do you want to disable drag? Do you want to disable drop? Do you want to disable drag/drop only internally in this right pane window? Or do you want to disable drag/drop from this window to/from external applications?

As for replacing some of the drag/drop functions with your own functions, this seems to be mostly related to the drop functions. Have I understood correctly? For example instead of copying the files, then generate a list of file names or the like.

The immediate response to the question whether it is possible to completely disable drag/drop functionality is no. Drag/drop appears to be deeply integrated in the entire Shell functionality including the methods and functions of the IExplorerBrowser interface as this right pane window is based on. There is no setting you just can turn on/off.

The only option seems to be workarounds where you interfere with the Windows messages, that are generated in connection with the implementation of the drag/drop functionality. You can prevent messages from being forwarded to the windows that are recipients of the messages, and disable the functionality in that way. Or you can execute your own code instead of the default code.

Many examples shows, that it is possible to implement such workarounds with a good result. In any case, it is necessary to conduct a thorough analysis of the message flow related to drag/drop functionality. To limit that analysis a little bit I would ask you to be as precise as possible.

It's probably the easiest to disable drop functionality. While it's probably more difficult to prevent initiation of a drag operation. But I will not just say that it can not be done.

Link to comment
Share on other sites

Yeah I thought to myself that it's not so simple.

My project:

The user should use my tool to create a package for an FTP server.
So you have an empty folder, displayed in your explorer control. And here the user can add his files. Later the content of this folder is packed in an .zip and will be uploaded to an FTP server.
After that the folder will be cleared an is ready for a new "package".
And here comes my problem: The user should not be able to drag some files from his desktop (for example) into the window in his folder. (Because Windows want to move the files in the new folder)
So i need to lock Drag´n Drop completly for this window/the explorer control. (if it´s possible)

I know it´s really special and hard to describe.
And it´s not a real problem if this is not possible with your UDF. (I currently use it simply beacuse of the nice and real explorer feeling ;) )

Thanks!

PS: Sorry for my bad english!

 

Edited by ISI360
Link to comment
Share on other sites

I'll see what I can do. Fortunately this weekend is a long weekend. I'll come back with an answer if not before then tuesday or wednesday next week.

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