Making a Document Browser
Document ID: IR10050The information in this article applies to:
- AutoPlay Media Studio 5.0 Professional Edition
SUMMARY
This article describes how to make a document browser
DISCUSSION
As an example, we will create an application that has the user select a folder on his drive, and then populates a listbox object with all of the *.doc files within that directory. The user clicks on a file in the listbox object, and clicks the "Open" button to open the document.
- Create a project with one listbox object, and two button objects.
- Label Button1 "Load" and Button2 "Open".
- Insert the following code into the On Click event for Button1:
--Disable listbox Updating ListBox.SetUpdate("ListBox1", false);
--Get the desired folder to browse
folder = Dialog.FolderBrowse("Open Folder", "C:\\");
--populate a table with all the .doc files
file = File.Find(folder, "*.doc", false, false, nil);
--do the following for each file:
for j,file_path in file do
--add the item to the listbox, with the name visible and path as data
ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
end
--Allow the listbox to display the updated content ListBox.SetUpdate("ListBox1", true); - Insert the following code into the On Click event for Button2:
selected = ListBox.GetSelected("ListBox1");
for j,k in selected do
File.Open(ListBox.GetItemData("ListBox1", k),"", SW_SHOWNORMAL);
end
MORE INFORMATION
KEYWORDS: AutoPlay Media Studio 5.0, Document, Browser
Last reviewed: September 26, 2003
Copyright © 2003 Indigo Rose Corporation. All rights reserved.
Comment