Welcome!

PowerBuilder Authors: Chris Pollach, Yeshim Deniz, Jayaram Krishnaswamy, Kevin Benedict, Avi Rosenthal

Related Topics: PowerBuilder

PowerBuilder: Article

PFC Quickstart

Provide more usability and utility to your applications Part 2

Split Bar
The split bar is not a service. It's a user object based on a static text control. The split bar gives you a "handle" to grab and drag. When you drag the split bar, the objects to the right and left (or above and below) of the split bar will automatically resize to follow the movement of the split bar.

Place the split bar object on your window between two objects that you want to control. Then all you need to do is register the objects with the split bar like this:

st_1.of_register(lv_1, st_1.LEFT)
st_1.of_register(dw_1, st_1.RIGHT)

These statements register a ListView control to the left of the splitbar and a DataWindow control to the right.

Status Bar Service
You can increase the utility and functionality of your user interface easily by adding information and shortcuts to your status bar. PFC's status bar service makes it easy to do that. To use the status bar service, instantiate the service in the pfc_preOpen event of your window. This gives you the opportunity to modify fields and information in the window's open event.

of_SetStatusBar(True)
If IsValid(inv_statusbar) Then
this.inv_statusbar.of_SetTimer(TRUE)
inv_statusbar.of_Register("userid","text","", 200)
End If

Then in the window open event, you can add some additional code to update your status fields:

if isvalid(inv_statusbar) THEN
inv_statusbar.of_modify("userid", gnv_app.of_getUserID())
end if

The above code adds the current logged-on userID to the "userid" status bar field.

You can do more with the status bar service. You can add icons to the status bar that allow your users to turn services on and off, display the debug log window, and perform any other common tasks.

To add an icon to the status bar, you register a bitmap with the service:

inv_statusbar.of_Register('debuglogwin', 'bitmap', 'dlgwnoff.bmp', 80)

The first parameter in this call specifies a name for the bitmap. This name is passed to the window's ue_statusbarclicked event and is used to tell which icon the user clicked. Here is a snippet of code from the ue_statusbarclicked event that detects when the "debuglogwin" icon is clicked:

IF as_name = 'debuglogwin' THEN
this.event ue_togglelogwin()
END IF

The above code calls an event on the window that will toggle the state of the debug log window. You can make this code more generic by using the PFC menu service to obtain a reference to the menu item that your user would choose to perform the same function, then triggering the clicked event on that menu item. This is the method that is used in the PFC example application.

More Precoded Scripts
Here are a few more scripts that you can include in your objects. Use these and other scripts that you create to get a running start on PFC development. Remember, the more working code that you can reuse, the more productive you will be.

Application Object
If you use the PFC Start Wizard, you won't need these. But if you start from a blank application, you should paste these scripts into the appropriate events to enable the application to call the methods of the application manager.

  • Open event:

    // Instantiate and call open on the app manager.
    gnv_app = CREATE <appmanagerclass>
    gnv_app.event pfc_open(commandLine)

  • Close event:

    // Call app manager's pfc_close and destroy app manager.
    IF isValid(gnv_app) THEN
    gnv_app.EVENT pfc_close()
    DESTROY gnv_app
    END IF

  • Connectionbegin event:

    RETURN gnv_app.EVENT pfc_connectionBegin(userid, password, connectstring)

  • Connectionend event

    gnv_app.EVENT pfc_connectionEnd()

  • Idle event

    // Enable PFC's idle processing.
    gnv_app.EVENT pfc_idle()

  • Systemerror event

    // Enable PFC's system error handling.
    gnv_app.EVENT pfc_systemError()
    Window (w_master or descendant)

    Add this script to the open event of your windows. The code in this script that enables the resize service could be added to w_master if you expect to have resize capability in all of your windows. Of course, you'll still need to code the of_register calls to register controls on the window. The code relating to the linkage service should be pasted into each of your windows that will use the linkage service. You need to replace items in the script surrounded by the pointed brackets (i.e., <datawindow object>) with actual object names (i.e., dw_master) as in Listing 1.

    DataWindow
    You can use the following scripts to start development in your DataWindow (u_dw) user objects (or a u_dw-based control placed on a window). Examine the statements and selectively enable the services you want to use by removing the comment markers.

    • Constructor event (see Listing 2) - be sure to substitute actual values for any variable parameters (such as "column") to correspond to your application's needs.
    • pfc_prermbmenu event:

    am_dw.m_table.m_delete.enabled = FALSE
    am_dw.m_table.m_insert.enabled = FALSE
    am_dw.m_table.m_addrow.enabled = FALSE

    Change these values to TRUE to enable any of these items on the right-mouse menu for your DataWindow.


  • More Stories By Millard F. Brown

    Millard F. Brown is vice president of Power3, LLC, a company providing consulting and training services for the enterprise. He has beend developing PowerBuilder applications since PowerBuilder 2 and is the co-author of two new PowerBuilder 9 books: PowerBuilder 9: Advanced Client/Server Development and PowerBuilder 9: Internet and Distributed Application Development.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.