Mastering PowerBuilder

HomePrevious Lesson: DataWindow Caching Service
Next Lesson: pfc_MRUSave

Most Recently Used Object Service

You might have seen in all most all applications that they list recently opened documents/windows under the File menu option right above the Exit menu option. Some sophisticated applications such as PowerBuilder even went to the extent of displaying recently used objects by category. PFC has a service object to provide this functionality in your PFC enabled application; but it comes with a little bit of coding.

The MRU is an application level service and is therefore enabled from the application manager constructor event.
// Enable and Configure the MRU Service
of_SetMRU(true)
IF this.of_IsRegistryAvailable() THEN
   this.inv_mru.of_SetUserKey(this.of_GetUserKey())
ELSE
   this.inv_mru.of_SetUserINIFile(this.of_GetUserINIFile())
END IF

The service provides an option of INI file or the registry to store the MRU data. The above code enables the service and configures it to use the registry to store the MRU information. Enabling either the INI file or the registry is enough, you don't have make another call to turn-off the other. When you call the of_SetUserINIFile(), it automatically turns off the registry usage for MRU service and vice versa.

MRU service allows you to register one or more group IDs. Each group will keep it�s own list of recently used windows. Each window to tell the service which list it wants for its menu can then use the group ID. The IDs can be registered from the application manager constructor event or the MDI frame open event, but the former is preferable.
gnv_app.inv_mru.of_Register("pms")

In order for the window to participate in the MRU process, code needs to be added to a few w_master MRU placeholder events. The key MRU events are:

You do not need to write any code for pfc_MRUClicked; this event is fired when user clicks one of the MRU menu option under the File menu option. This event in turn fires pfc_MRUProcess event.
HomePrevious Lesson: DataWindow Caching Service
Next Lesson: pfc_MRUSave