|By Alon Baadani||
|September 21, 2009 06:15 AM EDT||
Those who answer to users probably agree that the style of the PowerBuilder applications have remained unchanged for far too long. While major improvements are anticipated with the release of the PowerBuilder 12 beta, developers who would like a quick face-lift for their applications are invited to continue reading here.
RES-Q Healthcare Systems (www.res-q.com) is a provider of resource management software for hospitals. The RES-Q software includes applications for enterprise-wide employee scheduling and staffing, surgery department management and procedure scheduling, patient acuity classification, and productivity management and reporting. These applications are built with PowerBuilder. The constant marketplace demand for applications that have a fresh modern appearance prompted us to search for various ways to enhance the look of the calendars within our scheduling modules.
After extensive research we chose a component from a third-party provider -Codejock Software (http://www.codejock.com). This component, compellingly priced and with an Outlook 2007 style, provided the look and feel we sought (see Figure 1).
Codejock exposes access to its calendar's elaborate object model through OCX technology, with several data store solutions, as XML, MAPI, and databases. The calendar's built-in functionality provides an almost complete solution for anyone willing to store data in an XML file format. However, to meet RES-Q requirements we had to implement a data layer code to store scheduled events in a SQL Anywhere database. Fortunately, Codejock provides Visual Basic code samples for a similar implementation using MS SQL Server. From that starting point Codejock's Mark Doubson contributed to create a PowerBuilder implementation; this demo application is available on CodeXchange (www.sybase.com) as well as from here.
This is by no means a complete application and it uses a limited set of the functions that are available by the OCX. Yet, it will demonstrate what you can do and how to work with this control.
Here are some basic instructions to help you get started:
- Download the calendar and samples from www.codejock.com.
- Register the OCX using regsr32. Here is an expedited way to do this:
- Select the OCX through Windows Explorer.
- Use Ctrl-Shift-Right Mouse to "open with" the OCX.
- Choose [default] program.
- Browse to Windows\System32 and select regsvr32.exe.
- Check to always use the selected program.
- With that done, all you need to do is double-click on the OCX. A successful registration message should display.
A word of caution: OCX runs on each client workstation in a networked environment and requires local registration of the OCX file. This local registration can be done automatically at runtime, at least on Windows XP.
- From the Insert | Control | OLE... menu Insert the OLE Calendar control on to a window (see Figure 2).
- Repeat the last step for the DatePicker control. See Figure 4 for both the DatePicker control - top - and Calendar control - bottom.
- Create a table in your database. You can use the demo database that ships with PowerBuilder; the create table and insert sample data scripts are provided with the source code.
- Create two DataWindows, d_events and d_eventlist. Both use the CalendarEvents table as their data source. The DataWindow d_events retrieves by eventid.
- Write code for the window and calendar events and functions. The entire source code is available for download from Sybase's CodeXchange and Codejock's forum.
PowerBuilder's compiler accepts the OLE Object's Functions and properties without any type checking (as it doesn't know what syntax is expected).
This exposes your application to runtime errors during execution, which can occur when an invalid property or function name was called. Using exception handling, application termination errors can be avoided.
OLEcontrol.object.property = value
CATCH (RuntimeError er)
Messagebox ("Error", er.getmessage ())
You will be working with visual (insertable) controls and non-visual programmable objects. For the visual controls, PowerBuilder automatically includes create and destroy code. Refer in scripts to the control with the Name property as you have specified in the control's general tab. This applies to the calendar and DatePicker controls. However, many other objects are available and are required for implementing various calendar functions, i.e., adding events. The help file provided with the control is a good resource to discover the objects, properties, and methods you can use (see Figure 3).
Working with programmable objects requires you to manage their reference variables. You will need to declare an OLE Object variable, allocate memory for it, and destroy it:
myoleobject = CREATE OLEObject
Here is a short guided tour to using the controls. Prepare to be wowed!
- Use the navigation arrows to move around the calendar.
- Switch views - day, week, or month - and notice that clicking any day of a month places you on that day, when in day view.
- Select different days using the DatePicker while in day view. When holding the control key down, notice a multi-day custom view is created with these non-consecutive days (see Figure 4).
- Double-click on the calendar to add or modify events with a dialog, or just edit data in place. Right-click while the cursor is on an event to display a popup menu for Add/Modify/Delete/Print.
- Click on the symbol found on the right-hand side of the caption bar. A print preview screen for the current view appears.
You are given a wealth of properties to manage the appearance and configuration of the calendar control. You may choose to expose these property controls to the user with your application's implementation (similar to what we have with the Theme selection accessed in the tool bar Options menu as shown in Figure 4).
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- Creation and Consumption of Web Services with PowerBuilder
- Cloud People: A Who's Who of Cloud Computing
- DDDW Tips and Tricks
- Working with SOA & Web Services in PowerBuilder
- Cloud Expo 2011 East To Attract 10,000 Delegates and 200 Exhibitors
- Dynamically Creating DataWindow Objects
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Custom Common Dialogs Using SetWindowsHookEx
- Cloud Expo and The End of Tech Recession
- Solutions for Optimizing ASP.NET Applications
- Dynamic SQL
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App