PFC Guide Titlebar
HomeFAQLinksPFCMAGExtensionsDownloadWhat's NewSearch

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.

figure3.gif (1321 bytes)

Figure 3 – Non-exclusive MRU Group Mode

 

MRU service allows you to register one or more group ID. Each group will keep it’s 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

inv_mru.of_register("employeemaint")

inv_mru.of_register("all")

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.

If isvalid(gnv_app.inv_mru) &
    and Len(is_mruid) > 0 then
	This.event pfcMRUSave()
end if

 

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 it’s structure.

Variable

MaxLen

Description

is_id

50

MRU group ID

is_classname

50

Window class name

is_menuitemname

50

Menu text

is_menuitemkey

100

Parameter to be passed to the window

is_menuitemmhelp

100

Menu Microhelp

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.

// Non-Exclusive ID
// anv_mruattrib.is_id = "all"
// Exclusive ID
anv_mruattrib.is_id = this.classname()
anv_mruattrib.is_classname = &
this.classname()

anv_mruattrib.is_menuitemname = &
this.title

anv_mruattrib.is_menuitemkey = &
String(il_emp_id)

anv_mruattrib.is_menuitemmhelp = &
"Opens " + this.title

return 1

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 ...


powertimes.gif (11989 bytes)

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.