Xtreme Toolkit Pro User Guide

See Also Xtreme Toolkit Pro v12.0
Xtreme Toolkit Pro User Guide

Xtreme Toolkit Professional Edition extends MFC to give you the ability to quickly and easily create professional applications that have the latest visual styles and advanced features that are seen in such products as Microsoft® Office and Microsoft® Visual Studio .NET.

Supported Environments
Visual C++ 5.0
Visual C++ 6.0
Visual C++ 7.0 (.NET 2002)
Visual C++ 7.1 (.NET 2003)
Visual C++ 8.0 (.NET 2005)
Supported Operating Systems
Windows NT 4.0, 2000, XP, 2003
Windows 95, 98, 98SE, ME
Minimum Requirements
Windows 95/NT
Copyright (c) 1998-2008 Codejock Software. All rights reserved.
What do you think about this topic? Send feedback!


Introduction

Chapter 1: Introduction to Xtreme Toolkit Pro v12.0
Next
Introduction

Thank you for purchasing Xtreme Toolkit Pro by Codejock Software! Xtreme Toolkit Pro provides all of the features found in the standard version of the Xtreme Toolkit plus all of the advanced features found in the Xtreme Suite, including Xtreme Command Bars, Xtreme Docking Pane and Xtreme Property Grid, all for one great price.


Using the Manual

Introduction, Codejock Software's Technical Support
See Also Chapter 1: Introduction to Xtreme Toolkit Pro v12.0
Up | Previous | Next
Using the Manual

This manual assumes that you are knowledgeable in Visual C++ and the Microsoft Foundation Classes (MFC). It also uses special type conventions in order to indicate meanings of the items. In order to help you figure these conventions out, they are listed, along with their meanings, in the following table.
ITEM | EXAMPLE | DEFINITION
Function | Func() | All functions are in Courier New font
Class Name | CXTBrowseDialog | All class names are bolded and italicized in a slightly larger font size
File Names | StdAfx.h | All file names are in Courier New font
Code | #include <XTPToolkit.h> | All code is in Courier New font
Menu and Menu Commands | Open the File menu | All menus and menu items are bolded
Key sequences | CTRL+SHIFT+END | All CAPS


Codejock Software Technical Support

Introduction, Using the Manual, Product Features
See Also Chapter 1: Introduction to Xtreme Toolkit Pro v12.0
Up | Previous | Next
Codejock Software Technical Support

Codejock Software provides users with various means of support to ensure that they can always get the help they need. Simply visit us on the web at www.codejock.com and you will be able to find many means of support including:
  • Knowledge Base
  • Samples
  • Discussion Board
  • Suggestions
  • Bug Reports
  • Feature Requests
If you still can’t find the answers to your questions, feel free to contact us either by sending an e-mail to support@codejock.com or by calling 989-723-1442, Monday through Friday 9 a.m. – 6 p.m. EST, to speak with a Codejock Software representative.
Please be sure to check all of our online resources before contacting us so that we may provide better service to all users. Also, please have your registration information available when calling so that we may ensure that we are giving you correct support for your software.


Product Features

Introduction, Codejock Software Technical Support, Installation and Setup Procedures
See Also Chapter 1: Introduction to Xtreme Toolkit Pro v12.0
Up | Previous | Next
Product Features

Product Benefits
The following sections describe some of the key benefits to using Xtreme Toolkit Pro.
Full Source Code
Complete source code is included for Xtreme Toolkit Pro and all sample projects to ensure that you always have access to the latest enhancements and bug fixes. This means you will have access to comprehensive technical support; 30 days of support and maintenance comes free for all of our products including Xtreme Toolkit Pro.
Stay Up-To-Date
Xtreme Toolkit Pro is continually enhanced and improved upon and new versions are released frequently to ensure that you always have the most up-to-date and fully supported version available. This comprehensive set of object-oriented components has been designed to handle most any GUI application development requirement.
Complete Documentation
Xtreme Toolkit Pro comes with complete documentation that gives Windows developers the ability to create sophisticated GUIs similar to those seen in Microsoft® Office, Visual Studio.NET™ and Internet Explorer™.
No Royalty or Runtime Fees
‘No royalty or runtime fees’ means you can freely distribute any application using Xtreme Toolkit Pro without worry, use of the Xtreme Toolkit Pro is royalty free! After your purchase no additional fees are required, so you can use the components indefinitely!
Several Translations Available
Several translations are available. In addition to English, Xtreme Toolkit has been translated for several languages including: Brazilian, Chinese, Czech, German, Danish, Spanish, French, Italian, Japanese, Korean, Dutch, Norwegian, Polish, Romanian, Russian and Swedish.
System Requirements
Xtreme Toolkit Pro is supported by the following operating systems. The minimum requirement for Xtreme Toolkit Pro is Windows 95/NT:
  • WindowsXP
  • Windows NT 4.0, Windows 95/98/98SE
  • Windows 2000, Windows ME
The supported development environments for Xtreme Toolkit Pro are:
  • Visual C++ 7.1 (.NET 2003)
  • Visual C++ 7.0 (.NET 2002)
  • Visual C++ 6.0
  • Visual C++ 5.0 with Platform SDK


Installation and Setup Procedures

Introduction, Product Features , Deployment and Integration
See Also Chapter 2: Installing Xtreme Toolkit Pro v12.0
Up | Previous | Next
Installation and Setup Procedures

Setup Wizard
Run Setup for Xtreme Toolkit Pro and follow the instructions that are provided for you. You can use the Back and Next buttons at the bottom of each panel to navigate through the setup procedures. You may want to follow the default setup options, or you can customize the setup for your specific needs. Upon initializing setup, the following window will appear. Please note that it is suggested that you exit all other applications before continuing with the Setup Wizard.
Setup Welcome Screen...
License Agreement
The next panel contains the license agreement information for Xtreme Toolkit Pro. In order to continue with the setup procedures you MUST accept the agreement. If you are not willing to accept the terms of the agreement, please notify Codejock Software immediately
License Agreement Screen...
Destination Directory
This panel allows you to choose into which directory you would like Xtreme Toolkit Pro to be installed. The bottom portion of the panel informs you of how much disk space the program will require. After you have chosen the appropriate directory, click Next.
Destination Directory Screen...
Select Components
Choose which components you would like to be installed. As you un-check and check items, please notice how much disk space your selection requires, located in the bottom portion of the panel. When you are satisfied with your selection, click Next to continue.
Select Components Screen...
Select Start Menu Folder
This is where you can choose where you would like your shortcuts for Xtreme Toolkit Pro to be placed. After you have made your selection, click Next.
Select Start Menu Folder Screen...
Ready to Install
After these selections are made, your program is ready to install. If you would like to change any settings, click Back to get to the panel you would like to change. If you are ready for installation, click Install.
Ready To Install Screen...
Installation Wizard Complete
When the installation is complete the Deployment Wizard will begin. Click Next to continue to the Deployment Wizard manual.


Deployment and Integration

Introduction, Installation and Setup Procedures, Tutorials Overview
See Also Chapter 3: Deployment and Integration for Xtreme Toolkit Pro v12.0
Up | Previous | Next
Deployment and Integration

Deployment Wizard
The Deployment Wizard will help you set up the installed software, including compiling the libraries and adding the libraries to Visual Studio paths. If you would like to rerun this Wizard at any time, you can do so by selecting ‘Launch Deployment Wizard’ from the ‘Codejock Software’ start menu group. To navigate through this wizard, use the Back and Next buttons located at the bottom of each panel.
Deployment Wizard Welcome Screen...
Select Deployment Actions
In the top window, check the library to be deployed (Xtreme Toolkit Pro) and then choose to compile the selected libraries, add the selected libraries to your Visual Studio paths, or both. You cannot go forward with this deployment until you select your choice(s). When you are finished, click Next.
Select Deployment Actions Screen...
Visual Studio Program Locations
Your Visual C++ versions 5.0, 6.0, 7.0 (.NET) and 7.1 (2003) locations should be present in their respective locations. If they are not correct, or if you must enter one yourself, click Browse to search through your directories for the correct locations. If you do not currently have a version of Visual C++, leave that spot black. When you have finished, click Next.
Program Locations Screen...
Select Primary Visual C++ Version
You can choose from the versions of Visual C++ that you entered in the previous page to use as your primary version. When making this decision, it is important to remember that the libraries, when compiled with a particular version of Visual C++, may not be compatible across all versions of Visual C++. When you have made your selection, click Next.
Visual C++ Version Screen...
Select Build Configurations
You can choose to build as a DLL, build as a static library for applications using MFC as DLL, or build as a static library for applications using MFC as static library. After this selection is made, choose whether your unicode support will be ANSI only, Unicode only, or both. When you are finished, click Next.
Build Configurations Screen...
Ready to Begin
Click Next to begin processing your request.
Ready to Begin Screen...
Completion
The following panel will appear when deployment has successfully completed. Click Finish to exit the wizard. If you wish to perform any additional tasks, you can rerun the wizard at any time.
Completion Screen...


Tutorials Overview

Introduction, Deployment and Integration, How to Create an Application that has Office Style Toolbars and Menu
See Also Chapter 4: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
Tutorials Overview

In order to help you use your new software, we have put together several tutorials that you may find useful. These tutorials include:

  • How to create an application that has Office style toolbars and menus
  • How to add customization to toolbars and menus
  • How to create a custom theme for your application
  • How to add a docking pane to your application
  • How to add intelligent menus to your application
  • How to add MDI menu customization to your application
  • How to Add Custom Command Bar Controls to Your Application
    • Copyright (c) 1998-2008 Codejock Software. All rights reserved.


How to Create an Application that has Office Style Toolbars and Menus

Tutorials Overview, How to create an application that has Office style toolbars and menus, How to add customization to toolbars and menus, How to create a custom theme for your application, How to add a docking pane to your application, How to add intelligent menus to your application, How to add MDI Menu customization to your application, How to Add Custom Command Bar Controls to Your Application
See Also Chapter 4: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Create an Application that has Office Style Toolbars and Menus

The following is a tutorial on how to create an MDI application using the Visual Studio 6.0 Application Wizard that will have Office style menus and toolbars. The same technique can be used for later versions of Visual Studio .NET as well.
Create a simple MDI application using the MFC AppWizard:
  1. From Visual Studio and select File then New and select the Projects tab.
  2. Choose MFC Appwizard(exe) as your project type and enter ‘MDISample’ as the project name.
    Visual Studio New Dialog...
  3. For the first step, make sure that Multiple documents is selected then press the ‘Finish’ button.
Add Xtreme Command Bars components:

  1. Add the following line to your StdAfx.h file:
    Xtreme Toolkit Pro:
    #include <XTToolkitPro.h> // Xtreme Toolkit Pro component library
  2. In your MainFrm.h file you need to change your base class to be CXTPMDIFrameWnd for MDI applications or CXTPFrameWnd for SDI applications:
    class CMainFrame : public CXTPMDIFrameWnd
{
    ...
};
  3. If you plan to override either PreTranslateMessage or OnWndMsg make sure that you call the CXTPFrameWnd or CXTPMDIFrameWnd base class, for example:
    BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
    // TODO: Add your specialized code here and/or call the base class

    return CXTPMDIFrameWnd::PreTranslateMessage(pMsg);
}

BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode,
    void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
    // TODO: Add your specialized code here and/or call the base class

    return CXTPMDIFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
  4. Add the following code to the int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) function:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Create Status bar.
    // Important: All control bars including the Status Bar
    // must be created before CommandBars....
    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }

    // Initialize the command bars
    if (!InitCommandBars())
        return -1;

    // Get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }

    // Add the menu bar
    CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
        _T("Menu Bar"), IDR_MDISAMTYPE);
    if(pMenuBar == NULL)
    {
        TRACE0("Failed to create menu bar.\n");
        return -1;      // fail to create
    }

    // Create ToolBar
    CXTPToolBar* pToolBar = (CXTPToolBar*)
        pCommandBars->Add(_T("Standard"), xtpBarTop);
    if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;
    }

    // Set Office 2003 Theme
    CXTPPaintManager::SetTheme(xtpThemeOffice2003);

    return 0;
}
    Now we have an MDI application with an Offiice 2003 interface...it’s that Easy!
    MDI Sample Application...


How to Add Customization to Toolbars and Menus

Tutorials Overview, How to create an application that has Office style toolbars and menus, How to add customization to toolbars and menus, How to create a custom theme for your application, How to add a docking pane to your application, How to add intelligent menus to your application, How to add MDI Menu customization to your application, How to Add Custom Command Bar Controls to Your Application
See Also Chapter 4: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Add Customization to Toolbars and Menus

The following is a tutorial on how to create add customization to your applications toolbars and menus to your application. This tutorial assumes that you have already created an application that uses office style toolbars and menus.
Add customization for toolbars and menus.
  1. Add an ON_COMMAND for XTP_ID_CUSTOMIZE to the message map for CMainFrame. This will handle setup and display for the toolbar and menu customization dialog.
    In MainFrm.cpp add the following code:
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ON_WM_CREATE()
    //}}AFX_MSG_MAP
    ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
END_MESSAGE_MAP()
    in MainFrm.h add the following code:
        //{{AFX_MSG(CMainFrame)
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    //}}AFX_MSG
    afx_msg void OnCustomize();
    DECLARE_MESSAGE_MAP()
  2. Add the body for the OnCustomize function:
    void CMainFrame::OnCustomize()
{
    // Get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars != NULL)
    {
        // Instanciate the customize dialog object.
        CXTPCustomizeSheet dlg(pCommandBars);

        // Add the options page to the customize dialog.
        CXTPCustomizeOptionsPage pageOptions(&dlg);
        dlg.AddPage(&pageOptions);

        // Add the commands page to the customize dialog.
        CXTPCustomizeCommandsPage* pCommands = dlg.GetCommandsPage();
        pCommands->AddCategories(IDR_MDISAMTYPE);

        // Use the command bar manager to initialize the
        // customize dialog.
        pCommands->InsertAllCommandsCategory();
        pCommands->InsertBuiltInMenus(IDR_MDISAMTYPE);
        pCommands->InsertNewMenuCategory();

        // Dispaly the dialog.
        dlg.DoModal();
    }
}
  3. Add LoadCommandBars(_T("CommandBars")); to the OnCreate function for CMainFrame. This will restore the previous state of your toolbar and menus plus any customization made.
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    // Load the previous state for toolbars and menus.
    LoadCommandBars(_T("CommandBars"));

    return 0;
}
  4. Add the OnClose message handler to CMainFrame and add SaveCommandBars(_T("CommandBars")); before the call to the base class. This will save the current state of your toolbar and menus in plus any customization made.
    void CMainFrame::OnClose()
{
    // Save the current state for toolbars and menus.
    SaveCommandBars(_T("CommandBars"));
    CMDIFrameWnd::OnClose();
}
    MDI Sample Application Add or Remove Buttons Menu...
    MDI Sample Application Customize Dialog...


How to Create a Custom Theme for Your Application

Tutorials Overview, How to create an application that has Office style toolbars and menus, How to add customization to toolbars and menus, How to create a custom theme for your application, How to add a docking pane to your application, How to add intelligent menus to your application, How to add MDI Menu customization to your application, How to Add Custom Command Bar Controls to Your Application
See Also Chapter 4: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Create a Custom Theme for Your Application

You can create a custom theme for your application by deriving a class from any of the theme classes availiable in the toolkit.

Create a double gripper theme similar to Visual Studio 6.0.
  1. Create a new class derived from one of the predefiend themes found in the toolkit. We are going to use CXTPDefaultTheme; however you can use any of the following theme classes:
    CXTPDefaultTheme to inherit Office 2000 theme
    CXTPOfficeTheme to inherit Office XP theme
    CXTPOffice2003Theme to inherit Office 2003 theme
    CXTPNativeXPTheme to inherit Native XP theme
    class CDoubleGripperTheme : public CXTPDefaultTheme
{
    ...
};
  2. Override the DrawCommandBarGripper of CXTPDefaultTheme base class (See XTPPaintManager.h). This will allow us to add our own custom look for drawing the command bar grippers:
    class CDoubleGripperTheme : public CXTPDefaultTheme
{
    virtual CSize DrawCommandBarGripper(
        CDC* pDC, CXTPCommandBar* pBar, BOOL bDraw);
};

// DrawCommandBarGripper function.
// if bDraw if FALSE must return gripper size.
// if bDraw is TRUE must draw gripper.
CSize CDoubleGripperTheme::DrawCommandBarGripper(CDC* pDC,
    CXTPCommandBar* pBar, BOOL bDraw)
{
    // If Toolbar is vertical docked
    if (pBar->GetPosition() == xtpBarRight ||
        pBar->GetPosition() == xtpBarLeft)
    {
        if (bDraw)
        {
            CXTPClientRect rc(pBar);
            Draw3dRect(pDC, CRect(3, 3, rc.right - 3, 6),
                COLOR_BTNHILIGHT, COLOR_3DSHADOW);
            Draw3dRect(pDC, CRect(3, 7, rc.right - 3, 10),
                COLOR_BTNHILIGHT, COLOR_3DSHADOW);
        }
        return CSize(0, 10);
    }
    // if Toolbar is horizontal  docked
    else
    if (pBar->GetPosition() == xtpBarTop ||
        pBar->GetPosition() == xtpBarBottom)
    {
        CXTPClientRect rc(pBar);
        if (bDraw)
        {
            Draw3dRect(pDC, CRect(3, 3, 6, rc.bottom - 3),
                COLOR_BTNHILIGHT, COLOR_3DSHADOW);
            Draw3dRect(pDC, CRect(7, 3, 10, rc.bottom - 3),
                COLOR_BTNHILIGHT, COLOR_3DSHADOW);
        }
        return CSize(10, 0);
    }
    else return CXTPDefaultTheme::DrawCommandBarGripper(pDC, pBar, bDraw);
}
  3. Call CXTPPaintManager::SetCustomTheme from CMainFrame::OnCreate() method to use the theme we just created:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    // Use our own theme for drawing command bar grippers.
    CXTPPaintManager::SetCustomTheme(new CDoubleGripperTheme());

    return 0;
}
    MDI Sample Application Showing Custom Theme...


How to Add a Docking Pane to Your Application

Tutorials Overview, How to create an application that has Office style toolbars and menus, How to add customization to toolbars and menus, How to create a custom theme for your application, How to add a docking pane to your application, How to add intelligent menus to your application, How to add MDI Menu customization to your application, How to Add Custom Command Bar Controls to Your Application
See Also Chapter 4: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Add a Docking Pane to Your Application

The following is a tutorial on how to create an MDI application with Docking Panes using the Visual Studio 6.0 Application Wizard. The same technique can be used for later versions of Visual Studio . NET as well.
Create a simple MDI application using the MFC AppWizard:
  1. From Visual Studio select File then New and select the Projects tab.
  2. Choose MFC Appwizard(exe) as your project type and enter ‘MDISample’ as the project name.
    Visual Studio New Project Dialog...
  3. For the first step, make sure that Multiple documents is selected then press the ‘Finish’ button.
Add Empty Docking Panes:
  1. Add the following line to your StdAfx.h file:
    Xtreme Toolkit Pro:
    #include <XTToolkitPro.h> // Xtreme Toolkit Pro component library
  2. Add CXTPDockingPaneManager member to CMainFrame class:
    // Attributes
public:
    CXTPDockingPaneManager m_paneManager;
  3. Add string resources for the titles of the future panes:
    IDR_PANE_OPTIONS       61446    Options
IDR_PANE_PROPERTIES    61447    Properties
  4. Add following to CMainFrame::OnCreate:
    // Initialize the docking pane manager and set the
// initial them for the docking panes.  Do this only after all
// control bars objects have been created and docked.
m_paneManager.InstallDockingPanes(this);
m_paneManager.SetTheme(xtpPaneThemeOffice);

// Create docking panes.
CXTPDockingPane* pwndPane1 = m_paneManager.CreatePane(
    IDR_PANE_OPTIONS, CRect(0, 0,200, 120), dockLeftOf);
CXTPDockingPane* pwndPane2 = m_paneManager.CreatePane(
    IDR_PANE_PROPERTIES, CRect(0, 0,200, 120), dockBottomOf, pwndPane1)
    MDI Sample Application With Docking Panes...
Attach CWnd derived class to the panes:
  1. Add a CWnd derived class as member of CMainFrame:
    // Attributes
public:
    CStatic m_wndOptions;
    CEdit m_wndProperties;
  2. Add OnDockingPaneNotify handler.
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ON_WM_CREATE()
    //}}AFX_MSG_MAP
    ON_MESSAGE(XTPWM_DOCKINGPANE_NOTIFY, OnDockingPaneNotify)
END_MESSAGE_MAP()

LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
{
    if (wParam == XTP_DPN_SHOWWINDOW)
    {
        CXTPDockingPane* pPane = (CXTPDockingPane*)lParam;

        if (!pPane->IsValid())
        {
            switch (pPane->GetID())
            {
            case IDR_PANE_PROPERTIES:
                {
                    if (m_wndProperties.GetSafeHwnd() == 0)
                    {
                        m_wndProperties.Create(WS_CHILD|
                            ES_AUTOVSCROLL|ES_MULTILINE,
                            CRect(0, 0, 0, 0), this, 0);
                    }
                    pPane->Attach(&m_wndProperties);
                    break;
                }
            case IDR_PANE_OPTIONS:
                {
                    if (m_wndOptions.GetSafeHwnd() == 0)
                    {
                        m_wndOptions.Create(_T("\n\nOptions"),
                            WS_CHILD|WS_CLIPCHILDREN|
                            WS_CLIPSIBLINGS|SS_CENTER,
                            CRect(0, 0, 0, 0), this, 0);
                    }
                    pPane->Attach(&m_wndOptions);
                    break;
                }
            }
        }
        return TRUE;
    }
    return FALSE;
}
    MDI Sample Application With CWnd Objects Attached to Docking Panes...
Add Images for Dockig Pane Tabs:
  1. Create Bitmap with icons for created panes
    Visual Studio Resource Editor...
  2. Add to CMainFrame::OnCreate
    int nIDIcons[] = {IDR_PANE_OPTIONS, IDR_PANE_PROPERTIES};
    m_paneManager.SetIcons(IDB_BITMAP_ICONS, nIDIcons,
    _countof(nIDIcons), RGB(0, 255, 0));
    Visual Studio Resource Editor...

Add Save and Load State Handlers:

  1. Add following to the OnCreate function for CMainFrame. This will restore the previous state of docking panes:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    // Load the previous state for docking panes.
    CXTPDockingPaneLayout layoutNormal(&m_paneManager);
    if (layoutNormal.Load(_T("NormalLayout")))
    {
        m_paneManager.SetLayout(&layoutNormal);
    }
    return 0;
}
  2. Add the OnClose message handler to CMainFrame and the following before the call to the base class. This will save the current state of your docking pane:
    void CMainFrame::OnClose()
{
    // Save the current state for docking panes.
    CXTPDockingPaneLayout layoutNormal(&m_paneManager);
    m_paneManager.GetLayout(&layoutNormal);
    layoutNormal.Save(_T("NormalLayout"));
    CMDIFrameWnd::OnClose();
}


How to add intelligent menus to your application

Tutorials Overview, How to create an application that has Office style toolbars and menus, How to add customization to toolbars and menus, How to create a custom theme for your application, How to add a docking pane to your application, How to add intelligent menus to your application, How to add MDI Menu customization to your application, How to Add Custom Command Bar Controls to Your Application
See Also Chapter 4: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Add Intelligent Menus to Your Application

The following is a tutorial on how to add intelligent menus to your application. This tutorial assumes that you have already created an application that uses Office style toolbars and menus.
Create a simple MDI application using the MFC AppWizard:
  1. Add array of Ids that seem not very important for user.
    static UINT uHideCmds[] =
{
    ID_FILE_PRINT, ID_FILE_PRINT_PREVIEW, ID_WINDOW_CASCADE
};
  2. Add to the CMainFrame::OnCreate Intelligent menu initialization:
    // Hide array of commands
pCommandBars->HideCommands(uHideCmds, _countof(uHideCmds));

// Set "Always Show Full Menus" option to the FALSE
XTP_COMMANDBARS_OPTIONS* pOptions = pCommandBars->GetCommandBarsOptions();
pOptions->bAlwaysShowFullMenus = FALSE;
  3. Add LoadCommandBars(_T("CommandBars")); to the CMainFrame::OnCreate method. This will restore the previous state of your toolbar and menus plus any customization made:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    // Load the previous state for toolbars and menus.
    LoadCommandBars(_T("CommandBars"));

    return 0;
}
  4. Add the OnClose message handler to CMainFrame and add SaveCommandBars(_T("CommandBars")); before the call to the base class. This will save the user’s used commands:
    void CMainFrame::OnClose()
{
    // Save the current state for toolbars and menus.
    SaveCommandBars(_T("CommandBars"));
    CMDIFrameWnd::OnClose();
}
    MDI Sample Application with Intelligent Menus...


How to Add MDI Menu customization to Your Application

Tutorials Overview, How to create an application that has Office style toolbars and menus, How to add customization to toolbars and menus, How to create a custom theme for your application, How to add a docking pane to your application, How to add intelligent menus to your application, How to add MDI Menu customization to your application, How to Add Custom Command Bar Controls to Your Application
See Also Chapter 4: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Add MDI Menu customization to Your Application

Version 12.0 of Xtreme Command Bars has three ways for developers to add MDI Menu customization menus. This tutorial assumes that you have already created an application with customization.
Standard MDI Menu customization:
This method uses the MFC architecture for MDI menus, you just need to add standard customization without additional changes. As in a standard MFC application, you must add templates for each MDI document type.
Advantages:
  • Ease to add customization
  • Ease to modify standard MFC application
Disadvantages:
  • All disadvantages belong to the user-side. Users must manually customize all templates in the application. For example if the users want to see ‘View’ popup before ’File‘ they must customize each doc template and Main Frame template.
Notes:
  • Be sure that when you create a menu you use the IDR_MAINFRAME identifier:
    • CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
    _T("Menu Bar"), IDR_MAINFRAME);
  • See the CustomizeDlg sample for this customization type.
  • The xtpFlagUseMDIMenus flag has been depreciated and is no longer used.
Static MDI Menu customization:
All you need is to add the xtpFlagIgnoreSetMenuMessage flag to the Menu Bar:
CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_CUSTOMTYPE);
    pMenuBar->SetFlags(xtpFlagIgnoreSetMenuMessage);
All other menu templates will be ignored.
Advantages:
  • Ease to add customization
  • Ease to modify standard MFC application
  • Easy for users to customize the application, because they need customize only a single menu used for all templates
Disadvantages
  • Static menus not very flexible for developers to apply some document types
Notes:
  • See CustomThemes sample for this customization type
Custom MDI menu customization:
This is the most difficult for developers, but the most friendly type for user customization. Developers must create only one Menu template with all popup items needed to be used in the application, and assign programmatically what popup items are shown in each template. For example developers must add the ‘Window’ item but assign it to show only when some documents are visible.
For this customization type add ExcludeDocTemplate() and AssignDocTemplate() methods of CXTPControl class.
Advantages:
  • Easy for users to customize the application, because they need customize only a single menu to be used for all templates
Disadvantages
  • Developers must manually assign the popup items that are visible when the document template is active
Notes:
  • Visual Studio 6.0 and .NET used such customization type. (If you customize the ‘File’ item and open some image to edit, a new ‘Image’ popup appears but the changes in the File section stay the same.)
  • See MDIMenus sample for this customization type


How to Add Custom Command Bar Controls to Your Application

Tutorials Overview, How to create an application that has Office style toolbars and menus, How to add customization to toolbars and menus, How to create a custom theme for your application, How to add a docking pane to your application, How to add intelligent menus to your application, How to add MDI Menu customization to your application, How to Add Custom Command Bar Controls to Your Application
See Also Chapter 4: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Add Custom Command Bar Controls to Your Application

If you need to provide new functionality to standard Command Bars controls (CXTPControlButton, CXTPControlPopup, CXTPControlComboBox, CXTPControlEdit) you must create a new class inherited from one of these and override some virtual methods. This tutorial describes how to create custom Combo Box.
Imagine that you need a combo box with uppercase letters only (When users enter a character it automatically becomes uppercase)
Create a derived class to provide additional functionality for Command bars controls:
  1. Create a new class inherited from CXTPControlComboBox:
    class CControlComboBoxEx: public CXTPControlComboBox
{
public:
    ...
};
  2. To create custom edit we must override CreateEditControl method and add a new Edit Control inherited from CXTPControlComboBoxEditCtrl:
    class CControlComboBoxEx: public CXTPControlComboBox
{
public:
    CXTPControlComboBoxEditCtrl* CreateEditControl()
    {
        return new CControlComboBoxEditEx();
    }
};

class CControlComboBoxEditEx : public CXTPControlComboBoxEditCtrl
{
    ...
};
  3. Add OnChar handler to automatically uppercase the characters that the user entered:
    class CControlComboBoxEditEx : public CXTPControlComboBoxEditCtrl
{
public:
    afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);

    DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(CControlComboBoxEditEx, CXTPControlComboBoxEditCtrl)
    ON_WM_CHAR()
END_MESSAGE_MAP()

void CControlComboBoxEditEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    CString strChar((TCHAR)nChar), strUpper((TCHAR)nChar);
    strUpper.MakeUpper();

    if (strChar != strUpper) ReplaceSel(strUpper, TRUE);
    else CXTPControlComboBoxEditCtrl::OnChar(nChar, nRepCnt, nFlags);
}
  4. If your application uses customization you must add methods to restore your combo box after the program reloads add standard DECLARE and IMPLEMENT macros:
    class CControlComboBoxEx: public CXTPControlComboBox
{
    DECLARE_XTP_CONTROL(CControlComboBoxEx)
public:
    CXTPControlComboBoxEditCtrl* CreateEditControl()
    {
        return new CControlComboBoxEditEx();
    }
};

IMPLEMENT_XTP_CONTROL(CControlComboBoxEx, CXTPControlComboBox)
  5. If your control has its own variables that need to be stored / restored you must override Copy and DoPropExchange methods:
    class CControlComboBoxEx: public CXTPControlComboBox
{
...

protected:
    void Copy(CXTPControl* pControl, BOOL bRecursive = FALSE);
    virtual void DoPropExchange(CXTPPropExchange* pPX);

protected:
    CString m_strMask;
};

void CControlComboBoxEx::Copy(CXTPControl* pControl, BOOL bRecursive)
{
    ASSERT_KINDOF(CControlComboBoxEx, pControl);

    m_strMask = ((CControlComboBoxEx*)pControl)->m_strMask;

    CXTPControlComboBox::Copy(pControl, bRecursive);
}

void CControlComboBoxEx::DoPropExchange(CXTPPropExchange* pPX)
{
    CXTPControlComboBox::DoPropExchangepPX);

    PX_String(pPX, _T("Mask"), m_strMask);
}
  6. Now you can create your control in the CMainFrame::OnCreateControl handler:
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    ON_XTP_CREATECONTROL()
END_MESSAGE_MAP()

int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{
    if (lpCreateControl->nID == ID_POPUP_COMBO)
    {
        CXTPControlComboBox* pComboFind = (CXTPControlComboBox*)CControlComboBoxEx::CreateObject();
        pComboFind->SetDropDownListStyle();
        pComboFind->SetFlags(xtpFlagManualUpdate);

        lpCreateControl->pControl = pComboFind;
        return TRUE;
    }
    return FALSE;
}


Migrating from Xtreme Toolkit Standard Edition

Introduction, Tutorials Overview, FAQ Overview
See Also Chapter 5: Tutorials for Using Xtreme Toolkit Pro v12.0
Up | Previous | Next
Migrating from Xtreme Toolkit Standard Edition

Introduction
Many components such as toolbars, menubars and docking windows for the professional edition are quite different from the standard version of Xtreme Toolkit. This is because the architecture has changed considerably to provide many new enhanced features. This migration guide will attempt to explain those differences to help you make the process of migrating the standard version to the professional version of Xtreme Toolkit much easier.
Here are the topics that will be covered in this documentation:
  • Preparing Your Application
  • Getting Started
  • Command Bars Initialization
  • Menubar Creation
  • Toolbar (CommandBar) Creation
  • Dock Window Creation
  • Tabbed Dock Window Creation
  • Add customization for toolbars and menus.
  • Add intelligent menus
  • Create a custom theme for your application
Preparing Your Application
The first thing you will need to do is change the include file for the toolkit in your StdAfx.h file. This is the file that is used to bring in all of the toolkit's class definitions and links your application to the toolkit. To do this, open your StdAfx.h file and change #include <XTToolKit.h> to #include <XTToolkitPro.h>, for example:
#include <XTToolkitPro.h> // Xtreme Toolkit Pro components
Renaming Your Base Classes
Next you will need to change some base class derivations. You will need to replace all occurrences of CXT... to C..., for example in a MDI application CXTMDIChildWnd becomes CMDIChildWnd and CXTMDIFrameWnd becomes CMDIFrameWnd. For a SDI application CXTFrameWnd becomes CFrameWnd. Here is a complete list of classes that you will need to change back to their original MFC naming convention. This will return your application to a good starting point for the migration:
Toolkit Class Name | MFC Class Name (rename to)
CXTFrameWnd | CFrameWnd
CXTMDIChildWnd | CMDIChildWnd
CXTMDIFrameWnd | CMDIFrameWnd
CXTOleIPFrameWnd | COleIPFrameWnd
CXTControlBar | CControlBar
CXTDialogBar | CDialogBar
CXTReBar | CReBar
CXTReBarCtrl | CReBarCtrl
Additional Missing Classes
The following classes are no longer available in the professional version of Xtreme Toolkit. They have either been replaced or made obsolete with the new architecture. Most of these classes you would not use directly; however they are listed here for your reference:
Toolkit Class Name
CXTAccelSwapOutItemList | CXTCustOptions | CXTPopupTearOffWnd
CXTAccelManager | CXTCustomizeSheet | CXTPopupColorTearOff
CXTCBarDialog | CXTDockBar | CXTPopupToolbarTearOff
CXTCommandsListBox | CXTDockColorSelector | CXTPreviewView
CXTItemData | CXTDockContext | CXTSplitterDock
CXTCoolMenu | CXTDockWindow | CXTSplitterRowDock
CXTMenu | CXTFrameImpl | CXTToolBar
CXTCustomToolBar | CXTString | CXTToolBarCtrl
CXTCustToolBarPage | CXTMenuBarItem | CXTPopupWndToolbar
CXTCustCommandsPage | CXTMenuBar | CXTToolBarPopupWndHook
CXTCustAccelerators | CXTMiniDockFrameWnd | CXTToolBarPopupWnd
CXTCustTools | CXTNewToolbarDlg | CXTToolsManager
Getting Started
Changing Your Main Frame Inheritance
Now that you have your application free of most of the references to the standard version we can begin our migration process. Now that you have updated your StdAfx.h file, in your MainFrm.h file change your base class to be CXTPMDIFrameWnd for MDI applications and CXTPFrameWnd for SDI applications:
class CMainFrame : public CXTPMDIFrameWnd
{
    ...
};
If you have overridden PreTranslateMessage make sure that you call the CXTPMDIFrameWnd base class, for example:
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
    // TODO: Add your specialized code here and/or call the base class

    return CXTPMDIFrameWnd::PreTranslateMessage(pMsg);
}
Also, if you have overridden OnCmdMsg make sure that you call the CXTPMDIFrameWnd base class, for example:
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode,
    void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
    // TODO: Add your specialized code here and/or call the base class

    return CXTPMDIFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
Command Bars Initialization
Command bars must be initialized prior to using them, and they must be created after all control bar objects (such as your status bar) have been created. This is also a good place for you to set the theme for the command bars. In the standard version you would callxtAfxData.bXPMode = true; to set the theme for the toolkit to Officexp. In the professional version you have theme managers for each component. This allows you to define your own theme or select from several pre defined themes in the toolkit.
Here is an example of how to initialize the control bars:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Create Status bar.
    // Important: All control bars including the Status Bar
    // must be created before CommandBars....
    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }

    // Initialize the command bars
    if (!InitCommandBars())
        return -1;

    // Get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }

    // Set Office 2003 Theme
    CXTPPaintManager::SetTheme(xtpThemeOfficeXP);

    return 0;
}
Cool Menu Note:
It is no longer necessary to call InstallCoolMenus to initialize themed menus with command icons for your application. This is done internally with the command bars theme manager.
Menubar Creation
You will have to change your existing code to use the pro version of menubars. Most applications that use the standard toolkit will reference CXTMenuBar object in CMainFrame::OnCreate. There the object m_wndMenuBar is created, and enable docking is called to dock the menubar to the applications work area. With the professional toolkit this is done somewhat differently and there is no need to call enable docking, for example:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Create Status bar.
    // Important: All control bars including the Status Bar
    // must be created before CommandBars....
    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }

    // Initialize the command bars
    if (!InitCommandBars())
        return -1;

    // Get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }

    // Add the menu bar
    CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
        _T("Menu Bar"), IDR_MDISAMTYPE);
    if(pMenuBar == NULL)
    {
        TRACE0("Failed to create menu bar.\n");
        return -1;      // fail to create
    }

//  Remove the old menu bar code...
//  if (!m_wndMenuBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
//      | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
//      !m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
//  {
//      TRACE0("Failed to create menubar\n");
//      return -1;      // fail to create
//  }

//  m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
//  EnableDocking(CBRS_ALIGN_ANY);
//  DockControlBar(&m_wndMenuBar);

    return 0;
}
Toolbar (CommandBar) Creation
You will also need to change your code to use the pro version toolbars. As with the menubar, the toolbar object is usually created in CMainFrame::OnCreate and enable docking is called to dock the toolbar to the applications work area. The toolbar is created in a similar way to the menu bar with the addition of loading the toolbar resource, for example:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Create Status bar.
    // Important: All control bars including the Status Bar
    // must be created before CommandBars....
    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }

    // Initialize the command bars
    if (!InitCommandBars())
        return -1;

    // Get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }

    // Add the menu bar
    CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
        _T("Menu Bar"), IDR_MDISAMTYPE);
    if(pMenuBar == NULL)
    {
        TRACE0("Failed to create menu bar.\n");
        return -1;      // fail to create
    }

    // Create ToolBar
    CXTPToolBar* pToolBar = (CXTPToolBar*)
        pCommandBars->Add(_T("Standard"), xtpBarTop);
    if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;
    }

//  Remove the old tool bar code...
//  if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
//      | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
//      !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
//  {
//      TRACE0("Failed to create toolbar\n");
//      return -1;      // fail to create
//  }
//  m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
//  EnableDocking(CBRS_ALIGN_ANY);
//  DockControlBar(&m_wndToolBar);

    return 0;
}
Dock Window Creation
You will also need to change your code to use the pro version toolbars. As with the menubar, the toolbar object is usually created in CMainFrame::OnCreate and enable docking is called to dock the toolbar to the applications work area. The toolbar is created in a similar way to the menu bar with the addition of loading the toolbar resource. You can define the title for your docking pane by creating a string resource with the same id as the dock pane, for example IDC_DOCKWINDOW. You can also call SetTitle as we have done here.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Create Status bar.
    // Important: All control bars including the Status Bar
    // must be created before CommandBars....
    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }

    // Initialize the command bars
    if (!InitCommandBars())
        return -1;

    // Get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }

    // Add the menu bar
    CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
        _T("Menu Bar"), IDR_MDISAMTYPE);
    if(pMenuBar == NULL)
    {
        TRACE0("Failed to create menu bar.\n");
        return -1;      // fail to create
    }

    // Create ToolBar
    CXTPToolBar* pToolBar = (CXTPToolBar*)
        pCommandBars->Add(_T("Standard"), xtpBarTop);
    if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;
    }

    // Initialize the docking pane manager and set the
    // initial them for the docking panes.  Do this only after all
    // control bars objects have been created and docked.
    GetDockingPaneManager()->InstallDockingPanes(this);
    GetDockingPaneManager()->SetTheme(xtpPaneThemeOffice);

    // Create the workspace bar.
    CXTPDockingPane* pwndDockWindow= GetDockingPaneManager()->CreatePane(
        IDC_DOCKWINDOW, CRect(0, 0,200, 120), dockLeftOf);

    // set the title for the pane, not needed if you define a
    // string resource using the pane id (IDC_DOCKWINDOW).
    pwndTabDockBar->SetTitle(_T("Dock Window"));

    // create the tree control for the dock pane.
    if (!m_wndTreeCtrl.Create( WS_VISIBLE | TVS_HASLINES |
        TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS,
        CRect(0,0,0,0), this, IDC_TREE_CTRL ))
    {
        TRACE0("Failed to create tree control.\n");
        return -1;      // fail to create
    }

//  Remove the old dock window code...
//  if( !m_wndDockWindow.Create(this, IDW_TABDOCKBAR, _T("Dock Window"),
//      CSize(200, 150), CBRS_LEFT))
//  {
//      TRACE0("Failed to create workspace dock window\n");
//      return -1;      // fail to create
//  }

    // create the tree control for the dock pane.
//  if (!m_wndTreeCtrl.Create( WS_VISIBLE | TVS_HASLINES |
        TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS,
//      CRect(0,0,0,0), &m_wndDockWindow, IDC_TREE_CTRL ))
//  {
//      TRACE0("Failed to create tree control.\n");
//      return -1;      // fail to create
//  }

    // set the tree control as the child of the dock window.
//  m_wndDockWindow.SetChild(&m_wndTreeCtrl);

//  m_wndDockWindow.EnableDocking(CBRS_ALIGN_ANY);
//  EnableDocking(CBRS_ALIGN_ANY);
//  DockControlBar(&m_wndDockWindow);

    return 0;
}
See Also: How to add a docking pane to your application.
Setting the child window for the dock pane
To set the child window, in this case a tree control for the dock pane you need to call CXTPDockingPane::Attach and pass in the pointer to the window that want to be attached to the docking pane. The best place to do this is when the dock pane is initially displayed. We can do this by using the XTP_DPT_SHOWWINDOW notification message handler as shown here:
LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
{
    if (wParam == XTP_DPN_SHOWWINDOW)
    {
        // get a pointer to the docking pane being shown.
        CXTPDockingPane* pwndDockWindow= (CXTPDockingPane*)lParam;
        if (!pwndTabDockBar->IsValid())
        {
            switch (pwndTabDockBar->GetID())
            {
            case IDC_DOCKWINDOW:
                pwndTabDockBar->Attach(&m_wndTreeCtrl);
                break;
            }
        }

        return TRUE; // handled
    }

    return FALSE;
}
See Also: How to add a docking pane to your application.
Tabbed Dock Window Creation
You use the same approach to create a tabbed dock window that you would to create a single dock window. For each tab you want to display, you would need to create a new pane. Once you have all of the panes created, you then group them by calling AttachPane and passing in the pane you want to attach as the first argument, and the pane that is acting as the tab control bar for the second argument. You will also need to call SetIcons to define the icons for each tab.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Create Status bar.
    // Important: All control bars including the Status Bar
    // must be created before CommandBars....
    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }

    // Initialize the command bars
    if (!InitCommandBars())
        return -1;

    // Get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }

    // Add the menu bar
    CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
        _T("Menu Bar"), IDR_MDISAMTYPE);
    if(pMenuBar == NULL)
    {
        TRACE0("Failed to create menu bar.\n");
        return -1;      // fail to create
    }

    // Create ToolBar
    CXTPToolBar* pToolBar = (CXTPToolBar*)
        pCommandBars->Add(_T("Standard"), xtpBarTop);
    if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;
    }

    // Initialize the docking pane manager and set the
    // initial them for the docking panes.  Do this only after all
    // control bars objects have been created and docked.
    GetDockingPaneManager()->InstallDockingPanes(this);
    GetDockingPaneManager()->SetTheme(xtpPaneThemeOffice);

    // Create the workspace bar.
    CXTPDockingPane* pwndDockWindow= GetDockingPaneManager()->CreatePane(
        IDC_DOCKWINDOW, CRect(0, 0,200, 120), dockLeftOf);
    CXTPDockingPane* pwndPane2  = GetDockingPaneManager()->CreatePane(
        IDC_PANE2, CRect(0, 0,200, 120), dockLeftOf);
    CXTPDockingPane* pwndPane3  = GetDockingPaneManager()->CreatePane(
        IDC_PANE3, CRect(0, 0,200, 120), dockLeftOf);

    // Initialize the default layout for "EditorLayout".
    GetDockingPaneManager()->AttachPane(
        pwndPane2, pwndDockWindow);
    GetDockingPaneManager()->AttachPane(
        pwndPane3, pwndDockWindow);

    // select the first tab.
    GetDockingPaneManager()->ShowPane(IDC_DOCKWINDOW);

    // Set the icons for the docking pane tabs.
    int nIDs[] = {IDC_DOCKWINDOW, 0, 0};
    GetDockingPaneManager()->SetIcons(IDB_IMGLIST_TAB, nIDs,
        _countof(nIDs), RGB(0,255,0));

    // create the tree control for the dock pane.
    if (!m_wndTreeCtrl.Create( WS_VISIBLE | TVS_HASLINES |
        TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS,
        CRect(0,0,0,0), this, IDC_TREE_CTRL ))
    {
        TRACE0("Failed to create tree control.\n");
        return -1;      // fail to create
    }

    return 0;
}
See Also: How to add a docking pane to your application.
Set the child window for the dock panes
Set the child window for each pane as described in the previous page. You can also attach views by calling AttachView as shown here:
LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
{
    if (wParam == XTP_DPN_SHOWWINDOW)
    {
        // get a pointer to the docking pane being shown.
        CXTPDockingPane* pwndDockWindow= (CXTPDockingPane*)lParam;
        if (!pwndTabDockBar->IsValid())
        {
            switch (pwndDockWindow ->GetID())
            {
            case IDC_DOCKWINDOW:
                {
                    pwndDockWindow->Attach(&m_wndTreeCtrl);
                    break;
                }
            case IDC_PANE2:
                {
                    CPane2View* pView = (CPane2View*)pwndDockWindow->AttachView(this,
                        RUNTIME_CLASS(CPane2View));
                    pView->SendMessage(WM_INITIALUPDATE);
                    break;
                }
            case IDC_PANE3:
                {
                    CPane3View* pView = (CPane3View*)pwndDockWindow->AttachView(this,
                        RUNTIME_CLASS(CPane3View));
                    pView->SendMessage(WM_INITIALUPDATE);
                    break;
                }
            }
        }

        return TRUE; // handled
    }

    return FALSE;
}
See Also: How to add a docking pane to your application.
Add customization for toolbars and menus.
  1. Add an ON_COMMAND for XTP_ID_CUSTOMIZE to the message map for CMainFrame. This will handle setup and display for the toolbar and menu customization dialog.
    In MainFrm.cpp add the following code:
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ON_WM_CREATE()
    //}}AFX_MSG_MAP
    ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
END_MESSAGE_MAP()
    in MainFrm.h add the following code:
        //{{AFX_MSG(CMainFrame)
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    //}}AFX_MSG
    afx_msg void OnCustomize();
    DECLARE_MESSAGE_MAP()
  2. Add the body for the OnCustomize function:
    void CMainFrame::OnCustomize()
{
    // Get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars != NULL)
    {
        // Instanciate the customize dialog object.
        CXTPCustomizeSheet dlg(pCommandBars);

        // Add the options page to the customize dialog.
        CXTPCustomizeOptionsPage pageOptions(&dlg);
        dlg.AddPage(&pageOptions);

        // Add the commands page to the customize dialog.
        CXTPCustomizeCommandsPage* pCommands = dlg.GetCommandsPage();
        pCommands->AddCategories(IDR_MDISAMTYPE);

        // Use the command bar manager to initialize the
        // customize dialog.
        pCommands->InsertAllCommandsCategory();
        pCommands->InsertBuiltInMenus(IDR_MDISAMTYPE);
        pCommands->InsertNewMenuCategory();

        // Dispaly the dialog.
        dlg.DoModal();
    }
}
  3. Add LoadCommandBars(_T("CommandBars")); to the OnCreate function for CMainFrame. This will restore the previous state of your toolbar and menus plus any customization made.
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    // Load the previous state for toolbars and menus.
    LoadCommandBars(_T("CommandBars"));

    return 0;
}
  4. Add the OnClose message handler to CMainFrame and add SaveCommandBars(_T("CommandBars")); before the call to the base class. This will save the current state of your toolbar and menus in plus any customization made.
    void CMainFrame::OnClose()
{
    // Save the current state for toolbars and menus.
    SaveCommandBars(_T("CommandBars"));
    CMDIFrameWnd::OnClose();
}
    MDI Sample Application Add or Remove Buttons Menu...
    MDI Sample Application Customize Dialog...
Add intelligent menus
  1. Add array of Ids that seem not very important for user.
    static UINT uHideCmds[] =
{
    ID_FILE_PRINT, ID_FILE_PRINT_PREVIEW, ID_WINDOW_CASCADE
};
  2. Add to the CMainFrame::OnCreate Intelligent menu initialization:
    // Hide array of commands
pCommandBars->HideCommands(uHideCmds, _countof(uHideCmds));

// Set "Always Show Full Menus" option to the FALSE
XTP_COMMANDBARS_OPTIONS* pOptions = pCommandBars->GetCommandBarsOptions();
pOptions->bAlwaysShowFullMenus = FALSE;
  3. Add LoadCommandBars(_T("CommandBars")); to the CMainFrame::OnCreate method. This will restore the previous state of your toolbar and menus plus any customization made:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    // Load the previous state for toolbars and menus.
    LoadCommandBars(_T("CommandBars"));

    return 0;
}
  4. Add the OnClose message handler to CMainFrame and add SaveCommandBars(_T("CommandBars")); before the call to the base class. This will save the user’s used commands:
    void CMainFrame::OnClose()
{
    // Save the current state for toolbars and menus.
    SaveCommandBars(_T("CommandBars"));
    CMDIFrameWnd::OnClose();
}
    MDI Sample Application with Intelligent Menus...
Create a custom theme for your application
  1. Create a new class derived from one of the predefiend themes found in the toolkit. We are going to use CXTPDefaultTheme; however you can use any of the following theme classes:
    CXTPDefaultTheme to inherit Office 2000 theme
    CXTPOfficeTheme to inherit Office XP theme
    CXTPOffice2003Theme to inherit Office 2003 theme
    CXTPNativeXPTheme to inherit Native XP theme
    class CDoubleGripperTheme : public CXTPDefaultTheme
{
    ...
};
  2. Override the DrawCommandBarGripper of CXTPDefaultTheme base class (See XTPPaintManager.h). This will allow us to add our own custom look for drawing the command bar grippers:
    class CDoubleGripperTheme : public CXTPDefaultTheme
{
    virtual CSize DrawCommandBarGripper(
        CDC* pDC, CXTPCommandBar* pBar, BOOL bDraw);
};

// DrawCommandBarGripper function.
// if bDraw if FALSE must return gripper size.
// if bDraw is TRUE must draw gripper.
CSize CDoubleGripperTheme::DrawCommandBarGripper(CDC* pDC,
    CXTPCommandBar* pBar, BOOL bDraw)
{
    // If Toolbar is vertical docked
    if (pBar->GetPosition() == xtpBarRight ||
        pBar->GetPosition() == xtpBarLeft)
    {
        if (bDraw)
        {
            CXTPClientRect rc(pBar);
            Draw3dRect(pDC, CRect(3, 3, rc.right - 3, 6),
                COLOR_BTNHILIGHT, COLOR_3DSHADOW);
            Draw3dRect(pDC, CRect(3, 7, rc.right - 3, 10),
                COLOR_BTNHILIGHT, COLOR_3DSHADOW);
        }
        return CSize(0, 10);
    }
    // if Toolbar is horizontal  docked
    else
    if (pBar->GetPosition() == xtpBarTop ||
        pBar->GetPosition() == xtpBarBottom)
    {
        CXTPClientRect rc(pBar);
        if (bDraw)
        {
            Draw3dRect(pDC, CRect(3, 3, 6, rc.bottom - 3),
                COLOR_BTNHILIGHT, COLOR_3DSHADOW);
            Draw3dRect(pDC, CRect(7, 3, 10, rc.bottom - 3),
                COLOR_BTNHILIGHT, COLOR_3DSHADOW);
        }
        return CSize(10, 0);
    }
    else return CXTPDefaultTheme::DrawCommandBarGripper(pDC, pBar, bDraw);
}
  3. Call CXTPPaintManager::SetCustomTheme from CMainFrame::OnCreate() method to use the theme we just created:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    // Use our own theme for drawing command bar grippers.
    CXTPPaintManager::SetCustomTheme(new CDoubleGripperTheme());

    return 0;
}
    MDI Sample Application Showing Custom Theme...


FAQ Overview

Introduction, Migrating from Xtreme Toolkit Standard Edition, How to Insert the ‘Window List’ command
See Also Chapter 6: FAQ for Xtreme Toolkit Pro v12.0
Up | Previous | Next
FAQ Overview

There are some questions that we are frequently asked about Xtreme Toolkit Pro. These questions include:

  • How do I insert the ‘Window List’ command into the ‘Window’ popup menu?
  • How do I insert the ‘Customize’ command into the ‘Toolbars’ popup menu?
  • How do I add a splitter popup button that doesn't disappear?
  • How do I handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages?
  • How do I statically link with Xtreme Toolkit Pro and when statically linked to MFC?
    • Copyright (c) 1998-2008 Codejock Software. All rights reserved.


How to Insert the Window List command

FAQ Overview, How to Insert the Window List command, How to Insert the ‘Customize’ Command, How to Add a Splitter Popup Button that Doesn't Disappear, How to Handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages, How to Statically Link with Xtreme Toolkit Pro when Statically Linked to MFC
See Also Chapter 6: FAQ for Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Insert the Window List command

Question:

I created an MDI application, but the Window List was not in the list of child window items in the Windows popup menu. How do I add this command?
Answer:
To add the Windows List command to the Window popup menu for your MDI application, add a new menu command to your menu resource titled Window List. Set its command ID equal to 35000, or you can use the following command ID which is already defined in toolkit:
#define XTP_ID_WINDOWLIST               35000
Visual Studio Resource Editor...
If you plan on using XTP_ID_WINDOWLIST instead of 35000, you will need to add the Xtreme Toolkit Pro resources to your project. To do so, select the resource tab in Visual Studio, right click on the resource tree and select Resource Includes as shown here:
Visual Studio Workspace Window...
Once you have the Resource Includes dialog open, you will need to add #include "XTPResource.h" to the list of read only symbol directives and close the dialog by pressing the ‘OK’ button:
Resource Includes Dialog...


How to Insert the Customize Command

FAQ Overview, How to Insert the ‘Window List’ command, How to Insert the Customize Command, How to Add a Splitter Popup Button that Doesn't Disappear, How to Handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages, How to Statically Link with Xtreme Toolkit Pro when Statically Linked to MFC
See Also Chapter 6: FAQ for Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Insert the Customize Command

Question:

I want to add a Customize item to the Toolbars popup; how do I add this command?
Answer:
To add the Customize command to the Toolbars popup menu for your application, add a new menu command to your menu resource titled Customize. Set its command ID equal to 35001, or you can use the following command ID which is already defined in toolkit:
#define XTP_ID_CUSTOMIZE                35001
Visual Studio Resource Editor...
If you plan on using XTP_ID_CUSTOMIZE instead of 35001, you will need to add the Xtreme Toolkit Pro resources to your project. To do so, select the resource tab in Visual Studio and right click on the resource tree and select Resource Includes as shown here:
Visual Studio Workspace Window...
Once you have the Resource Includes dialog open, you will need to add #include "XTPResource.h" to the list of read only symbol directives and close the dialog by pressing the ‘OK’ button:
Resource Includes Dialog...


How to Add a Persistent Splitter Popup Button

FAQ Overview, How to Insert the ‘Window List’ command, How to Add a Persistent Splitter Popup Button, How to Add a Persistent Splitter Popup Button, How to Handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages, How to Statically Link with Xtreme Toolkit Pro when Statically Linked to MFC
See Also Chapter 6: FAQ for Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Add a Persistent Splitter Popup Button

Question:

I have created a splitter popup button as shown below, but after I clicked the ‘Reset Toolbar’ button, it disappeared. How do I fix this?
pStandardBar->GetControls()->Add(xtpControlSplitButtonPopup, ID_BUTTON_POPUP);
Answer:
If you use Customizable toolbars you must avoid dynamic creation of controls. You must use the ‘Xtreme Control Subclassing’ technique. To add a splitter button do the following:
  1. Add the button to your toolbar resource using the Visual Studio resource editor like so:
    2. Visual Studio Resource Editor...
  2. Using the resource editor, create a Popup menu with same command id as the toolbar button you just added.
  3. Add the command handler ON_XTP_CREATECONTROL() to your CMainFrame message map, for example:
    4. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ...
    //}}AFX_MSG_MAP
    ON_XTP_CREATECONTROL()
END_MESSAGE_MAP()

int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{
    if (lpCreateControl->bToolBar)
    {
        if (lpCreateControl->nID == ID_BUTTON_POPUP)
        {
            lpCreateControl->controlType = xtpControlSplitButtonPopup;
            return TRUE;
        }
    }
    return FALSE;
}
  4. Add the following line to your header file for CMainFrame:
    5. afx_msg int OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl);
    Application screen shot showing splitter popup button...


How to Handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages

FAQ Overview, How to Insert the ‘Window List’ command, How to Insert the ‘Customize’ Command, How to Add a Splitter Popup Button that Doesn't Disappear, How to Handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages, How to Statically Link with Xtreme Toolkit Pro when Statically Linked to MFC
See Also Chapter 6: FAQ for Xtreme Toolkit Pro v12.0
Up | Previous | Next
How to Handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages

Question:

How do I handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages?
Answer:
(part I) using ON_UPDATE_COMMAND_UI:
Xtreme Command Bars supports the classic MFC updating mechanism using the ON_UPDATE_COMMAND_UI macro. For example, to make a menu or toolbar command item checked you would add the following code:
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ...
    //}}AFX_MSG_MAP
    ON_UPDATE_COMMAND_UI(ID_EDIT_STATE,OnUpdateEditState)
END_MESSAGE_MAP()

void CMainFrame::OnUpdateEditState(CCmdUI* pCmdUI)
{
    pCmdUI->SetCheck(m_bCheck);
    pCmdUI->Enable(TRUE);
}
If you wanted to cause a control to be updated from CCmdUI, you can use the following code:
void CMainFrame::OnUpdateEditState(CCmdUI* pCmdUI)
{
    CXTPCommandBar* pToolBar = (CXTPToolBar*)pCmdUI->m_pOther;
    if (pToolBar)
    {
        CXTPContro* pControl = pToolBar->GetControls()->GetAt(pCmdUI->m_nIndex);
        pControl->SetIconId(ID_FILE_NEW);
    }
}
You can also manually update the control using the xtpFlagManualUpdate flag, for example:
pButton->SetFlags(xtpFlagManualUpdate);
pButton->SetChecked(TRUE);
(part II) using ON_COMMAND:
Xtreme Command Bars support the classic MFC executing mechanism using ON_COMMAND macro, for example to handle the ID_THEME_DEFAULT command handler, you would add the following code:
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ...
    //}}AFX_MSG_MAP
    ON_COMMAND(ID_THEME_DEFAULT, OnSwitchDefault)
END_MESSAGE_MAP()

void CMainFrame::OnSwitchDefault()
{
    CXTPPaintManager::SetTheme(xtpThemeOffice2000);
    GetCommandBars()->RedrawCommandBars();
}
(part III) using ON_XTP_EXECUTE:
Sometimes we need what control is to be executed and not just the command ID. In this case we use the ON_XTP_EXECUTE macro, for example:
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ...
    //}}AFX_MSG_MAP
    ON_XTP_EXECUTE(ID_EDIT_STATE, OnEditState)
END_MESSAGE_MAP()

void CMainFrame::OnEditState(NMHDR* pNMHDR, LRESULT* pResult)
{
    CXTPControl* pControl = ((NMXTPCONTROL*)pNMHDR) ->pControl;
    if (pControl->GetType() == xtpControlSplitButtonPopup)
    {
        …
        …
        *pResult = TRUE;
    }
}


How to Statically Link with Xtreme Toolkit Pro when Statically Linked to MFC

FAQ Overview, How to Insert the ‘Window List’ command, How to Insert the ‘Customize’ Command, How to Add a Splitter Popup Button that Doesn't Disappear, How to Handle ON_COMMAND and ON_UPDATE_COMMAND_UI messages, How to Statically Link with Xtreme Toolkit Pro when Statically Linked to MFC
See Also Chapter 6: FAQ for Xtreme Toolkit Pro v12.0
Up | Previous
How to Statically Link with Xtreme Toolkit Pro when Statically Linked to MFC

Question:

How do I statically link with Xtreme Toolkit Pro and when statically linked to MFC?
Answer:
Follow these steps to statically link with the Xtreme Toolkit Professional Version:
  1. Change your project settings to “Use MFC in a Static Library”. This is found on the “General” tab in your project settings dialog.
  2. Change your “C/C++ Code Generation” to use either “Multithreaded” or “Debug Multithreaded” run-time library. For release builds use the “Multithreaded” (non DLL) run-time library. For debug builds use “Debug Multithreaded” (non DLL) run-time library.
  3. Some libraries are incompatible when statically linking to MFC. On the link tab under input settings you will need to ignore the following libraries.
    For “Multithreaded” add the following to the “Ignore libraries” list:
    libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
    For “Debug Multithreaded” add the following to the “Ignore libraries” list:
    libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib
    See Linker Tools Warning LNK4098 in MSDN for more details.
  4. Add the following line to your application's .rc2 file. This will link in the toolkit resources so they are available to your application.
    Xtreme Toolkit Pro:
    #include <XTToolkitPro.rc>
    Xtreme Suite:
    #include <XTSuitePro.rc>