翻譯|使用教程|編輯:鮑佳佳|2020-10-09 13:26:37.940|閱讀 444 次
概述:以下是有關如何為應用程序工具欄和應用程序菜單添加添加自定義設置的教程。本教程假定您已經創建了使用Office樣式的工具欄和菜單的應用程序。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
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最新試用版! 點擊獲取更多免費Xtreme Toolkit Pro教程、視頻、示例!
【同類產品推薦】
以下是有關如何為應用程序工具欄和應用程序菜單添加添加自定義設置的教程。本教程假定您已經創建了使用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并在下方評論區分享您對該產品的想法。您的反饋意見可幫助我們在以后的更新中找到正確的方向,慧都作為Codejock的正版代理商現Xtreme ToolKit Pro正版授權最高立減2000元! Xtreme Command Bars在線訂購最低僅需1105元!
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自: