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:
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.
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.
TRY
OLEcontrol.object.property = value
CATCH (RuntimeError er)
Messagebox ("Error", er.getmessage ())
END TRY
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:
OLEObject myoleobject
myoleobject = CREATE OLEObject
myoleobject.ConnectToObject(classname)
....
Destroy myoleobject
Here is a short guided tour to using the controls. Prepare to be wowed!
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).