Lesson 1: Creating a Basic Hello World Application  Lesson 1: Creating a Basic Hello World Application


Add a button and text to the window

Note

Now you add a button and text to the application’s main window. When you run the application on the desktop, the main window displays in the position and size that you specify.

NoteWindow size on mobile devices On mobile devices, the main window always displays full size and centered.

  1. Double-click w_basic_tutorial_main in the System Tree.

    The Window painter opens the application’s main window.

    Shown is the Icon page of the Application property sheet. It displays a text box for Icon Name with the entry PowerBuilder 10 dot 0  Tutorial  Tutorial dot i c o and next to it is Browse button. Displayed is an icon of a graduation cap and diploma.
  2. Change the title of the window to Hello World on the General page in the Properties view.

  3. Select the Center check box on the General page in the Properties view if it is not already selected.

    Now when you run the application on the desktop, the main window will be centered. On the PocketPC or Smartphone, this does not affect the window position.

  4. Check the Close (OK) check box on the General page in the Properties view if it is not already selected.

    Now when you run the application on the desktop, you can close it by clicking the window’s Close button in the upper right. On the PocketPC, the Close button becomes an OK button that you can use to Close the application.

    NoteOn the Smartphone The Close (OK) button property is ignored on the Smartphone.

  5. Select Insert>Control>CommandButton from the PocketBuilder menu.

    Shown is the Icon page of the Application property sheet. It displays a text box for Icon Name with the entry PowerBuilder 10 dot 0  Tutorial  Tutorial dot i c o and next to it is Browse button. Displayed is an icon of a graduation cap and diploma.
  6. In the Layout view, click in the space near the upper left corner of the window.

    A command button with the label none displays in the window.

  7. Click the command button.

    In the Properties view, change the name property to cb_ok.

    Change the text property to OK.

    Shown is the Icon page of the Application property sheet. It displays a text box for Icon Name with the entry PowerBuilder 10 dot 0  Tutorial  Tutorial dot i c o and next to it is Browse button. Displayed is an icon of a graduation cap and diploma.
  8. Select Insert>Control>StaticText from the PocketBuilder menu.

    Click in the space below the command button.

    A static text control with the label none displays in the window.

  9. Be sure the static text control is selected.

    In the Properties view, change the name property to st_hello.

    Delete the default text property and leave the property blank.

  10. Double click the command button in the Layout view.

    The Script view displays with the cb_ok clicked event selected.

  11. Click in the blank script area and type the following code for the clicked event:

    st_hello.text = “Hello World”
    
    Shown is the Icon page of the Application property sheet. It displays a text box for Icon Name with the entry PowerBuilder 10 dot 0  Tutorial  Tutorial dot i c o and next to it is Browse button. Displayed is an icon of a graduation cap and diploma.
  12. Select File>Close from the PocketBuilder menu.

    Click Yes when you are prompted to save your changes.

    Next you run the application.





Copyright © 2004. Sybase Inc. All rights reserved. Lesson 1: Creating a Basic Hello World Application

View this book as PDF