mr_unreliable
Sun Aug 20 13:08:27 CDT 2006
This is a multi-part message in MIME format.
--------------010200060209000406080905
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
The attachment is an HTA app file, made up to crudely resemble
windows explorer -- and to show the (music?) files in a folder.
The fake explorer uses a listview control, just as the REAL
windows explorer does. There are various listview controls
available, the one used here is from vb6 as found in mscomctl.ocx.
If you have vb6 installed, or any vb6 app installed you can most
likely find this ocx on your system. You could also use the vb5
version (comctl32.ocx) if you have that. Even if you don't have
some version of the vb compiler, or some vb app installed, you may
be able to find one of the above ocx's on one of the dll download
sites. Also, some pc suppliers will have pre-loaded the vb
common control dll's/ocx's when they deliver their systems to you.
Finally, there are other listview controls out there. For example,
Steve McMahon offers a listview control that is "better"
(more features) than microsoft's.
http://www.vbaccelerator.com/home/VB/Code/Controls/ListView/article.asp
If you try this, you may note that there are no icons for each
file or folder, as windows explorer provides. For this, you
need an imagelist control to work with the listview control.
That requires a "two-pass" process, whereby you scan what's in
the folder and look up (in the registry) what icons to use.
Then there may be some further adjustments necessary to get
the "right size" icon (16x16). Then you set up the imagelist
to contain the icons to use. I believe this is "do-able" from
script -- there is an imagelist control in the ocx -- but
I considered that to be "out-of-the-scope-of-this-project"
(as they say in the business world).
And yes, there is no menubar or toolbar of the sort to be
found with windows explorer. However, there are countless
html/dhtml menubars and toolbars to be found on the various
web development sites. So if you really need one, they are
easy to find.
After all those caveats, is there really any value here?
Could be, if you are looking to display your folder (music,
or any other folder for that matter) in some non-standard way.
The folder displayed by this hta (my documents \ my music)
is built into the code, but easy enough to change. For
more flexibility, one may wish to make the folder a
(command line) parameter.
cheers, jw
--------------010200060209000406080905
Content-Type: text/plain;
name="fakeExplorer_(forMusic).hta.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="fakeExplorer_(forMusic).hta.txt"
<HTML>
<HEAD>
<HTA:APPLICATION ID="ohta" APPLICATIONNAME="testListView"
WINDOWSTATE="normal" SCROLL = "no" BORDERSTYLE="normal" BORDER="thin"
CAPTION="yes" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="no" ICON="mru.ico"
SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" VERSION="1.0" >
<TITLE> << Testing ListView Control w/HTA script >> </TITLE>
<SCRIPT LANGUAGE="vbScript">
<!--
Option Explicit
' --- global constants ---
Const sMsgBoxCaption = " < Fake Windows Explorer Demo > "
Const wdDlg = 600, htDlg = 400, leftDlg = 100, topDlg = 100
'
Const lvwReport = 3 ' listview "report" format
Const lvwColumnRight = 1 ' align data to the right
'
Dim sMusicFolderSpec ' as string (used in click event handler)
Sub dlgInit() ' dialog initialization
Dim wshShell ' as object
' MsgBox("dialog initialization called")
' do a little adjusting of my size and location...
window.ResizeTo wdDlg,htDlg
window.MoveTo leftDlg,topDlg
' reposition the statusbar to the bottom of the dialog...
With Document.getElementById("statusbar").style
.backgroundcolor = "silver"
.position = "absolute"
.left = 5
.top = Document.Body.clientHeight - 25
.width = Document.Body.clientWidth - 10
End With
With window.document.getElementById("etchedEdge").style
.position = "absolute"
.left = 8
.top = Document.Body.clientHeight - 32
End With
' initialize the listview control...
With oLVW
.Width = Document.Body.clientWidth - 20 ' fit the listview into the dialog
.Height = Document.Body.clientHeight - 35 - 50
.Font.Name = "MS Sans Serif"
.Font.Size = 8
.Font.Bold = False
.View = lvwReport
.ColumnHeaders.Add , , "Name", 250
.ColumnHeaders.Add , , "Size", 80, lvwColumnRight
.ColumnHeaders.Add , , "Type", 80, lvwColumnRight
.ColumnHeaders.Add , , "Modified", 125, lvwColumnRight
End With
' construct path to the music folder of choice (or, look to arguments)...
Set wshShell = CreateObject("WScript.Shell")
sMusicFolderSpec = wshShell.SpecialFolders("MyDocuments") & "\My Music"
Document.title = " Contents of: " & sMusicFolderSpec
Call PopulateListView(sMusicFolderSpec) ' from music folder
End Sub
Sub PopulateListView(sFolderPath)
Dim fso ' as object
Dim oMusicFolder ' as folder object
Dim colFiles, colSubFolders ' as collection(s) (files, folders)
Dim myFile, mySubFolder ' as file,subfolder object
Dim curItem ' as file/folder object
Set fso = CreateObject("Scripting.FileSystemObject")
if NOT (fso.FolderExists(sFolderPath)) Then ' validity check
MsgBox sFolderPath & " is an invalid path" & vbCrLf & _
" this app will terminate now", vbCritical, sMsgBoxCaption
self.Close
End If
Set oMusicFolder = fso.GetFolder(sFolderPath) ' get folder object
Set colFiles = oMusicFolder.Files ' file collection
Set colSubFolders = oMusicFolder.SubFolders ' folder collection
' statusbar message...
Document.getElementById("statusbar").Value = _
" there are: " & CStr(colFiles.Count) & " files in this folder" _
& " (and " & CStr(colSubFolders.Count) & " subfolders too)... "
' fill in the listview entries...
For Each mySubFolder in colSubFolders
' .Add(index, key, text, icon, smallIcon)
Set curItem = oLVW.ListItems.Add( , , mySubFolder.Name)
With curItem
.SubItems(1) = "" ' leave the size blank
.SubItems(2) = mySubFolder.Type ' extension
.SubItems(3) = mySubFolder.DateLastModified
End With
Next
For Each myFile in colFiles
' .Add(index, key, text, icon, smallIcon)
Set curItem = oLVW.ListItems.Add( , , myFile.Name)
With curItem
.SubItems(1) = CStr(myFile.Size\1000) & "KB"
.SubItems(2) = myFile.Type ' extension
.SubItems(3) = myFile.DateLastModified
End With
Next
End Sub
Sub oLVW_Click() ' listview click event handler
Dim selListItem ' as LV item
Dim nReply ' as integer
Set selListItem = oLVW.SelectedItem
Select Case selListItem.SubItems(2) ' what was the item-type selected?
Case "File Folder" : MsgBox("repopulating listbox not supported") : Exit Sub
Case "mp3 file"
nReply = MsgBox("You selected: " & selListItem.Text & vbCrLf & _
" Would you like to play it now", vbQuestion Or vbYesNo, _
sMsgBoxCaption)
if (nReply = vbYes) then PlayTheSelection(selListItem.Text)
Case Else : MsgBox("unsupported file type") : Exit Sub
End Select
End Sub
Sub PlayTheSelection(sSelectedItem)
Dim sSaveStatusMsg ' as string
Dim sPathToSelection
Const bWaitOnReturn = True
Dim wshShell ' as object
sSaveStatusMsg = Document.getElementById("statusbar").Value
sPathToSelection = sMusicFolderSpec & "\" & sSelectedItem
Document.getElementById("statusbar").Value = " Now Playing: " & sPathToSelection
' assume mp3 (for now) and play it...
Set wshShell = CreateObject("WScript.Shell")
' note: wrap the path in quotes, in case of BLANKS in the path ("""" is ONE dq)...
wshShell.Run """" & sPathToSelection & """",, bWaitOnReturn
' assume music player finished, restore statusmsg and return
Document.getElementById("statusbar").Value = sSaveStatusMsg
End Sub
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="silver" scroll=no onload="dlgInit()" language="vbScript">
<FONT FACE="verdana,arial,helvetica" SIZE=1>
<A HREF="#" ONCLICK="self.close()">Your html/dhtml toolbar goes here...</A>
</FONT><hr>
<!-- this is the vb6 listview control, as found in mscomctl.ocx -->
<OBJECT ID="oLVW" WIDTH=0 HEIGHT=0
CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
</OBJECT>
<hr id="etchedEdge">
<font face="MS Sans Serif" size=2>
<input type=text id="statusbar" align=absbottom
value=" please stand by while the files are being enumerated... ">
<center><BUTTON onclick="self.close()" style="visibility: hidden; "> Close this Dialog </BUTTON></center>
</font>
</BODY>
</HTML>
--------------010200060209000406080905
Content-Type: image/x-icon;
name="Mru.ico"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="Mru.ico"
AAABAAEAICAEAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD/
/wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AA7u7u7u4AAAAAAAAAAAAO7u7u7u7u7uAAAAAAAAAA7u7u7u7u7u7uAAAAAAAADu7u7u7u7u
7u7uAAAAAAAA7u7u7gAA7u7u7gAAAAAADu7u4AAAAAAO7u7gAAAAAA7u7gAAAAAAAO7u4AAA
AAA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