Dialog Box form of Delphi

Source: Internet
Author: User

The form can also be used as a dialog box. In fact, there is no difference between the Delphi Form as a dialog box and the real dialog box.

"Real dialog boxIt refers to a dialog box created using a traditional method. It has a resource compiler and a resource script file. In other programming environments, the dialog box is created using this method, delphi does not use the traditional dialog box ).

The dialog box has the following features, which are different from the normal form:

1,Normally, the dialog box cannot be resized. They are usually used to complete a special function. It is useless to change the dialog box size;

2,There is almost always an OK button in the dialog box, and some dialogs have a close button, which completes the same task. A typical simple dialog box has only one OK button, for example, the dialog box about the about in Delphi 7 is as follows:

3,The dialog box may contain a cancel (close) button and a help button;

4,A dialog box is the tabbed dialog boxes dialog box. This dialog box displays several tag buttons that you can choose from. When you click a tag button, different pages of the dialog box are displayed, for example, Delphi 7 main menu [tools | environment option ...] The dialog box is as follows:

5,In most dialogs, the tab key can be used to move from one control to another adjacent control;

6,A dialog box usually has a system close button on the title bar, which usually does not have a minimization or maximization button.

There are exceptions for each rule. Most dialogs have these common features, but some dialogs execute some special tasks, in this way, it will be different from these formal situations.

 

Delphi dialog box

In Delphi, the dialog box is just another form. Creating a dialog box is the same as creating a Main Window form or other forms. To prevent scaling in the dialog box, you must set the borderstyle attribute of form to bsdialog or bssingle. You can change the order of tab key switching by changing the taborder attribute of each space in the dialog box.

Mode)A dialog box is a dialog box that must disappear before the user continues to use the application. When this dialog box is opened, the main form of the application stops working. Most of the dialogs are modal dialogs.

Modeless)The dialog box is a dialog box in which you can continue to make the application work. The FIND dialog box in some word processing programs is a non-mode dialog box.

The Delphi dialog box (actually any Delphi Form) is a display mode that relies entirely on mode or non-mode. to display a mode dialog box, you can call the showmodal method of tform, to display a non-mode dialog box, call the show method of tform.

 

Create Dialog Box form

1,Open theSimplest multi-form application (Delphi)", You can view the MRU (recently used) list through the" file | reopen "button in the main menu or the arrow next to the" open "button in the toolbar. The list is divided into the upper and lower sections. The top part is the five projects that have been recently used, and the 10 recently used files are displayed at the bottom. You only need to click these projects or files to re-open the project or file, for example:

2,After opening the multiple project, we will change the mainform caption attribute of this project to "about dialog forms test program", and change the caption attribute of the btnshowform2 button to "show about ";

3,Use the "View forms" button in the toolbar or press SHIFT + F12 to display the secondform, change the borderstyle attribute of the secondform form to "bsdialog", and change the caption attribute to "about ";

4,Place a bitbtn button on the additional tag card on the secondform, and set the kind attribute of the button to "bkok". The caption attribute of the button is automatically changed to "OK ", in this case, the bitbtn button contains the code to close the form when you click OK, as shown below:

5,Return to the mainform and double-click "show about" to see the Code as follows:

Procedure tmainform. btnshowform2click (Sender: tobject); begin secondform. showmodal; {display secondform mode window} end;

6,After you press F9 to run the program, click "show about" to display the "about" dialog box. Note that this dialog box is a mode dialog box and cannot be scaled, as shown below:

Note

General dialogs (topendialog, tsavedialog, tfontdialog, etc.) do not represent the dialogs created in the Delphi Form. Windows provides these dialogs as a set of dialog boxes, which can be used by all Windows applications, (In fact, these dialogs are included in the system's comdlg32.dll file). The VCL dialog box class encapsulates this general dialog box for ease of use.

* All the above Code passes the test in Delphi 7. Download the sample code:Dialog Box .rar

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.