VB File System control scheme

Source: Internet
Author: User

File System control scenario: File finder

Applications because users often want to quickly find available files or filegroups for an application, many applications provide the ability to query the file system. The Winseek.vbp sample application assists users in browsing drives and directories and displays all types of files.

The following table summarizes the controls that the Winseek application uses in the Seek.frm form.

Note File system controls do not have caption properties, although they can be tagged and the access keys specified. For more information about this method of using labels, see the "Using the Label Control" section later in this chapter.

Code for writing Winseek applications

Clicking an item in the Drive list box with your mouse triggers the Change event. The change event is also triggered when the user selects the item and then changes the focus on the form. In the Directory list box, you need the DblClick event to generate the Change event.

When the user does not want to change the directory with the mouse, usually use the arrow keys to select the desired directory, and then press ENTER.

Because the ENTER key is usually associated with the default CommandButton control, Winseek must identify when the user is just trying to change the directory without searching for the file.

The Winseek application solves the problem by determining whether the path to the Dirlist list box differs from the currently highlighted directory. This can happen when the user clicks an item in the Directory list box or moves through the Table of Contents list box with the arrow keys. The following code determines whether Dirlist.path is different from the highlighted directory. If different, update the Dirlist.path. If the same, the search operation is performed.

Private Sub cmdSearch_Click()
   .
   .
   .
'若 dirList.Path 与当前选定目录不同,
'则执行更新操作;否则执行'搜索操作。
If dirList.Path <> dirList.List(dirList.ListIndex) Then
   dirList.Path = dirList.List(dirList.ListIndex)
   Exit Sub
End If
'继续搜索。
   .
   .
   .
End Sub

Winseek applications use the following procedure to handle important events:

Drvlist_change process

Dirlist_change process

Cmdsearch_click process

DriveListBox control's Change event

The control's change event is generated when the user clicks an item in the Drive list box. The Drvlist_change event procedure is invoked and the following code runs: Private SubdrvList_Change ()
    On Error GoTo DriveHandler
    '若选定新驱动器,则 Dir1 列框'更新显示 。
    dirList.Path = drvList.Drive
    Exit Sub

' If an error occurs, reset the drvlist.drive with Dirlist.path.

 DriveHandler:
    drvList.Drive = dirList.Path
    Exit Sub
  End Sub

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.