PFC 6.0 Most Recently Used Service |
Page 3 of 3 |
... continued from page 2
Your version of the code in this event will depend on the approach you have accepted for opening windows within your application. Please note that when using a Non-Exclusive mode this event may be triggered for windows of a class different from the class of the current window. Therefore, the parameter passing method has to be generic enough for multiple window classes. As with the previous events it is possible to move this code into the w_sheet, w_frame, or w_master ancestors.
pfc_MRURestore Pfc_MRURestore is a placeholder event, used to restore the MRU settings. It was left empty to allow the end-user to specify a specific group ID. To restore the settings add a call to the of_restore() function passing the MRU ID as an argument.
One way to allow a more generic MRU implementation is to add an is_mruid instance string variable to the w_master window. If any descendant needs to participate in MRU service the variable may be set by using of_setMRUID() function. A sample generic pfc_MRURestore code is shown below
The same approach may be used to generalise other MRU event logic. |
Limitations The MRU service uses the INI file or the registry to save the persistent information between each call or between multiple application "runs". An obvious limitation imposed by the INI file or the registry is that MRU service can only save string parameters. In cases where the window is opened passing an object instead of a simple datatype, such as an attribute non-visual object, the data contained within that object has to be encoded into a string. This may be done in the pfc_preMRUSave event. The decoding logic should be added to the pfc_MRUProcess event. When using the encoding / decoding approach dont forget the 100 character limit imposed by the MRU datastore dataobject. If needed increase the s_menuitemkey size in d_mruservice datawindow object. Couple of other limits are worth mentioning as well. The total size of the INI file is limited to 64K. A single INI key entry is limited to 4K. The value entry limits in the registry are much higher, going up to 1 Meg, however values above 2K are stored as separate files.
Other Considerations The single argument version of of_register() function defaults to five MRU menu items. To specify a new default number of MRU menu items the of_SetItemCount() function may be used.
If a different number of MRU menu item is required for each ID a second version of the of_register() function may be used.
If more than five menu items are specified additional placeholder MRU menu items have to be added to the m_master menu. As mentioned previously the MRU service will save the information in the INI file or the registry. If some of this information is proprietary you may want to encrypt it to hide it from prying eyes. The MRU object has two events that are perfect for the encryption / decryption logic. The pfc_encode event in the pfc_n_cst_mru contains logic to combine the MRU entry information into a string to be saved in the INI or the registry. Pfc_decode event us used to parse the string. Extending these events offers an opportunity to add any required encryption routines. Conclusion Out of the box it may seem that it takes a lot of code to configure the MRU service. However, the reason for the apparent complexity is that PFC developers were not willing to enforce any behaviour restrictions on every PFC user. After making a couple of assumptions, most of the MRU configuration code can be moved into the framework ancestors and configuration code greatly simplified. Prior to using the service it would be wise to go through the checkpoint below:
The MRU service can give your application the professional feel and ease of navigation found in many standard windows applications. With a little up-front work the service can be easily integrated into your framework or application. Who said PFC took all the fun out of programming?
|
| This article was originally published in the April 98 issue of PowerTimes magazine. To find out more about PowerTimes visit their website at http://www.powertimes.com/ |
Last revised: February 15, 2004 03:58 AM.