Unlocking the Secrets of the ShellDocVwCtl
As I was working with the WebBrowser control the other day, I noticed another control in the toolbar that I had not seen before: the ShellDocVwCtl. I had heard of the amazing power locked in the ShellDocVw.dll, but had not really had the time to be able to investigate its full potential. However I was a little disappointed when I looked at the control, as it had no properties as such. So, I decided to look in the Object Browser to see if there was anything else that I could do. Lo and behold, there were several classes with lots of different things to play about with. The first thing I did was to create one of these classes in code and have a play around:
Dim ShellControl As New Shell
To add a reference to the object library select References... on the Project menu. Scroll down the list until you find the Microsoft Internet Controls. Select this, then click OK. If you can't find it, you may need to install Internet Explorer 4.
Browse For Folder Dialog Box
Function BrowseForFolder(HWND As Long, _
Title As String, Options As Long, [RootFolder]) _
As Folder
Use it as follows:
| Hwnd | Set this as the window handle for the owner form, eg. Me.Hwnd |
| Title | The text which is displayed above the list of folders (not the caption for the window) |
| Options | 0 if the users can select anything (ie. including control panel, etc.) and 1 if the user must select a proper folder (eg. c:windows) |
This returns a folder object which we will look at later. For example
Set mynewfolder = ShellControl.BrowseForFolder(Me.hwnd, _ "Choose a folder", 0)
CascadeWindows, TileHorizontally, TileVertically
Sub CascadeWindows() Sub TileHorizontally() Sub TileVertically()
These three methods are the same as right-clicking on the task-bar and selecting the respective item. For example:
ShellControl.CascadeWindow 'will cascade all the windows
