Part 1: Establish an application
Start words: In the large database application, "Client / Server System" structure is common, in this architecture, all data and database management systems are on the server, and the client is by using standard SQL statements. To access the data in the database on the server, you can guarantee the security and integrity of the data, but also allow each user to share and make full use of server high performance. Because of these advantages of the client / server architecture, it has been widely used, and PowerBuilder and the previous Chinese Access 2000 are excellent products. If you want to quickly master it, then come with this tutorial. ! .
First mention, start using the template application
PowerBuilder uses the current popular graphical operation interface, as well as visual programming methods that allow you to program the database application as soon as you use Chinese Visual FoxPro, you will see the database applications, without having to remember that is upset. Program commands and grammar rules unless you are willing to do this. From this tutorial, this book will tell PowerBuilder 7, this latest version of the basic usage. First, this will explain how to start using this software to design applications by establishing a "login window" operation for an application.
Establishing an application is an infrastructure that uses PowerBuilder. Template Application is a wizard that is very useful to beginners, through it creates new databases and applications based on existing databases and applications. After starting the PowerBuilder 7 by launching the Windows application, the operation window displayed on the screen will be shown in Figure 1, which is the "development environment" for you to use, this tutorial will begin to tell how to use this wizard from here.
Figure 1 Enter the PowerBuilder 7 operation window
Step 1, select the New (new) command from the File drop-down menu, or select the New tool in the usual toolbar, see Figure 2.
Figure 2 Select New Commands or New Tools
Step 2, select the Template Application icon after the New dialog shown in Figure 3, click the OK button, or comin the icon, go to the Application Start Wizard dialog box shown in Figure 4. .
Figure 3 Select this icon
Note: After mastering the basic operation of PowerBuilder 7, you can also try to establish a specific type of item through the Project tab in this New dialog, and start using the software here. For example, create a new database and application from scratch from scratch through the Application Wizard.
Figure 4 Enter this wizard dialog
Many steps you need to pass in Application Start Wizard can complete the operation, each step will use a dialog (the developer of the software is "page", and the relevant information is recorded as Page). Like the wizard in Chinese Visual FoxPro 6, click the Next button to go to the next step, click the Back button to return to the previous operation dialog. In the dialog box used in the first step, the function description text is displayed. The first line means that "the wizard will help you create an application from the draft." The next text illustrates the object established, The next steps are listed in the Dialog box, and then the next step will request you to refer to the newly established application and the "Object Library" name, please proceed.
Step 3, see Figure 5, enter the PBTUTOR application name in the Application Name (Application Name) Text Editing box, and click the Library text edit box below to create a target library named here.
Figure 5 Enter PBTUTOR
Note: The extension in the object library name file name is PBL. Figure 6 accept this default setting
Figure 7 Enter w_master_detail_ancestor
Step 4, click the next operation dialog box, accept the default settings in the wizard: MDI Application With microhelp, see Figure 6. You can also do this after entering the dialog boxes used in the subsequent steps until the Name MDI Base Sheet, the Menu and Service dialog box is displayed on the screen, and you can see this name in the title bar of the dialog.
Note: MDI is a MULTIPLE Document Interface (multi-document interface), which is currently adopted in a Windows application.
Step 5, see Figure 8, enter: w_master_ detail_ancestor in the Base Sheet Window Text Editing box, the remaining two items accept the default settings of the wizard.
Figure 8 Enter these two chart names
Step 6. After entering the Name Individual Sheets dialog box, enter: w_customers in the Sheet 1 (Chart 1) text editing box, enter: w_products in the Sheet 2 text editing box, and clear the content in the Sheet 3 Text Editing box, see Figure 8.
The purpose of the above operation is to establish a w_master_detail_ancestor infrastructure, and establish two windows on this basis, one for managing user information, and the other for managing product information. At this point, what is the use of the chart? Here you can understand it as a "table" previously described!
Figure 9 means the display name of the chart
Step 7. Refer to Figure 9. After entering the next operation dialog, the two charts of Sheet 1, SHEET 2, specify the display name: Customers, Products.
Next, click the Next button in the dialog used in each of the following steps, all accept the default settings of the wizard. After entering the last steps dialog, click the FINISH button. In this way, the application is established, and the specified data system is compatible with DBASE III. DBASE III is self-written as BD3, which is a widely used database management system. It is almost used by all the technologies that are almost all popular database software, and PowerBuilder 7 uses it as a default standard.
Thereafter, you will not see any dialog on the screen, the display status will also be shown in Figure 1, but the name shown in the title bar will become PBTUTOR, as shown in Figure 10. This is the name you taken in front of the new application in the previous operation, see it, indicating that the application group has been established and is saved in a disk file, and you can press your wish by it. Design a database application.
Note: The above operation is only the start of PowerBuilder 7, and only a framework (FRAME) is set for the establishment of an application, and the next operation is more!
Second, run the app and open the chart window
Ok! You can now run the application you designed to see what is the result of the design! This is a proofreading work in a timely discovery.
Figure 10 Click this button
Step 1, see Figure 10, click the RUN button in the common toolbar.
In this way, the application you designed above is run, you can see the window and menu design in the above operations, as shown in Figure 11, but the future work It will be based on them. Of course, if needed, you can do some appropriate modifications.
Figure 11 Enter the Frame window
Step 2, see Figure 12, select the new command from the FILE drop-down menu, then select the Untitled for Sheet 1 command from the New submenu, open the Untitled for Sheet 1 in the Template Application Wizard, see Figure 13. Figure 12 Select this command
Figure 13 Opening the Untitled for Sheet 1 Chart Window
Step 3, then select the Untitled for Sheet 2 command in the new submenu shown in Fig. 12, the Untitled for Sheet Chart window will also be opened, as shown in Figure 14.
Figure 14 Opening the Untitled for Sheet 2 Chart Window
Thereafter, the display form of this chart can be controlled by the Window drop-down menu, such as selecting the Tile Horizontal command, allowing them to display in the way shown in Figure 15.
Note: Figure 14 shows the above desigrable application framework, Figure 15 makes two graphs facing the arrangement of operations. In addition, you can control the display form on the screen through the Toolbars command in the File drop-down menu. From this drop-down, select the exit command, or click the "Close" button at the upper right corner of the Frame window and turn it off and return to the operation window of the PowerBuilder 7 shown in Figure 1. If the operation in PowerBuilder 7 is completed, the application will automatically become the current application when the operation is started.
Figure 15 Horizontal tiled two chart windows
Third, start establishing an application "login window"
The position of the Windows application is very important, you can say that there is no application if it doesn't. And "Login Window" is the most common in a database application. It will ask the user to enter the username and password. The two are correct to enter the next step, not the operation like the last section. application. You must use the "login" operation elsewhere, and it is also understood that "Login Window" is a response window from the operational characteristics, and the following operations will design the answer.
Step 1. Refer to the previous operation, enter the New dialog box shown in Figure 3, and then click the Object tab to connect to the Window icon from the card, see Figure 16.
Figure 16 Boarding this icon
Figure 17 Entering the Window Drawboard
Thereafter, the Window drawing board will be opened, as shown in Figure 17. The distribution of this drawing has different views, where the Properties view and the Layout view will be the following operations to be used, confirm that it is displayed on the screen. By the way, through the View drop-down menu can control whether each view is displayed in the current picture board.
Step 2, see Figure 18, find the General (General) tab in the Properties view, then enter: Welcome! Welcome! Welcome! Welcome! Let the new window use this as the title name.
Figure 18 Inputting the title of the window here
Step 3. Drag the scroll bar on the right edge of the Properties view, let the WindowType list in the General tab display, then select the Response! (Agate!) Item, see Figure 19.
Figure 19 Select this
This step specifies the newly established window to a reply window, so the design of the design will ask the user when starting execution, if the answer is correct, the operation will continue, otherwise stop, or exit. The remaining common types in the WindowType drop-down list are: Child (sub-window), which is used to make the current window belong to an already existing window; main (main window), the operation window of the program's main functionality.
Step 4. Confirm that the Titlebar is in the open state and the ControlMenu detection box and then open the ContextHelp detection box. The purpose of this step is to specify "Login Window" through the TitleBar property. Using the Title Bar in the Windows Application window with the "Close" button, use the control menu with the ControlMenu property, and the contexthelp property? A question mark (?) Button will be added to the window to trigger the help information established by the "Login Window" behind this tutorial. You should notice that these detection boxes are located in the General tab and drag the scroll bar to find them.
Hehly, click the Other tab, enter the number in the Width text editing box after entering this tab: 2000 Enter Number in the Height (Height) text editing box: 1000, as shown in Figure 20.
Figure 20 Specifies the width and height in this tab
This step will specify "Login Window" on the display size on the screen, and the length measuring unit used is somewhat special, which is PowerBuilder 7, which is not a metric or English. Thereafter, this size can also be modified if necessary.
Figure 21 Inputting the name of the window here
Step 6. Select the Save command from the FILE drop-down menu, enter the W_WELCOME in the Window Text Editing box, see Figure 21 after entering the Save dialog.
Note: The W_WELCOME you entered here will be provided as a control name to the application instead of it displayed on the screen. Prefix W_ is used to illustrate this is a Windows Standard window, and it is also a standard identity of such a window in the application. You can give different names for all controls in this book example, but must pay attention to can't blend their prefix.
Next, you can also enter some text that describes this window feature in the Comments text editing box. This text will appear in the Library panel, or other dialog boxes that provide a selection object operation, which is advantageous for identifying the "login window" in the design operation. After that, click the OK button to close the Save dialog, this "login window" is established and saved by Powerbuilder 7. At the same time, the window will also appear in the ControlsList view of the Window section, as shown in Figure 22, indicating that it has become a control in the application.
Note: "Control" is an important design object when developing a PowerBuilder 7 application, the operation button, text box, detection box, radio button, etc. in the application, including the operation window itself belongs to the control, the next section will Tell how to join the control in the window.
Fourth, join the control in the window
Once you open the Window drawing board, you can add a control in the window by two ways. First, use the Insert drop-down menu, and the other is to use the Window Draw Toolbar. Let's first add a picture to the part.
Step 1, see Figure 22, click the Painterbar drop-down button in the Window section board toolbar, then select Create Picture Control button from the list. Or select the control command from the INSERT drop-down menu, enter the Control submenu to select the Picture command, see Figure 26.
Figure 22 Select this tool button
The controls listed in the drop-down list shown in Figure 22 can be seen from their names. However, if you are interested, you should choose to do it after learning this tutorial!
Step 2, move the cursor into the Layout view in the Window Drawboard, and then click Place the left corner of the picture area, let a square box appear, then use the drag method to draw the size size, see Figure 23 .
After clicking on the gesture finger of Figure 23, a picture control will appear in the Layout view. Thereafter, you can use the drag method to adjust its size and location. Note: Once a control is established, the Other tab in the Properties view will display the X, Y coordinate values, and width, high degree of width, and high attributes in the window. To delete a control, you can select it and press the DELETE button on the keyboard.
Figure 23 Click the left corner to drag the lower right corner of the box
Step 3, select the General tab in the Properties view, then change the value in the name text editing box in the card to P_Sport, then click the PictureName open button under this text editing box and select Open a picture, see Figure 24.
Fig. 24 is the result of the above operation
This step is to name the picture control P_Sports, where the P_ prefix is the standard identity of the image control. After you click the PictureName to open the button, the standard Windows file selection dialog will be displayed on the screen, which can be easily selected to select a picture (or "image"). This open button is located on the right side of the PictureName text editing box, with three small dots. After the results of the operation, the selected picture will be an illustration in "Login Window", and will also be displayed in the image control established above, as shown in Figure 24.
意 意: If you open the originalsize detection box in the General tab, the picture will be inserted in the window according to the original size, and the result may not be what you want, unless the original size of the picture is custom.
Figure 25 Modify the size of the control and location
Step 4, select the picture control in the Layout view, then enter the Other tab of the Properties view, change the values in the X, Y text box editing to: 40 and 50, respectively, the values in the Width and Height text editing boxes respectively Change to: 450 and 300.
As mentioned earlier, the use of drag can modify the size of the "control" and location, but this cannot quantize the operation, and this step is operated by the placement position of the control and the specific size size. Beginners should note that this is a common operation, but the result will be in place with the original picture, as shown in Figure 25, but this is not tight, appropriate adjustment.
Figure 26 Select this command
Fifth, add static text in the window
"Static Text" mainly refers to the text of the window, such as the name of the application, developer information, operational prompt, welcome information, etc., is an indispensable control in "Login Window", the following operations will be added it.
Step 1, see Figure 26, select the StaticText command in the Control submenu, or select the Create StaticText Control button in the drop-down list shown in Figure 22.
Step 2, click on the right side of the image control in the Layout view, let a static text control display immediately click on it, then select the Duplicate command from the shortcut menu, see Figure 27.
Figure 27 Right-click the command to select the cursor after the point
Step 3. Repeat the previous step, continuously copy two static text controls, and the result should be shown in Figure 28.
The above operations creates three static text controls in the "Login Window", which allows you to place some text through them in the application's operation window as the label in Chinese Visual FoxPro 6. All of the input and format control operations related to text can be completed by the Properties view.
Figure 28 Establish three static text controls
Step 4, select the first static text control, then in the General tab in the Properties view, the value in the Name text edit box to: ST_WELCOME, change the value in the Text Text Edit box: Welcome this procedure! Refer to Figure 28. This step sets the ST_WELCOME property for naming selected static text controls, and ST_ is the standard identity of static text controls. Enter "Welcome to this Program!", And press the Enter on the keyboard or continue to set other properties, the text will appear in the Layout view, see Figure 29.
Step 5, after entering the Font (Font) tab in the Properties view, select the font of the static text from the FaceName drop-down list, see Figure 29.
Next, you can also modify the TEXTSIZE attribute value, reset the size of the text, and set the diagonal, aligned text properties, which can be done with other Windows applications, and more about it here.
Figure 29 Selecting this font from the drop-down list
Step 6. Refer to the previous step, select the second and third static text boxes, and set the control name to ST_USERID and ST_Password in the Properties view, and the text content is: "User Name:" and "password .
Note: The properties of the text can be set by the relevant tools in the Stylebar. If you don't see STYLEBAR on the screen, you can display it through the Toolbars command in the Window drop-down menu. The appearance of Stylebar is the same as the "Common" tool in Microsoft Word, as shown in Figure 30. If you increase the text size, you can't accommodate the text in the text control box in the Layout view, you can refer to the above content to properly enlarge the text control box.
Figure 30 Settings text properties using StyleBar
Powerbuilder 7 Speed Tutorial (6)
Time: 2001/04/13 11:29
Author: eNet beacon mirror technology
Sixth, establish a login information text edit box
In order to enter the login information (user name and password), you will need to add two single-line text editing boxes in the "Login Window", which is the SingLineEdit control. To this end, the operational steps that can be used are as follows.
Step 1. Select Create SNGLINEEDIT Control in the Painterbar (Create a single line Edit Control) button, see Figure 31.
Figure 31 Select this button
Step Second, refer to the operation of establishing a static text control above, and two single-line text editing boxes are established in the Layout view, as shown in Figure 32.
Figure 32 Creating two single-line text editing controls
Step 3, set these two single-line text editing control names to SLE_USERID and SLE_PASSWORD in the Properties view, delete the value in the TEXT text editing box. For the second single line editing control, the Password check box should also be opened, see Figure 33.
Note: The above SLE_ is the standard identity of the SINGLINEEDIT control name.
Figure 33 Open this detection box
After the above operation, the text editing box for entering the login information is established.
Figure 34 Select this button
Powerbuilder 7 Speed Tutorial (7)
Time: 2001/04/17 10:46
Author: eNet beacon mirror technology
Seventh, add a command button to "Login Window"
All right! Now you need to add a command button to "Login Window", which is the CommandButton control. Later, this tutorial also defines the script for the control, enabling the operation of the command button to execute the program predetermined action.
Step 1, see Figure 34, select the Create CommandButton Control (Create a Command Button Control) button in Painterbar, as shown in Figure 34. Figure 35 Results of the above operation
Step 2, click Seple_UserID to edit the right side of the control, let a command button appear here. Adjusting the location and size size is adjusted, then select the duplicate command from the shortcut menu of the control, as shown in Figure 35.
Figure 36 Results of the above operation
Step 3, set the first command button control name to CB_OK in the Properties view, the value of the Text Text Edit box is set to OK, then open the default detection box. Then set the second command button control name to CB_Cancel, the value of the Text Text Edit box is set to Cancel (cancel), and open the CANCEL detection box, as shown in Figure 36.
The first command button above is used to be clicked, the ENTER key operation on the keyboard is used, and the second command button triggers the ESC key operation on the keyboard. Like the programming in Chinese Visual FoxPro 6, there is also a "focus" problem here. The following operations will set "Focus".
Figure 37 Select this command
Powerbuilder 7 Speed Tutorial (8)
Time: 2001/04/19 10:38
Author: eNet beacon mirror technology
Eighth speaking, set operation "focus"
For each control created in the Window section, PowerBuilder 7 will make the default label sequence number according to the established order. When the application is executed, if you press the Tab key on the keyboard, "Focus" will move from one control from one control to another control, in order to control the "focus" on the specified control, you need to change it. The steps used are as follows.
Step 1, see Figure 37, select the Tab ORDER command from the Format drop-down menu.
Thereafter, the default label order is displayed in the Layout view, and the red number is used in the upper right corner of the control indicates the position in the label order, as shown in FIG. Where 0 means that the control will not be ignored when using the TAB key on the keyboard, so it only needs to rearrange those control tag order in which the two-in-one control tags in Figure 38 is required.
Step 2, see Figure 39. After you click the control you want to modify, enter the new sequence number.
After you click the control you want to modify, the tag sequence number will turn red background blue text, and you can enter a new order number from the keyboard. Obviously, SLE_USERID, SLE_PASSWORD, CB_OK, CB_CANCEL, the sequence number of these controls should be: 10, 20, 30, 40. Maybe you will ask why not use 1, 2, 3 .... Natural sequence as the order number? In fact, it is very simple, that is, inserting new controls in these "focus" and establishing new "focus" leaves!
After the modification is completed, if you do not need to continue to display on the screen, repeat the first step.
Powerbuilder 7 Speed Tutorial (Nine)
Time: 2001/04/23 12:04
Author: eNet beacon mirror technology
Ninth, develop login help information
Next, you need to use the Script view as a single-line editing control, this information will be designed for the Question mark button in the "Login Window" title bar. If you don't see this view in the Window Drawboard, let's combo an object in the Layout view so that it will be displayed in this drawing board and become a current view. After the following operations will edit the control from the combo SLE_USERID, start after the Script view shown in Figure 40.
Note: In Figure 40, the current control name is displayed in the first drop-down list box in the Script view, indicating that the following operations will be applied to it. This drop-down list can choose to set the current control without having to combo controls in the Layout view. Figure 40 Entering the Script view
Step 1, select the HELP event from the second drop-down list from the Script view.
In this drop-down list, an event that can be used for current controls or selected objects is listed, and the full prototype of each event, such as the prototype of the HELP event is as follows (see Figure 41):
Help (Integer XPOS, Integer Ypos) Returns Long [PBM_HELP]
Figure 41 Select this event
Step 2, see Figure 42, enter the following scripts in the "Script area" of the Script view:
MessageBox ("Context Help", &
"Enter your username here.")
The text entered in "Script Area" is to be strictly limited by PowerBuilder 7, must be integrated. The MessageBox here is a function provided by PowerBuilder 7 for displaying a system information box to provide information on the screen, and you can apply titles, text, icons, buttons. The above Context Help is the title, "Enter the username here." It is text, which all need to be placed in a pair of English half-angle dual quotes. The content in parentheses (()) is the parameters of the function; & symbols are used to connect to both lines, if they write them in one line, then don't have to use this symbol, see Figure 43.
Figure 42 Enter a script in the "Script area"
Step 3, see Figure 43, select the SLE_PASSWORD control name from the first drop-down list from the Script view.
Figure 43 Select this control
Thereafter, PowerBuilder 7 will compile the script that is set to the SLE_USERID control. If there is an error in the script, the Script view will display an error message, and you can do this again after the modification is completed until all errors are eliminated, so that the "script area" is displayed as "empty", and the first drop in the Script view The list shows the new current control name, here is SLE_PASSWORD, see Figure 44.
Step 4, refer to the above operation, select the HELP event and enter the following script in "Script Area":
MessageBox ("Context Help", enter the user password here. ")
Next, if you right to click anywhere in the Script Area area, you can select the compile command from a drop-down menu to compile this line script. If there is no error, you can also select the Preview button from the Painterbar1 toolbar, or select the preview command from the Design drop-down menu to preview the above design results, just cannot see the help information.
The next section will tell the event design method that opens the "login window" before the application is executed, and now you can close the Window Drawboard.
Powerbuilder 7 Speed Tutorial (10)
Time: 2001/04/25 10:13
Author: eNet beacon mirror technology
Tenth, to open the "login window" to add a script
This section will add a row of scripts to open "Login Window" to open it when logging in to the application database. Please follow the steps below.
Step 1. Open the W_PBTUTOR_FRAME WINDOW drawing board through the open dialog, see Figure 44.
Figure 44 Select this window
Note: W_PBTUTOR_FRAME is the MDI frame window designed by the template application wizard in front, which is the main operation window of the PBTUTOR application, which can log in to the relevant database.
You can do this this step: first select the Open command from the File drop-down menu, then select the Windows type in the ObjectType drop-down list of the Open dialog, then select W_PBTUTOR_FRAME in the Windows list window, and finally click the OK button. Thereafter, a Window drawing board will appear on the screen. This is a new, WINDOW picture board for PBTUTOR applications, different from the previous. If you are operated by the steps as described in this tutorial, then there is no control and an object in this pictureboard in the Layout view, and the script in the Script view is only a few lines, as shown in Figure 45. The following operation will modify the script. Note: W_PBTUTOR_FRAME strings should be displayed in the Window sectors shown in Figure 45, please note! This window is automatically created by PowerBuilder 7 when you use the Template App Wizard in front. In addition, in the Windows list window of the Open dialog, you can also see and open all windows in the current application.
Figure 45 Open the W_PBTUTOR_FRAME WINDOW Drawboard
Step 2, see Figure 46, click the last character in the script area in the Script view, let the cursor (a vertical line) stay here, then press the Enter key on the keyboard, then add it in the new blank line The following two lines:
// Open the login window
Open (w_welcome)
Figure 46 Add this two lines of scripts
Among them, the two slash cables (//) are indicated by the comment text, and the PowerBuilder 7 will automatically ignore these texts when compiling. Beginners should pay attention to each line of comments must be placed two slash cables. The Open here is a function of PowerBuilder 7 for opening the window specified in the back parentheses.
Note: "Compilation" is useful to convert the script conversion program code, only the script that has been compiled.
Step 3 After compiling the added script, use the Save command in the FILE drop-down menu to save the results.
After this step is completed, the "login window" is designed.
In the above operation, the set script is not all of the application, just determines the appearance of "login window", and the time displayed, to completely design a PowerBuilder 7 application, there is a lot of work Do it, this tutorial tells here, please continue to read the following.
to sum up:
PowerBuilder provides an environment for developing database applications so that you can design applications with your own needs and preferences, and no longer conflict in existing software. However, in order to develop an application with practical value, the work to do is very much, and you ask you to master a lot. First of all, do you know how to start working in this software, that is, what is the first step? This tutorial said that the first step is to use the wizard to establish an application framework. The operation to do is to establish various objects in the application. This tutorial has established a "login window". If you refer to 12.2 The content is running on the application you designed above, then you can see how it requires you to enter "User Name", "Password", and display help information.
In various drawing workspace, you can see views of different features, where there is a script view with blue and black text is very important, it is very important to design applications! Of course, the role of other views cannot be ignored, but there are too many content in each picture board, too complicated, and it takes more time to understand their respective purposes. If there is a tag in the bottom of a view, click them to enter the appropriate view. Drag a small rectangle button at the top left corner of each view, you can place them anywhere in the discipline, including another view. Drag the separators of each view and will also control its display size. The program is written in Power Builder as Script. Since Power Builder is an application development tool based on an object-oriented event drive mechanism, the script is also written for the object of the object. This tutorial has written a small number of scripts. The requirements for distances are far less than enough. There is also no database, and the rest will be described in the following tutorial festival.
Thinking:
1. What is the main steps in the Template Application wizard?
2. How to start building an application "login window"?
3. How to join the control in the window?
4. How to set up the operation "focus"?