The realization and application of PB tree-type catalogue

Source: Internet
Author: User
Tags readable

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.