ZT: Delphi entry level information: 2 Basic Windows program

zhaozj2021-02-16  64

?

Unit 2, basic Windows program

2.1 menu production

Open a new item and select File | New Application. Add MainMenu components. Double-click the MainMenu component to open the menu design tool.

Method of adding options: (as an example of the production file menu)

Enter the name of the menu: Fill in the "Archive (& F)" at the CAPTION, change the characteristic Name to "MIFILE1". Then, click the new square below the file in the design tool, and fill in the "New File (& N)" at the CAPTION, change the characteristic Name to "Minew1".

Targes for design menu

INS key: Add a new option above the left or option of the menu. DEL key: Delete the current option. Ctrl DEL key: Delete a blank option. Ctrl → Key: Insert a new nest menu.

Continue to complete the file menu of the following table according to the above steps.

CAPTION NAME SHORTCUT Archive (& F) MIFILE1 Refinition (& N) MINEW1 Open Old Diles (& O) Miopen1 Ctrl O Storage Archives (& S) Misave1 Ctrl S SAS SASS SASE (& A) Misaveas1 Ctrl A - N1 Print (& P ) MIPRINT1 CTRL P printer setting ... (& R) MIPRISNTSETUP1 - N2 End (& X) MIEXIT1 CTRL X

Specify an accelerator key: add "&" symbol before the letter of the quick key, for example: file (& f).

Specify shortcut: Specify button combination in the SHORTCUT feature of the option. Specify the separation line: Enter "-" in the CAPTION characteristic.

Insert menu from the sample version: Press the slider button, select "Insert from Template ...". After we can insert the options in the sample, we can add or decrease options to meet our needs.

Making other menu

Add edit menu on the right side of the archive selection. In the menu design tool, press the mouse button, select "Insert from Template ...", then select "Edit Function" Press OK. The check menu is checked on the right side of the editorial order and add two options to the following table.

CAPTION NAME CHECKED Display Tools Column (& T) MiViewToolsbar True Display Status Column (& S) MiViewStatusbar True

In the right side of the viewing options, the menu is described. Close menu design tool.

2.2 Production Tools

2.2.1 Traditional Method Production Tools

Join the Bevel Component (in the Additional page or by Alt_VL), Align = Altop, Height = 4, Shape = BStopline. Add to PANEL components, align = altop, bevelout = bvnone, clear CAPTION. Join ScrollBox, Align = AlClient, Color = CLWINDOW. Add 8 SpeedButton and change its feature according to the table below. The BMP files required for GLYPH feature can be found in the Delph 3 / Image / Buttons directory.

Name Left Top Enabled Glyph sbNew 0 2 True FILENEW.BMP sbOPen 25 2 True FILEOPEN.BMP sbSave 50 2 True FILESAVE.BMP sbCut 85 2 False CUT.BMP sbCopy 110 2 False COPY.BMP sbPaste 135 2 False PASTE.BMP sbPrint 170 2 True Print.bmp Sbhelp 195 2 True Help.BMP2.2.2 Using Tools Route By Production Tools

Join Toolbar.

The button has the following five, and the difference is that the Style characteristics are different.

Button (style = tbsbutton): General buttons. Separator: Does not react to the mouse. Divider: Similar to the Separator to draw the separation line between the button. Check: Press the status when pressing. DropDown: Display the menu specified by DROPDOWNMU in press.

Press Right-click New Button to make a button. Use New Button to join three Button, a Separator, then in three button, one separator, and finally in two button. Set the FLAT characteristics of the tool column to TRUE. (This is the setting of the new button, which will automatically display the el el 元 加 加 加 加 加 加 加Double-click ImageList to launch the ImageList editor, join the images of the eight buttons in order. . (Answer your own image when the editor is required to divide it into two stations, then delete the unpatisfactory graphic specified to the IMAGE feature of the tool column. Set CUT, COPY, and PASTE. The enabled characteristic of these two Button is set to false.

2.3 Production Status Columns

Change the Scrollbox's align to Alnone, move it up, leave the space to STATUSBAR. Then join the StatusBar element. Reply to the AlClient of Scrollbox's Align.

Find the PANELS of STATUSBAR in the object viewer, double-click the omission button on the right, and a Status Panels Editor dialup will appear. Continuous Press Five ADD buttons, set the width of the first block to 250, the remaining 50, the TEXT of the first four blocks is set to "Ready", "NUM", "CAP" and "SCRL".

2.4 Responding to Windows events

Write an event handler: First find the event related item, then find the event you want to process, and finally add the program you want to process at the event. Proceed as follows:

Select the components you want to process. To find the event you want to process, double-click the characteristic column on the right. At this point, Delphi will automatically generate the head tail of the event handler, and the declaration of the category plus the declaration of the handler. Add the program code of the handler.

2.4.1 End Options for Archive menu Adding an event handler

Turn on the menu design tool and select the end of the option. At the Events page, choose the onclick event, double-click the blank on the right to generate an event handler. The Close method of adding a table object is added to the program.

Procedure TFORM1.EXIT1CLICK (Sender: TOBJECT); begin close;

Executive program.

2.4.2 Viewing the event handler of the menu

In the menu design tool, find the view menu, double-click the first item "Display Tool Column". Add the following program code

Procedure TFORM1.MIVIEWTOOLSBARCLICK (Sender: TOBJECT); begin // Reverse adjustment display tool column MIVIEWTOOLSBAR.CHECKED: = NOT MIVIEWTOOLSBAR.CHECKED; // According to the selected method, decide whether to display tool columns Toolbar1.visible: = MiViewToolsBar.Checked; End; Execution, select View | Display Tool Column Try.

Use the same method to seek | Display status columns plus the process code.

2.4.5 Delphi Auxiliary Editing Tools: Code Insight

Code Completion: When the name of the input object, enter the period, wait for a while, Delphi will list a block display all features, methods, and events of this object.

Code parameters: When the call is input, after entering the left parentherential arc, you will wait for a while, and the Delphi will list all the parameters and its type of the method.

Code Template: Press the Ctrl J key, Delphi lists all the programs that have been defined.

转载请注明原文地址:https://www.9cbs.com/read-18777.html

New Post(0)