1. Introduction
In the development of MIS, it is often necessary to get the tree directory structure and corresponding file information in the local computer, such as the choice of the catalogue and the selection of special files, and the PowerBuilder (PB) does not provide a special tree directory object. This requires the developer of the program to implement the appropriate tree directory. In this paper, a method of using pure PB code to realize tree structure is presented.
Implementation of tree-type catalogue in 2.PB
The implementation of the tree directory in PB can take advantage of Windows ' own API function Shbrowseforfoldera (included in the Shell32.dll file), but the API function can only display the corresponding tree directory, cannot display the file information, and the user does not have the flexible control to it. Therefore, if you need flexible control, you need the program staff to write the appropriate code.
The ListBox list box control in PB provides the ability to display directories and files. In a program, you can dynamically generate a tree directory structure using the PB Tree-Shape control treeview. We do this using the function Dirlist of the ListBox control, where the function dirlist populates the list items of the list box with the filename that satisfies the condition, using the following method:
Listboxname. Dirlist (file mode, file type)
The value of the file type is as follows:
0 |
Readable/writable files |
2 |
Implied file |
16 |
Sub Directory |
16384 |
Drive |
1 |
Read-only files |
4 |
System files |
32 |
Archive file |
32768 |
All types except readable/writable |
Several types of values can be added to a program to get the appropriate file or directory information. The following is an example of how to implement a tree directory, as shown in Figure 1.
Figure 1 An instance of a tree-type directory implementation
The tree directory allows you to get any directory on your computer and then display the files you want to display (in this case, the type of file the browser can view: Htm,html,swf,gif,jpg,txt, etc.). The main controls used in the program are as follows:
Control Name |
Type |
Description |
Tv_dir |
Treeview |
Show Tree Directory |
Lb_file |
ListBox |
Display files in the appropriate directory |
Ole_disp |
Microsoft Web Browser Control |
Browse for selected files |
Lb_dir |
ListBox |
Display drive Information |
Lb_next |
ListBox |
Display the current directory subdirectory information |