Xtreme Toolkit Pro是MFC开发中最全面界面控件套包,它提供了Windows开发所需要的11种主流的Visual C++ MFC控件,包括Command Bars、Controls、Chart Pro、Calendar、Docking Pane、Property Grid、Report Control、Shortcut Bar、Syntax Edit、Skin Framework 和Task Panel。如果对产品感兴趣的话欢迎下载Xtreme Toolkit Pro最新试用版!
【同类开发工具】
- BCGControlBar Professional Edition for MFC 是一个MFC扩展库,使您可以创建具有完全自定义的选项以及一组专业设计的丰富Microsoft Office和Microsoft Visual Studio的应用程序 GUI控件,例如图表、日历、网格、编辑器、甘特图和许多其他控件。
- BCGControlBar for .NET :包含有大量高度自定义、完全可设计的.NET界面控件,用户可以使用这些来创建精致美观的图形用户界面。
以下是有关如何为应用程序工具栏和应用程序菜单添加添加自定义设置的教程。本教程假定您已经创建了使用Office样式的工具栏和菜单的应用程序。
添加工具栏和菜单的自定义
1.将XTP_ID_CUSTOMIZE的ON_COMMAND添加到CMainFrame的消息映射中。这将处理工具栏和菜单自定义对话框的设置和显示。
MainFrm.cpp:
BEGIN_MESSAGE_MAP(CMainFrame,CMDIFrameWnd)
// {{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
//}} AFX_MSG_MAP
ON_COMMAND(XTP_ID_CUSTOMIZE,OnCustomize)
END_MESSAGE_MAP()
MainFrm.h:
// {{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}} AFX_MSG
afx_msg void OnCustomize();
DECLARE_MESSAGE_MAP()
2.为OnCustomize函数添加主体:
void CMainFrame::OnCustomize()
{
// Get a pointer to the Command Bar object.
CXTPCommandBars* pCommandBars = GetCommandBars();
if(pCommandBars != NULL)
{
// Instantiate 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();
// Display the dialog.
dlg.DoModal();
}
}
3.添加LoadCommandBars(_T(“ CommandBars”)); 到CMainFrame的OnCreate函数。这将恢复工具栏和菜单的先前状态以及所做的任何自定义。
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
// Load the previous state for toolbars and menus.
LoadCommandBars(_T("CommandBars"));
return 0;
}
4.将OnClose消息处理程序添加到CMainFrame并添加SaveCommandBars(_T(“ CommandBars”)); 在调用基类之前。这将保存工具栏和菜单的当前状态以及所做的任何自定义。
void CMainFrame::OnClose()
{
// Save the current state for toolbars and menus.
SaveCommandBars(_T("CommandBars"));
CMDIFrameWnd::OnClose();
}
今天的内容就是这些了,下载最新版Xtreme ToolKit Pro并在下方评论区分享您对该产品的想法。您的反馈意见可帮助我们在以后的更新中找到正确的方向!