Dynamic Filter and Sort Dialog Styles
Contributed by Mark Derosa
Figure 1: Set Style Preferences window
Using the objects in the attached zip file, simply follow the steps listed below to implement the style preferences service into your application:
1. Copy the n_cst_style_preferences object into one of your application .PBLs.
2. Copy the w_r_set_style_preferences object into one of your application .PBLs.
3. If you have not implemented any changes in n_cst_appmanager in the extension layer, copy the attached n_cst_appmanager object into PFEAPSRV.PBL and skip to step 4; otherwise, follow the steps below to integrate the style preferences service into your existing n_cst_appmanager object:
3.1. Declare a public
instance variable of type n_cst_style_preferences
PUBLIC n_cst_style_preferences inv_StylePreferences
3.2. Create a function in n_cst_appmanager named of_SetStylePreferences to create/destroy the style preferences service. (You can model the function after the of_SetError function in pfc_n_cst_appmanager, replacing inv_Error with inv_StylePreferences and n_cst_error with n_cst_style_preferences.)
3.3. Create the style
preferences service in the pfc_open
event of n_cst_appmanager:
3.4. Destroy the style preferences service in the destructor event of n_cst_appmanager:
3.5. Specify the .INI file, containing the current style preferences, in the pfc_open event of n_cst_appmanager:
3.6. Restore the current style preferences from the .INI file in the pfc_open event of n_cst_appmanager:
4. Create a grid DataWindow object referencing a table in your database and assign it to the DataWindow control in w_r_set_style_preferences. (The current DataWindow object, d_employees, is referencing the EMPLOYEE table from the Powersoft Demo DB.)
5. Create an .INI file named STYLES.INI in your Windows
directory/folder with the following section:
6. To use the style preferences defined by the user, simply use the appropriate get function as the argument for the of_SetStyle function in each service. For example, place the following script in the constructor event of your DataWindow (inherited from u_dw):
// Get the users style preferences
// Instantiate and
set up the filter service
// Instantiate and
set up the sort service
7. Add a menu item providing the user access to the Set Style Preferences window. Place the following script in the clicked event of the new menu item to evoke the window (or use of_SendMessage):
The following objects/files are available in the attached zip file:
Other Tips and Ideas
The concepts described in this document may be applied to any function where the arguments are static values (e.g., 0, 1, 2, Scale, ScaleToRight, etc.). You can dramatically increase the flexibility and consistency of your applications by using this approach for other preference-related features. Naturally, the implementation would depend on the users expectations; if one of those expectations is to use a standard window for each service, this approach will easily satisfy that requirement. Best of all, if the requirement ever changes (or should I say as the requirement changes), code modifications will be minimal since the implementation is centralized.
|Download the||About the extension contributor|
|07/07/1998||Initial Revision||Ver. 1.00|
Interested in contributing material to this web site? Send an email to firstname.lastname@example.org, but don't forget to check the contribution guidelines first.
For information or suggestions about this web site please contact email@example.com
sponsored by Dynamic Technology Group.
The information on this site is provided for advice only and not to be considered a contract or a liability against Dynamic Technology Group.