Environment Variable

当安装Codejock.ToolkitPro时,可能会在系统环境变量中添加dll的路径,如果没有自动添加,需要手动添加,这样程序在运行时,会自动链接dll,否则需要手动把dll复制到程序相同目录下,才能正常工作。
日志文件夹

Codejock.ToolkitPro.MFC.IncludePath

当Codejock.ToolkitPro.MFC安装完后,会修文件%LOCALAPPDATA%\Microsoft\MSBuild\v4.0\Microsoft.Cpp.x64.user.props,把当Codejock.ToolkitPro.MFC的相关路径写入到改文件中,从而在全局上支持visual studio创建新项目时,可以直接引用Codejock.ToolkitPro.MFC头文件和库文件。

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
    <ExecutablePath>C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v16.3.1\Bin\vc100x64;$(ExecutablePath)</ExecutablePath>
    <IncludePath>C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v16.3.1\Source;$(IncludePath)</IncludePath>
    <ReferencePath>$(ReferencePath)</ReferencePath>
    <LibraryPath>C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v16.3.1\Lib\vc100x64;$(LibraryPath)</LibraryPath>
    <SourcePath>C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v16.3.1\Source;$(SourcePath)</SourcePath>
    <ExcludePath>$(ExcludePath)</ExcludePath>
</PropertyGroup>
</Project>


<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>

日志文件夹

MFC Application

经过测试,如果要使用ToolkitPro,在创建MFC项目时,需要选MFC Standard -> Windows Native/Default -> Use a classic menu项目模板,否则会报错,暂不清楚原因。从测试看,ToolkitPro不支持MFC的新类,如CMDIFrameWndEx, CWinAppEx,只支持旧类CMDIFrameWnd, CWinApp。

日志文件夹
日志文件夹

Simplest MFC MDI Project

  1. Project template: MFC App
  2. Project style: MFC standard
  3. Classic menu options: none
  4. Advanced features: All unchecked

Add Toolbars and Menus

IDR_MDISAMTYPE需要修改为项目资源的菜单ID,同时默认情况下,MFC没有自动创建工具栏资源,所以需要手动创建工具栏资源,并把ID命名为IDR_MAINFRAME, 否则程序运行时会因为找不到菜单资源或者工具栏资源而报错。

#include <XTToolkitPro.h>

class CMainFrame : public CXTPMDIFrameWnd
{
    ...
};

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;
}

日志文件夹

Xtreme Toolkit Pro Application Wizard

创建基于Toolkit Pro的MFC程序,可以直接用Xtreme Toolkit Pro Application向导创建

日志文件夹
日志文件夹

Toolkit Pro Intellegent menus

General settings -> Intellegent menus

// Hide array of commands
pCommandBars->HideCommands(uHideCmds, _countof(uHideCmds));

// Set "Always Show Full Menus" option to the FALSE
pCommandBars->GetCommandBarsOptions()->bAlwaysShowFullMenus = FALSE;

日志文件夹

Toolkit Pro Menu Bar

General settings -> Menu Bar

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

日志文件夹

Toolkit Pro Customization

General settings -> Customization

ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)

pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);

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 keyboard page to the customize dialog.
        CXTPCustomizeKeyboardPage pageKeyboard(&dlg);
        dlg.AddPage(&pageKeyboard);
        pageKeyboard.AddCategories(IDR_SeventhTYPE);

        // 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_SeventhTYPE);

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

        // Dispaly the dialog.
        dlg.DoModal();
    }
}     ![日志文件夹](/assets/cpp/ToolkitProCustomization.png)  

Toolkit Pro Windows Explorer

日志文件夹