For users who often use Delphi, the following explanation may be too preliminary. Even so, you 'd better browse it so that you can discover things you didn't know or recall forgotten things.
Use Form Designer
Delphi Form DesignerIt is a powerful visual programming tool that can place components, select components, move components, reset component sizes, and align components. Form Designer can set the size and position of the form, add a menu, and create a special dialog box-all required to create a user interface for a typical window program.
The Form Designer is a blank window at the beginning. The window designer can be seen as an artist's canvas, which can depict a variety of Windows applications. The user interface of the application is implemented by the form. You only need to select a component from the component panel and place it on your form to interact with the Form Designer. You can use the mouse to adjust the position and size of the component on the Form Designer, and use the object inspector and code editor to control the appearance and behavior of the component.
I hope you can stop and experiment at any time if you are wondering how something works. Sometimes a few minutes of lab will teach you how to use the technology for a long time.
Quick menu of Form Designer
When you start Delphi or develop a new project, you are faced with an empty form in Form Designer. Like most Delphi windows, Form Designer has matched shortcut menus. As shown in:
- Align to GridAlign the selected component with the Form Designer coordinate grid.
- Bring to frontTake the selected component to the front of all other components.
- Send to backSend the selected component to the end of all other components.
- Revert to inheritedRestore the selected control to its original state when you use a form transplanted by Object repository.
- Align...Show alignment dialog box
- Size...Show size dialog box
- Scale...Show scale dialog box
- Tab order...Show edit tab order dialog box
- Creation order...Show the creation order dialog box
- Flip children...For Windows in non-English versions, this command changes the reading sequence of components and is not applicable to English versions.
- Add to respository...Add the form to the object repository. The custom form can be stored and used later.
- View as text...In code editor, the form description is displayed in text. Select view as form from the code editor shortcut menu and return to the original form. You can also use Alt + F12 to switch the display view as text/view as form option.
- Text DFMSave the form as a text file.
Place Components
It is easy to place components on the form. All you need to do is select the required component from the component option board and click on the form to place the component. When you click on the form, the upper left corner of the component is placed in the click position. Note that when you click the button on the component palette, the button is pressed down. When a component is clicked on the form, the button on the component option board is displayed again to show that the action is complete.
Tip
As you have learned in the previous section, you can place components on the form multiple times, start to shift when selecting the component button on the color palette, and click on the form each time, new components will be added. On the component palette, click the arrow (arrow) to stop placing the component.
You can set the size of most components. You can place the component on the form, set its size, or set it at the same time. To set the size of a widget, click the desired widget and drag the mouse until the widget size is appropriate and the mouse is released.
Note
Not all components use this method to set the size. For example, a non-visualized component is represented by an icon on the form. Although you can click and drag to place non-visual components, the drag size is ignored. Another example is the single row Editing Component (edit), which can be placed by drag and drop, but can only be used by the drag width, while the drag height is ignored.
Caution
If you change your mind when you move the widget by dragging it, you can cancel the operation by pressing ESC before releasing the mouse. However, the widget button is still in the pressed status on the widget palette, so you can continue to place the widget, if you want to cancel the task, press the arrow to return to the component selection status.
Form Designer Mesh
The internal coordinate grid of Form Designer Helps design the form. The initial size of the coordinate grid is set to horizontal 8 pixels and vertical 8 pixels. When Form Designer is set to display a coordinate grid, a point is placed at the intersection of each coordinate grid. Components placed on the form will jump to the nearest coordinate grid. "Snap to Grid"Means that the upper left corner of the component automatically jumps to the nearest coordinate grid. As long as it is close enough to the correct position, Form Designer automatically places the component on the nearest coordinate grid.
You can use 【Tool | environment OPTIONS...] OpenEnvironment optionsThe designer page in the dialog box changes the settings of the coordinate grid. You can change the size of the coordinate grid or disable the snap to grid feature, or enable or disable the "display grid" grid coordinate display. When the coordinate grid display is disabled, the coordinate grid is still valid (when snap to grid is open), but the points marked with the coordinate grid are not drawn on the form.