Create the main application window

Note

Now you create a w_orders window.

  1. Select File -> New.

    In the PB Object tab, select Window and click OK.

    Shown is the P B Object tab of the New dialog box. The Window object icon is selected.
  2. On the General tab of the window Properties view, make sure the following values are set:

    Window property

    Value

    Title

    SalesDB tutorial

    MenuName

    m_salesdb

    Visible

    selected

    Enabled

    selected

    Show SIP Button

    selected

    Close (OK)

    selected

    Selecting the Show SIP Button property makes the Soft Input Panel in the Pocket PC available to the user. Selecting the Close (OK) property adds an OK icon to the title bar of the window in the Pocket PC; when the user clicks OK, the application closes.

  3. On the Scroll tab of the window Properties view, select the HScrollBar and VScrollBar check boxes.

  4. Select File>Save to save the window.

    Type w_orders as the name of the window.

    Click OK.

  5. Select Insert>Control>DataWindow.

    Click the window in the Layout view to insert a DataWindow control in the w_orders window.

    Click and drag the borders of the DataWindow object to size it, leaving space at the bottom of the window for navigation buttons.

    Shown is the Layout view of the Window painter. It displays an empty Data Winodw control at the top of the window page.
  6. Change the DataWindow control properties on the General tab of the Properties view to these values:

    DataWindow control property

    Value

    Name

    dw_orders

    DataObject

    d_orders

    HScrollBar

    checked

    VScrollBar

    checked

    You should now see the column labels inside the DataWindow control.

  7. Select Insert>Control>CommandButton.

    Click in the window below the DataWindow control to add the command button.

    Name the button cb_prev with command button text < Previous.

  8. Repeat the preceding step with the following settings:

    Command button name

    Value

    cb_next

    Next >

    cb_approve

    Approve...

    cb_deny

    Deny...

  9. Rearrange the position of the DataWindow control and buttons so the resulting window looks like this:

    Shown is the Layout view of the Window painter. It displays the main application window containing a Data Window control and four buttons. The Data Window displays the labels for the column headers, but does not yet display column data.

    Next you associate events with the buttons.

  10. Double click the cb_prev button.

    Make sure the clicked( ) event displays in the Script view.

    Type the following code in the Script view.

    f_scroll(-1)
    

    This function scrolls data in the DataWindow back by one row.

  11. In the Script view, select the each of the other command buttons from the first drop-down list and type the code shown below for the clicked event of that command button:

    Command button name

    Code

    cb_next

    f_scroll(1)

    cb_approve

    f_approve_deny(APPROVE)

    cb_deny

    f_approve_deny(DENY)

  12. Select File>Save to save the changes.

    Close the Window painter.

    Now you must tell the application to open the window when the application starts.

  13. In the System Tree, double-click the salesdb_tutorial Application object.

    In the second drop-down list in the Script view, select the open event.

    Uncomment the section following the text: Uncomment the following section after creating w_orders. Leave the comments that start with a double slash (//) unchanged.

    NoteUncommenting code You can use comments in code to document your scripts or prevent statements within scripts from executing. In this step and the next few steps, you uncomment scripts that have been commented to prevent them from executing. The slash-and-asterisk method of commenting code looks like this: /* Code */, where Code can refer to any number of lines of code. You uncomment the code by deleting the /* and the */ characters that surround the code.

    The double slash method of commenting code can comment out only a single line of code at a time. The tutorial uses this method to include descriptive text. If you remove the comments from the descriptive text, the PocketBuilder compiler will indicate a compilation error.

    Here is what you should see in the Script view now:

    Shown is the Open event for the Sales D B underscore tutorial application. After setting the SIP keyboard on the handheld device, the script opens the main application window and calls the u e post open event.

    This code had to be commented out before you created the w_orders window. Since you created the window at the beginning of this lesson, you can now uncomment the code without causing the PocketBuilder compiler to issue an error message.

  14. In the second drop-down list, select the ue_postopen event.

    Uncomment the section following the text: Uncomment the following section after creating w_orders.

    Leave the comments that start with a double slash (//) unchanged.

  15. Select File>Save to save the changes.

    Close the Application painter.

  16. In the System Tree, double-click the m_salesdb menu.

    Expand Order, and double-click the Delete submenu item.

    Uncomment the section following the text: Uncomment the following section after creating w_orders.

    Leave the comments that start with a double slash (//) unchanged.

  17. Select File>Save to save the changes.

    Close the Application painter.

  18. In the System Tree, double-click the f_scroll function.

    Uncomment the section following the text: Uncomment the following section after creating w_orders.

    Leave the comments that start with a double slash (//) unchanged.

  19. Select File>Save to save the changes.

    Close the Function painter.

  20. Repeat steps 18 and 19 for f_scroll_last, f_approve_deny, f_refresh_orders and f_set_dir_btn_enabled.

    The SalesDB application is now ready to be tested.