PFC Guide Titlebar
HomeFAQLinksPFCMAGExtensionsDownloadWhat's NewSearch

Preference Service FAQ

Table of Contents

  1. Why doesn't the Preference service remember that I want my window Maximized?
  2. Why doesn't the Preference service remember my setting for showing the Toolbar Text?
  3. Deja vu! How is my toolbar remembering my previous pictures after I changed my menus?
  4. When I select menuoption File/Exit my windows' Preferences are not saved.

The Preference service is resizing my window but not the controls on the window.

Contributed by Sharon Buntz

The Preference service resizes the window according to the size stored in the registry/INI file. However, the Preference service does not bother to save every controls' size and position because the moving/resizing of the controls on the window are left up to the Resize service.

So use the Resize service in conjunction with the Preference service in order to have the window's controls automatically resize when the Preference service resizes the window. Please see the for details plus an example of how to use both services together.

Be sure to turn both the Resize service and the Preference service in the window's pfc_PreOpen event. Also make sure to register all controls in the either the pfc_PreOpen event or an event that executes before it.

Back to Top

Why doesn't the Preference service remember that I want my window Maximized?

Contributed by Sharon Buntz

The Preference service saves the last "state" of the window.  However it does not handle restoring the "state" of the window - Maximized, nor Minimized.   Minimized is understandable since it is not "standard Windows behavior" to restore a Minimized state of a window.  However, it is "standard Windows behavior" to restore a Maximized window state, and many users like this preference.

Here is one way to override the PFC's ancestor code in order to have a net effect of seeming to "maximize" the window.  This approach, by Bruce Nordstrand, will store (and therefore will naturally restore) the position and size of the maximized window, even though the state of the window will still be "Normal!":

In n_cst_winsrv_preference's of_Save( ) function:
// If the window is currently Minimized then use the 
// stored Position/Size values.  If the window is currently Normal! or Maximized!
// then refresh the stored Position/Size values to ensure accurate data.
If iw_requestor.WindowState=Normal! or iw_requestor.WindowState = Maximized! Then of_SetPosSize()


In n_cst_winsrv_preference's of_SetPosSize( ) function:
// Confirm that the WindowState is of type Normal! or Maximized!
If iw_requestor.WindowState = Normal! or iw_requestor.WindowState = Maximized! Then


Note:  The solution that was previously posted here is shown below.  However, it has a couple of problems:  It will work in the IDE, but not in the actual EXE.  Also, if the user opens a window with a Maximized preference, then they minimize it, then they close it (without restoring it), then a funny little 'scrunched' window will open next time.

In n_cst_winsrv_preference's of_Restore( ) function:
If ib_window Then
   // CODE FOR HANDLING MAXIMIZED WINDOW STATE -----------------------
   li_rc = of_Restore (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
           'window.windowstate', ls_winstate, 'normal')
   if ls_winstate = 'maximized' then
      iw_requestor.windowstate = Maximized!
      iw_requestor.windowstate = Normal!
   end if
   // CODE FOR HANDLING MAXIMIZED WINDOW STATE -----------------------
   If iw_requestor.WindowState = Normal! Then
Back to Top

Why doesn't the Preference service remember my setting for showing the Toolbar Text?

Contributed by Sharon Buntz

The Toolbar Text is an application attribute, not a window or menu attribute. And in PFC 5.0.xx, the preference service does not save these application attributes. However, this feature is coming in PFC 6.0...

From :

2.3 Application Preference service

Back to Top

Deja vu! How is my toolbar remembering my previous pictures after I changed my menus?

Contributed by Sharon Buntz

If you are using some of the Toolbar Preference options (which are turned on by default), be aware that it will "remember" and restore your old toolbar pictures, unaware that your menu may have changed!

Either remember to clear your (and your users') Toolbar settings from your registry/INI file whenever you change your menus... Or, you may find it wise to avoid these toolbar options altogether. In fact, there are several reasons why you may find it advisable to not use these toolbar options:

  1. It is not a useful preference for the user. The user cannot even dynamically move each individual bmp around anyway!
  2. There is a big performance difference on both the storing and the setting of these toolbar preferences at runtime.
  3. Imagine the user's confusion if a programmer changes the menu and their preferences were not "cleared". Plus, there is no easy way for the user to "clear" any or all preferences through the application normally either. And furthermore, you don't really want your users changing their registry settings, as it is easy to accidentally wipe out an important section in there.
To avoid confusion with Preference Toolbar button settings,
turn off the following options (They are ON by default):
// Turn on the Window Preference Service
this.of_SetPreference (TRUE)
IF IsValid(inv_preference) THEN
   this.inv_preference.of_SetWindow (TRUE)
   this.inv_preference.of_SetToolBars (TRUE)
   this.inv_preference.of_SetMenuItems (FALSE)
   this.inv_preference.of_SetToolbarItemOrder (FALSE)
   this.inv_preference.of_SetToolbarItemSpace (FALSE)
   this.inv_preference.of_SetToolbarItemVisible (FALSE)
   this.inv_preference.of_SetToolbarTitles (FALSE)

By the way, there was a bug Pre-PFC 5.0.02 whereby the toolbar preferences were saved no matter what options you set.

PFC 5.0.02 corrections to pfc_n_cst_winsrv_preference's of_Save( ) function:
// 5.0.02 Check for an associated menu prior to saving menu preferences.
// 5.0.02 Save menu items that have pictures only when requested.
Back to Top

When I select menuoption File/Exit my windows' Preferences are not saved.

Contributed by Sharon Buntz

Prior to PFC 5.0.02, the application manager's pfc_exit event simply did a "Halt Close". The code to store the user preferences is done in the window's Close event, and a "Halt Close" does not allow the window's Close event to execute. Therefore, the user preferences were not saved when the user selected menuoption File/Exit.

The newer PFC code closes the MDI frame instead of doing a HALT CLOSE. Closing the frame allows all of the open windows' Close and CloseQuery events to execute, allowing the application to close gracefully, destroying all objects as well. So be sure to take advantage of the code change.

New PFC 5.0.02+ Code for pfc_n_cst_appmanager's pfc_exit event:
w_frame lw_activeframe

lw_activeframe = of_GetFrame()
if IsValid (lw_activeframe) then
   Close (lw_activeframe)
   halt close
end if
Back to Top

Contributed by PFCGuide staff, except where noted otherwise.
PFCGuide is sponsored by Dynamic Technology Group
The information provided is for advice only and not to be considered a contract or a liability against Dynamic Technology Group.

Last revised: February 15, 2004 03:58 AM.