| By Millard F. Brown | Article Rating: |
|
| October 1, 2004 12:00 AM EDT | Reads: |
11,701 |
PowerBuilder includes a powerful set of foundation classes to speed development. These classes are collectively known as the PowerBuilder Foundation Classes, or PFC. In Part 1 (Vol. 11, issue 9) I provided an introduction to PFC and demonstrated how to use it. Part 2 outlines the more recent changes and additions to PFC.
PFC Quickstart
This section contains some scripts that you can paste into your PFE objects to get a jump start on PFC programming.
The Wizsrce Scripts
As you saw in the section on the PFC Start Wizard in Part 1, Sybase has provided a few script files that you can paste into the application manager. You'll find these scripts in the pfcwizsrce folder. You can use these scripts whether or not you use the Wizard to create your PFC application. The Wizsrce scripts enable basic PFC functionality in the application manager. It's worth noting that these scripts are simply text files and can be modified to suit your purposes. The wizsrce scripts are summarized in Table 1.
Where Can You Get Coding Examples?
As anyone who has been programming for a while will tell you, some of the most productive coding you'll do will come from reusing code "borrowed" from other sources. This gives you a head start because you can use known, working code that solves a particular problem. PFC includes a comprehensive sample application that gives thorough examples of coding techniques for PFC objects and services. The PFC Example application is in the folder C:Program FilesSybasePowerBuilder 9.0PFCExamples. Add the target file "PFC Examples.pbt" to your workspace. Perform a full build of this target, then run the application.
The user interface for this application lets you select a given illustration and run that example. As you review each of these mini-applications, take note of any useful or interesting implementations. Then check out the code to find the techniques used to create the effects.
The windows for the examples can be found in the file APPEXAMP.pbl. Find the window that corresponds to the example that you want to examine. When you look at the code, you'll see well-coded working illustrations of PFC techniques. You can copy and paste this code and modify it to suit the purposes of your own PFC applications.
The help file for the PFC Examples application says, "The front end launching utility is probably the best example in the application." The front end launcher presents you with a very rich user interface that uses many PFC techniques:
- TreeView
- ListView
- Split Bar
- Resize Service
- MRU Service
- Debug and SQL Spy Service
- Status Bar Service
Using Common PFC Objects and Services
Use PFC visual user objects much like you would use any standard PowerBuilder object. That is, you simply place the object on your window or user object using the user object button on the Painter Bar. When you write code for these objects you will see additional events that you can place script in.
PFC services are nonvisual objects. These must be created (or instantiated) in order to use them. As you have already seen, you do this by calling a function of the form of_set<service> where <service> represents the service you want to use.
For many services you must supply additional information. In most cases, the service will provide one or more forms of the function of_register. Of_register is used to supply related column names to the linkage service, to configure controls for the resize service, and for many other uses throughout PFC services. There are also a number of functions such as of_setTransObject that you use to supply a value for a single property to a PFC object or service.
In the next few sections you'll see a sampling of a few of the more useful PFC objects and services. This is by no means an exhaustive catalog, but rather an introduction to a select few of PFC's features.
PFC Constants
To make coding easier and your resulting code more readable, PFC includes a number of symbolic constants. You'll find the PFC constants in each of the services or objects that require them. For instance, the Linkage service defines a number of constants, including those that specify the update style. Look in the instance variables for the declarations of the constants:
//- UpdateStyle Constants:
constant integer TOPDOWN =1
constant integer BOTTOMUP =2
constant integer TOPDOWN_BOTTOMUP =3
constant integer BOTTOMUP_TOPDOWN =4
constant integer CUSTOM =101
To use these constants, use the reference variable defined for the service. For example, this statement uses constants defined on the DataWindow's inv_linkage service:
dw_master.inv_linkage.of_setUpdateStyle(dw_master.inv_linkage.TOPDOWN)
Menus
PFC Menus use a feature called the Message Router to notify windows and controls of the user's menu selection. Each menu that is descended from pfc_m_master has a function, of_sendMessage, that is used to initiate the message router with a specific text message. The text message is the name of an event that you want to be executed on a window or control in response to your user's menu selection. For instance, to send a message that the user would like to start a queue, the call to of_sendMessage would look like this:
of_sendMessage("ue_startqueue")
The call to of_sendMessage should be placed in the clicked event of the menu item. Figure 1 shows the path a message takes through the message router.
As you can see, the of_sendMessage function passes the message to the pfc_messageRouter event on the current window where it's processed. The pfc_messageRouter event then tries to trigger the event on (in order) the current window, the current control, the last active DataWindow, and the MDI frame. If no place can be found to trigger the event, the message is ignored. If the message can be processed, no further routing takes place.
PFC also includes four right-mouse button (RMB) menus, shown in Table 2.
The RMB menus do not use the message router. Instead, they use the dynamic keyword to fire an event on the parent control. For instance, the "Cut" selection on m_edit fires an event called pfc_cut on the parent control, if such an event exists. This is the code from the pfc_m_edit clicked event for the m_edititem.m_cut menu item:
idrg_parent.dynamic event pfc_cut()
An event on the PFC controls, pfc_preRMBMenu, allows you to manage menu settings. Pfc_preRMBMenu receives the menu as an argument. To enable or disable a particular menu item, code true or false for the enabled property of that menu item. For example, to disable the "delete" menu item for the DataWindow's RMB menu, code the following in the pfc_preRMBMenu event of the u_dw based DataWindow control:
am_dw.m_table.m_delete.enabled = false
To completely disable the RMB menu for a control, insert the following code into the constructor event of the control:
ib_RMBMenu = FALSE
datawindows (u_dw)
The PFC DataWindow control, u_dw, is one of the most important PFC controls. To use u_dw, just place it on any window as needed. Since it's a user object, you'll use the user object icon on the PowerBuilder Painter Bar to place an instance of u_dw.
Published October 1, 2004 Reads 11,701
Copyright © 2004 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
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.
- User Group Malaise?
- What's New in HTML5
- SAP Buys US Mobile Platform House Syclo
- Best Way to Grow Enterprise Mobility In-House
- What's New in HTML5 - Week of April 1, 2012
- How to Test Drive Enterprise Mobility
- Mobile Marketing News Weekly – Week of March 26, 2012
- Enterprise Mobility Asia News Weekly – Week of March 25, 2012
- The PowerBuilder DataWindow as an Image Thumbnail Display Control
- Mobile Commerce News Weekly – Week of March 19, 2012
- Tablets Have Come of Age
- Mobile Health News Weekly – Week of April 8, 2012
- User Group Malaise?
- What's New in HTML5
- SAP Buys US Mobile Platform House Syclo
- Going Mobile in 2012
- Appeon Mobile: First-Ever Mobility Solution for the PowerBuilder Community
- Take PB to the Web, Mobile & More!
- M2M News Weekly – Week of February 27, 2012
- Best Way to Grow Enterprise Mobility In-House
- What's New in HTML5 - Week of April 1, 2012
- How to Test Drive Enterprise Mobility
- Mobile Marketing News Weekly – Week of March 26, 2012
- Mobility News Weekly – Week of February 20, 2012
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- DDDW Tips and Tricks
- Dynamically Creating DataWindow Objects
- OLE - Extending the Capabilities of PowerBuilder
- Working with SOA & Web Services in PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Custom Common Dialogs Using SetWindowsHookEx
- Sybase ASE 12.5 Performance and Tuning
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Book Excerpt: Sybase Adaptive Server Anywhere





















