1. Customized Speedbar
In Delphi's visual design interface, the most frequently used place is the acceleration button bar (Speedbar) located in the upper left corner of the screen. During the practice, the author accidentally discovered the customization method of Speedbar, which was not mentioned in the four Delphi reference books I have used. The steps are as follows:
Right-click the Speedbar and select PRperties in the pop-up menu. A dialog box called SpeedbarEditor will appear. Suppose you want to add a "syntax check" function, you can select Project in the Categories list box on the left, then drag and drop the Syntax Check icon on the right to the appropriate position of the Speedbar, and this function has been added. If there is no extra space on the speedbar to accommodate the new button, you can stop the mouse at the right frame of the speedbar. When it changes into the shape of a double-headed arrow, drag it a certain distance to the right to make room. If you want to delete a button on the speedbar, you can simply drag it out of the speedbar range and delete it. Very convenient to operate. It is recommended to add Syntax Check, Project Options, and WindowsApi Help to Speedbar to improve development efficiency.
2. Shortcut keys when designing Form
Use shortcut keys to speed up your design. The shortcut keys listed below can be mastered selectively according to the actual situation.
Del: Delete the selected component;
Esc: Select the container of the current component (usually Panel, Group or Form);
F11: Switch between Form or Unit and Object Inspector;
F12: Switch between Form and code editor;
Ctrl+F12: Display the "View Unit" dialog box;
Shift+F12: Display the "View Form" dialog box;
TAB: next component;
Shift+TAB: Previous component;
Direction keys: select the nearest component in this direction;
Ctrl+arrow keys: Move the selected component one point;
Shift+arrow keys: Change the size of the selected component by one point;
Ctrl+Shift+arrow keys: Move the selected component one space;
Shift+click: Hold down the Shift key and click the component with the mouse to select multiple components.
The following is what I figured out:
Ctrl+drag: Hold down the Ctrl key and drag the mouse in a container component (such as Panel, QReport, Groupbox, etc.) to force the selection of all visual components belonging to this container (excluding the container component) in the rectangular box dragged by the mouse. .
3. Use of command line parameters
Delphi provides a convenient way to access command line parameters, that is, using the ParamStr and ParamCount functions. ParamStr(0) returns the current program name, such as C:TESTMYPROG.EXE, ParamStr(1) returns the first parameter, and so on; ParamCount is the number of parameters. Examples are as follows:
var
I: Word;
Y: Integer;
begin
Y := 10;
for I := 1 to ParamCount do begin
Canvas.TextOut(5, Y, ParamStr(I));
Y := Y + Canvas.TextHeight(ParamStr(I)) + 5;
end;
end;
4. Reuse of DCU files (compiled library units)
(1) Referenced in the uses clause in the interface. Such as Windows, Dialogs, etc., it is required that the referenced DCU must be placed in the Delphi 3Lib subdirectory.
(2) Referenced in the uses clause in the implementation. If it is a DCU file written by yourself, this method should be used and the referenced DCU file should be placed in the subdirectory of the current project.