Click here to Skip to main content
Click here to Skip to main content

The Ultimate Toolbox Application Customization

, 25 Aug 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Ultimate Toolbox provides a set of classes to allow for application state management and customization.

Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.

Contents

Overview

COXCustomizeManager is a derived class that serves as a control center that provides customization functionality for different aspects of your application. COXCustomizeManager is a container of customize page(s). Each customize page is responsible for customization of a particular area of your application functionality (e.g. customizing menus and toolbars). Refer to the COXCustomizePage class overview and overviews for the standard customize page classes (like COXCustomizeCommandsPage).CDialog

COXCustomizeManager is responsible for initializing all customize pages inserted in the manager. It organizes all pages in groups (by default there is only one group defined - the one that contains standard (predefined) customize pages) and provides navigation facilities by using a shortcut bar control (COXShortcutBar class).

COXCustomizeManager is designed to be easily overridden in order to provide support for custom-defined customize pages. It has many virtual functions that define its behaviour, which can be overridden in order to provide additional customization functionality.

Although the customize manager is easily expandable, in most cases a programmer will use a predefined set of standard customize pages (Customize Commands, Customize Toolbars, Customize Workspace, etc.). COXCustomizeManager provides interface functions for accessing the standard pages and their initialization functions (refer to the class reference for details). In most cases a customization feature will require a programmer to call only one initialization function.

COXCustomizeManager provides a rich set of functions for navigating through customize pages programmatically. These will be useful mostly for programmers who decide to derive their own classes and provide additional functionality.

We've developed many predefined customize pages that will satisfy the more common customization needs (e.g. toolbars, menus, accelerator tables, etc.). All standard pages are documented, and are listed in the overview for the COXCustomizePage class (base class for any customize page).

Note that you do not have to implement your own COXCustomizeManager-derived class in order to specify what standard pages will be included in the customize manager. Moreover, you don't have to include the code that implements the standard pages if you are not interested in using them. For example, in order to include support for customizing toolbars and menus you need to include the following define in your stdafx.h file:

#define OX_CUSTOMIZE_TOOLBARS

The list of all defines that correspond to standard pages can be found in the COXCustomizePage overview in the CHM documentation.

Below you will find the details on how you can use customize manager in your application. (Note that some of the standard pages might require additional initialization steps).

Usage

  1. In your stdafx.h file include defines for the standard pages you are going to use in the customize manager:
#define OX_CUSTOMIZE_TOOLBARS
#define OX_CUSTOMIZE_COMMANDS

These defines will include "Customize Toolbars" and "Customize Commands" standard pages.

  1. Declare a member variable of COXCustomizeManager class in the main window of your application (usually CMainFrame class for SDI/MDI applications)
// customize manager

COXCustomizeManager m_customizeManager;
  1. Handle the WM_CREATE message for the main window and in the handler and call initialization routines for the pages included in the customize manager:
#ifdef OX_CUSTOMIZE_TOOLBARS
VERIFY(m_customizeManager.InitializeToolbars());
#endif //OX_CUSTOMIZE_TOOLBARS

#ifdef OX_CUSTOMIZE_COMMANDS
VERIFY(m_customizeManager.InitializeCommands());
#endif //OX_CUSTOMIZE_COMMANDS

This code will initialize the "Customize Toolbars" and "Customize Commands" standard pages. Note that you have to refer to the documentation for the appropriate way of initializing any particular standard, customized routines because some of them require additional initialization step(s).

Before initializing any page in the Customize manager you have to make sure that the variable that points to application main window is already defined (i.e. AfxGetMainWnd() function returns a pointer to created window). The default MFC implementation sets this variable in the CWinApp-derived class InitInstance() function after loading the frame. Unfortunately, it is too late for some of the standard customize pages. So make sure that you put the following line of code before calling any Initialize... functions:

AfxGetApp()->m_pMainWnd=this;
  1. If you want to save the state of the pages (pages allows you to save the changed settings in the registry) you have to handle WM_CLOSE message for the main window and add the following line of code to this handler:
m_customizeManager.SaveWorkspaceState();
  1. In order to display the customize manager (it is always displayed as modeless window) you can use the following code:
f(!::IsWindow(m_customizeManager.GetSafeHwnd()))
{
    VERIFY(m_customizeManager.Create(COXCustomizeManager::IDD,this));
}
m_customizeManager.SetActiveWindow();
m_customizeManager.ShowWindow(SW_SHOW);

That's all you need to do.

COXCustomizeManager automatically recognizes if it is being used in with the docking windows framework. It behaves differently in a docking windows environment. If your application doesn't use the docking framework then you must to add the following define to your stdafx.h file:

#define OX_CUSTOMIZE_NOTSUPPORTING_DOCKING_FRAMEWORK

For more on the COXCustomizeManager and associated configuration pages, refer to the Application Customization Framework section of the compiled HTML help documentation.

History

Initial CodeProject release August 2007.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.
 
Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

397 members


Comments and Discussions

 
GeneralThe CustimizationDialogBar fails with Office 2003 skin Pinmembermalfaro30-Sep-10 14:19 
Generalproblems with COXCustomizeCommandsPage and COXCustomizeShortKeyPage. Pinmembermalfaro13-Jun-08 15:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150129.1 | Last Updated 25 Aug 2007
Article Copyright 2007 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid