Sixth chapter-Document management (iii) (8)

Source: Internet
Author: User
Tags exception handling

Display of 6.4.8.2 status bar

The status bar is used to display the current directory and the currently selected file. Their values are modified during the Change event processing of Directoryoutline and filelist.

The final change event process for Directoryoutline and FileList is as follows:

Procedure Tfmform.directoryoutlinechange (Sender:tobject);

Begin

Createcaption;

Filelist.clear;

Filelist.directory: = directoryoutline.directory;

Filelist.update;

FileManager.DirectoryPanel.Caption: = directoryoutline.directory;

End

Procedure Tfmform.filelistchange (Sender:tobject);

Begin

with FileList do

Begin

if (itemindex >= 0) and (not Hasattr (filename,fadirectory)) Then

Begin

Thefilename: = FileName;

FileManager.FilePanel.Caption: =

Format ('%s,%d bytes ', [Thefilename, GetFileSize (thefilename)]);

End

Else

FileManager.FilePanel.Caption: = ';

End

End

6.4.8.3 Version Information

When the user clicks the help| of the main window The About menu item pops up an About dialog box to display version information (Figure 6.13).

This dialog box is made from the template provided by Delphi.

The ash and the 6.4.8.4 of the menu items

The file management feature defined in the Files menu works only if the active focus is filelist (that is, the currently selected file). Otherwise all menu item strain Ash, lest cause system crash.

This functionality is implemented during the Click event Handling of the File menu. This is not easy to think of, and I hope readers can be inspired.

Procedure Tfmform.file1click (Sender:tobject);

Var

Fileselected:boolean;

Begin

fileselected: = Filelist.itemindex >= 0;

open1.enabled: = fileselected;

delete1.enabled: = fileselected;

copy1.enabled: = fileselected;

move1.enabled: = fileselected;

rename1.enabled: = fileselected;

properties1.enabled: = fileselected;

End

Determines whether a file is selected by detecting whether the ItemIndex property is greater than or equal to the 0来 implementation.

fileselected: = Filelist.itemindex >= 0;

6.4.8.5 reusable file-processing module

The Library unit Fmxutils is a code base that provides a number of file processing modules. These modules, in addition to being used in this program, can be invoked directly in other applications and do not have to be recompiled, as long as they are included in the uses clause. From this we can realize that Delphi provides a better code reuse mechanism for the central Program Organization mode of the library unit.

Summary of 6.4.9

File Manager is a more comprehensive routine, the use of most of the file name, file handle and other parameters (in addition to file variables) for the operation of the document management process/function, but also provides some ideas for program design and development. Our presentation is organized in a program functional module, and I recommend that readers use the same approach when they are learning and trying to establish the program themselves. The contents of (6.4.8) may be understood from the outset, but others can be incrementally expanded sequentially, and finally a complete program is obtained. This routine is used in the following sections, such as drag-and-drop operations and exception handling. The reader can use this as a basis to further refine it, so that it truly becomes a fully practical program.

File management is an unavoidable issue in the development of a high-level Windows program. The ideas and methods presented in this chapter will provide the basis for the reader to become a skilled programmer.

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.