Document directory
- (1) The project group context menu)
- (2) the project context menu)
- (3) The unit context menu)
- (4) The file context menu)
Project is the life of Delphi. It is impossible to create a program without engineering. The project can combine all working groups to create executable applications.
Generally, each project needs to be managed. You may need to add a new unit to the project or delete a unit from the project. You may need to add another type of file (such as a binary resource file) to the project. To add or delete a unit and its project files, you must use project manager.
Project Groups)
A project is a collection of files that work together to create an independent executable file or DLL. This is the definition of the project involved by Delphi IDE. In reality, there are various types of projects. For example, a job to be completed can also be called a project.
A large project can contain one or more executable files and several dynamic link libraries (DLLs). Because some projects consist of multiple (not a single) executable programs, delphi allows several projects to be put together to form a group, so that all the projects in the group can be processed as a separate whole. This whole is called a project group.
1. Why use a project group ?)
You may ask: what are the advantages of a project group? The advantages of a project group are as follows:
- Make the complete software engineering control more convenient.
- You can modify the DLL and the EXE of the test DLL at the same time.
- A group of projects can be compiled and linked at a time.
- You can open multiple projects at the same time and switch back and forth between open projects.
- A solution for organizing related projects is provided.
Creating a project with a single executable file does not require a project group. A single project cannot be considered as a group, right? In a single project, the concept of a project group is inappropriate.
However, imagine that a program contains an EXE file and a single DLL. The DLL and exe are linked together. When you modify a DLL, you generally want the EXE to be next to it. You can immediately test the DLL modification effect. In this case, it makes sense to use a project group, because the EXE and DLL are always together.
You can create a project group that contains the EXE and DLL. When you want to modify an application or DLL, you can open the project group (instead of a single project ). After the project group is opened, both the EXE project and the DLL project are displayed. You can use code editor to modify DLL or EXE and switch back and forth between them. For example, the Project Manager window opens such a project group.
Another reason for using a project group is that the associated project can be organized together. It seems that this sentence is of little significance. Let's explain it below. For example, a company has a set of serial communication components. The components are divided into three categories: Basic serial communication, fax, and TAPI. Each category contains many sample programs.
In this case, you can create a project group for the fax program, create a project group for the program in the TAPI class, and create a project group for the program in the basic Serial Communication Class. In this way, you open the TAPI project group and place all the TAPI sample programs in it. The entire project group can be compiled and linked at the same time, saving time and simplifying the operations for opening and compiling each project. Here, each project does not work together as EXE and DLL, but these projects are related, so the concept of engineering group is meaningful.
2. Active Project)
There is always an active project in any project group, which is displayed in bold in project manager. In the figure above, the active project is testdll.
When you select a compile or build menu item from the main menu of Delphi, the activity project will be compiled and linked.
Each time a project is set as an active project, both menu items change. For example, if the active project name is project1, the two menu items are [compile project1] and [Build project1]. If you set a project named pictview as an active project, the two menu items are "compile pictview" and "build pictview ].
You can use the Delphi Main Menu or the Delphi toolbar to add elements, such as new forms or units, to the current active project.
There are multiple ways to set a project as an active project.
- One method is to select any item on the project node to be set as an active project, and then click the "active" button at the top of the Project Manager window.
- Another method is to double-click the project node to be set as an active project.
- The last method is to select the "active" menu item from the shortcut menu of the Project node to activate a project.
The Project Manager window)
The project manager is the central controller for all projects and engineering groups. You can use the project manager to add files to the project, delete files from the project, view units or forms, add projects to the Project Group, and change the order of projects. You can select the [View | Project Manager] menu item on the main menu or press CTRL + ALT + F11 to display the project manager.
The Project Manager window contains a tree-like list control, which can display up to four layers. The four layers are:
- Engineering Group
- Projects in the Project Group
- Forms and other files in the project
- Single Form file and unit under the form node
Naturally, a single node can be expanded or shrunk in any Tree View control. The Project Manager node has icons to indicate whether the node contains a project, a single file, a form, or a form/unit. For example:
Note
View the path and file name of a unit in project manager. Click the unit in the Project Manager window. The Project Manager Status Bar displays all the paths and file names of the unit. For example:
1. Project Manager shortcut menu (the project manager context menus)
Most of the work of the Project Manager is done through the Project Manager shortcut menu. Project Manager has four independent shortcut menus, which are described below.
(1) The project group context menu)
Right-click the project group node at the vertex of the Project Manager tree. The shortcut menu of the project group is displayed. For example:
- [Add new project ...] -- Open the object library and select a new application, DLLs, form, data module, component, or other valid objects in the object library.
- [Add existing project ...] -- Open a project file stored on the disk and add it to the Project Group.
- Save project group: Save the project group. The project group extension is. BPG.
- [Save Project Group ...] -- Save the project group with a new project group name.
- View project group Source: displays the source file of the project group. A project group source file is a special file (A makefile) that contains references to all projects in the project group.
- [Toolbar] -- open or close the toolbar of project manager.
- [Status Bar] -- open or close the project manager status bar.
- [Dockable] -- specifies whether the project manager can be positioned.
Note
Each shortcut menu in Project Manager contains the toolbar, Status Bar, and dockable menu items. Next we will not repeat the shortcut menu of other project managers.
(2) the project context menu)
Right-click the project node in project manager and the project shortcut menu is displayed. For example:
- [Add ...] -- Open the add to project dialog box and add files to the project. Select project | add to project from the main menu or the Delphi toolbar. This dialog box can also be opened.
- [Remove File ...] -- Open the remove from project dialog box and delete files from the project. Select project | remove from project from the main menu or the Delphi toolbar to open this dialog box.
- [Save] -- save the project. You can also choose file | save from the main menu to save the project.
- [Options] -- display the Project Options dialog box for the project. You can also select project | options from the main menu of Delphi to display the Project Options dialog box.
- [Activate] -- changes a project into an active project.
- [Compile] -- compile the project.
- [Build] -- Build (compile and connect) the project.
- View Source: displays the project source file (DPR file ). You can also select project | View Source from the main menu to display the project source files.
- Close: Close the project and all files. If a part of a saved project group is in the project, the project node icon becomes grayed out; it is still part of the project group, but cannot be opened in IDE. If the project is part of the default Project Group, close the project and remove it from the default Working Group.
- Remove project -- delete a project from the project group. Note that the project is not deleted from the hard disk, but removed from the Working Group. You can also click "Remove" in the Project Manager toolbar to delete the project from the Working Group.
- [Build sooner] -- move the project to the upper part of the Project tree. Compile the link project in the top-down order.
- [Build later] -- move the project to the lower part of the Project tree.
Note
The Project Manager shortcut menu contains more content than described in this section. If it is a batch file project or a package project, the project shortcut menu contains additional menu items. These additional menu items are not described as they are not much different.
(3) The unit context menu)
When you right-click a cell node in Project Manager, the cell shortcut menu is displayed. For example:
- [Open] -- display a unit in Code Editor (for an independent unit), or display a form in Form Designer (if the unit has an associated form ).
- Remove from project -- delete a unit from the project. When a project manager is deleted, a message is not displayed, so the deletion cannot be undone. If you accidentally delete a unit, add it to the project.
- [Save] -- save the unit. You can also choose file | save from the main menu of Delphi to save.
- [Save ...] -- Open save... Dialog box, save the unit with the new unit name, or select file | save as… from the main menu of Delphi ...] To complete the same operation.
(4) The file context menu)
When you right-click a node other than a project group node, project node, or unit node (usually a. Pas or. DFM file), the file shortcut menu is displayed. For example:
This shortcut menu has only one menu item, [open] The menu item displays the selected node in code editor or Form Designer (determined by the type of the selected node, whether it is displayed in code editor or Form Designer ).
2. Project Manager toolbar and Keyboard Command (the project manager toolbar and keyboard commands)
In addition to the project manager shortcut menu, project manager has a toolbar that facilitates the operations of the Project Manager. The Project Manager Toolbar contains three buttons:
- Add new project button. This button displays the object repository object library to add a new project to the Project Group. You can also click the Add new project menu item in the Project Group shortcut menu to add a new project to the Project Group.
- Remove button. This button deletes the selected project, unit, and file from the project group.
- Active button. This button activates the selected target as an active project.
Keyboard commands include the delete key and the Insert key. When you press the delete key, the selected node is deleted. If a project node is selected, the project is deleted from the project group. If a unit node is selected, the unit is deleted from the project. The Insert key function is the same as the add to project function of the Project shortcut menu.
Tip
Project Manager toolbar buttons can be in two sizes. You can drag a button at the bottom of the toolbar to change the size of the toolbar button. Drag a small button up and drag a large button down.
Create and use a project group)
For complex projects, it is very helpful to use a project group, but it is not mandatory to use a project group. It is not necessary to use a project group for each project. Project manager has a default project group named projectgroup1, which can be used when a project group is not specifically opened or created. Try the following steps:
(1) Select File | close all to close all open projects or engineering groups.
(2) Select File | new application to create a new application.
(3) select View | project manager to display the project manager. For example:
Projectgroup1 is a temporary project group. When you select File | save all from the main menu, the system will prompt you to save the project instead of saving the project group. To save the project group, you must use SAVE project group or save Project Group ...] Menu to save it.
1. Add a unit (adding units)
To add an existing unit to the project, you only need to click the Add button on the Project Manager toolbar or select Add… from the Project Manager project shortcut menu ...].
If there is a form in the project with the same name as a unit, you cannot add this unit to the project.
2. Removing units)
You can use the remove from project option to delete files from the project. In addition, you can also select the unit to be deleted, and then press the delete key on the disk. Files deleted from the project are not deleted from the hard disk, but are only removed from the project compilation/link process.
Note
When deleting a unit from a project, be careful not to delete the unit referenced by other units in the project. If the unit used by the project is deleted, compilation errors may occur. Before deleting a unit, check whether the unit is used in the project. If you accidentally delete a unit that is still required by the project, you can add it back to the project with the add to project option.
Click Remove File… in the project shortcut menu ...], The "Remove from project" dialog box is displayed. This dialog box allows you to select multiple units. Therefore, you can delete multiple unit files at the same time. For example:
3. View A unit or form (viewing units or forms)
To view a cell, form, or other files, double-click the form or cell node you want to view. You can also select the [open] menu item from the Project Manager shortcut menu, and the form or unit will be displayed in Form Designer or code editor (based on the type of the selected node ).
Building projects or project groups)
To compile and link a project, follow one of the following methods:
- Right-click engineering electromechanical in project manager, and select build from the shortcut menu.
- Select project | build <Project Name> from the Delphi main menu ]. The name of this menu item automatically changes with the Project Name of the current active project.
- Press Ctrl + F9 on the keyboard to compile the current active project.
To compile and link the entire project group, select project | build all projects from the main menu of Delphi. All projects in the Project Group will be compiled and linked, the sequence is from top-down from the first project in the Project Group to the last project.