PFC 6.0 Most Recently Used Service |
Page 2 of 3 |
... continued from page 1
A different requirement may be that any menu should display a list of any recently opened windows, see Figure 3 below.
Figure 3 Non-exclusive MRU Group Mode
MRU service allows you to register one or more group ID. Each group will keep its own list of recently used windows. The group ID can be then used by each window to tell the service which list is wanted for its menu. The IDs can be registered from the application manager constructor event or the MDI frame open event. The example below registers two IDs
Window Level Code In order for the window to participate in the MRU process configuration and processing code has to be added to a few w_master MRU placeholder events. The key MRU events are pfc_MRUProcess, pfc_MRUSave, pfc_PreMRUSave, and pfc_MRURestore.
pfc_MRUSave When triggered, this event will add the current window to the MRU list. Do not confuse this event with saving the information into the ini file or the registry. The MRU service will do that on the application close. This event is used to tell the service when the MRU menu items should be modified. Possible choices are open, save, or close related events. No code has to be added to the pfc_MRUSave event, but the event will automatically trigger the pfc_PreMRUSave event, described below. Once the MRU Save timing behaviour is determined the code can safely be moved into the extension layer ancestors, specifically w_sheet, w_frame, or w_master.
The is_mruid instance variable can be added to the window to simplify generic event code and is described later in the article. |
pfc_PreMRUSave Pfc_PreMRUSave is a placeholder event intended for populating the information to be saved in the MRU service. N_cst_mruattrib attribute object is used to pass the window specific information. The n_cst_mruattrib object is used in a few MRU events and it is important to become familiar with its structure.
Table 1 - n_cst_mruattrib properties The limits mentioned in Table 1 are imposed by the datastore used internally by the MRU service. If you find them restricting, increase the column size in the d_mruservice datawindow. Sample Pfc_PreMRUSave code is shown below.
If the window class name is used for an exclusive ID all of the code with the exception of the line populating is_menuitemkey property can be moved up into an ancestor window.
pfc_MRUProcess Pfc_MRUProcess event will be fired when a user clicks on the MRU menu item. It should contain the code needed to respond to a clicked MRU menu item. This is the even you will use to open the requested window. An event argument contains a row in the internal datastore. This row can be used to populate an instance of the n_cst_mruattrib object with the information needed to open the window. See code below or check the template code provided in the pfc_w_master Pfc_MRUProcess. continued on page 3 ...
|
| 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.