1. Create a New dialog.
empty dialog has been created, ready to be filled in.
2. Bring up the Dialog Properties (double-click on the dialog or press F4).
3. On tab page 1 - change the caption to: PowerEntry
4. Press OK to approve of the new caption and close the Dialog Properties.
Our blank dialog now has a caption. Now we'll add controls to the dialog.
5. Select the Label control in the Toolbox dialog.
6. Move the mouse to the upper left corner of the dialog, about 5 pixels in.
7. Click and drag the mouse to create a Label - release at size 40x10. (PBForms statusbar shows the size in Bottom/Right corner).
8. Bring up the Label's Properties (double-click on the Label or press F4).
9. Change the caption to: User name:
10. Press Ok.
11. Press the Down arrow key twice to move the Label down 2 steps, to pos 5, 7.
12. With the Label control selected, press Ctrl+C to copy it.
13. Press Ctrl+V to paste a copy of right under Label1.
14. Press the Down arrow key 5 times to move Label2 down 5 steps, to pos 5, 22.
15. Bring up the Label Properties (double-click on Label or press F4).
16. Change the caption to: Password:
17. Double-click on the TextBox control in the Toolbox dialog.
18. Move the created TextBox1 up to position 45, 5 - right next to Label1.
19. Expand the TextBox1 width to 150.
20. Bring up the TextBox1 Properties (double-click on TextBox1 or press F4).
21. Remove the caption text for TextBox1 and OK the change.
22. With the TextBox control selected, press Ctrl+C to copy it.
23. Press Ctrl+V to paste a copy of it right under TextBox1.
24. Bring up the TextBox2 Properties (double-click on TextBox2 or press F4).
25. Remove the caption text for TextBox2.
26. Add %ES_PASSWORD style to TextBox2 on tab page 2 and OK the changes.
27. Select the Button control in the Toolbox dialog.
28. Create a button size 50x15 at position 90, 50.
29. Bring up the Button1 Properties (double-click on the Button or press F4).
30. Change the caption text for Button1 to: OK
31. Select a new Button id, %IDOK, from the ID name ComboBox dropdown list.
32. Press Ok.
33. Select the Button control in the Toolbox dialog again.
34. Create a button size 50x15 at position 140, 50.
35. Bring up the Button2 Properties (double-click on Button or press F4).
36. Change the caption text for Button2 to: Cancel
37. Select a new Button id, %IDCANCEL, in the ID name ComboBox.
38. Press Ok.
39. Resize the dialog to size 201, 70.
40. Test the dialog - Exit test mode (just to show test mode).
41. Activate the menu - &File.
42. Save the project as PwrEntry.bas
43. Activate the menu again - &Tools.
Now let's look at the souce code PB/Forms has generated (PwrEntry.bas)
44. Select Open file in IDE - PBEdit. (in the ToolBar or the Tools menu)
45. In PBEdit, bring up the Code Finder dialog.
46. Double-click on ShowDIALOG1Proc (or select it and press Ok).
47. Add the following code at top of the ShowDIALOG1Proc:
LOCAL sName, sPassWord AS STRING
, so it looks like:
CALLBACK FUNCTION ShowDIALOG1Proc()Scroll down to %WM_COMMAND.
LOCAL sName, sPassWord AS STRING
CASE %IDOK IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN CONTROL GET TEXT CBHNDL, %IDC_TEXTBOX1 TO sName IF LEN(TRIM$(sName)) = 0 THEN MSGBOX "You must submit a name!", _ %MB_OK OR %MB_TASKMODAL, "PowerEntry" CONTROL SET FOCUS CBHNDL, %IDC_TEXTBOX1 EXIT FUNCTIONEND IFCONTROL GET TEXT CBHNDL , %IDC_TEXTBOX2 TO sPassWord IF LEN( TRIM$(sPassWord)) = 0 THEN MSGBOX "You must submit a password!" , _ %MB_OK OR %MB_TASKMODAL, "PowerEntry" CONTROL SET FOCUS CBHNDL, %IDC_TEXTBOX2 EXIT FUNCTION END IF ' For demonstration purpose, we only grab the text from ' the two input fields/TextBoxes and test their length. ' This would be the place to make sure each entry also ' is valid against the specifications needed for entry. MSGBOX "User name: " + sName + $CRLF + _ "PassWord: " + sPassWord, _ %MB_OK OR %MB_TASKMODAL, "PowerEntry" DIALOG END CBHNDL, %IDOK END IF
Compile and Execute (Run) the code.
And here's the result:
Your PowerEntry program is now ready for a first test round.