zoukankan      html  css  js  c++  java
  • MFC Ribbon

    1.代码

    void CMainFrame::InitTabButtons()
    {
        // Add "Style" button to the right of tabs:
        CMFCRibbonButton* pStyleButton = new CMFCRibbonButton((UINT) -1, _T("Style
    s"));
        pStyleButton->SetMenu(IDR_THEME_MENU, TRUE /* Right align */);
    
        m_wndRibbonBar.AddToTabs(pStyleButton);
    
        pStyleButton = new CMFCRibbonButton((UINT)-1, _T("SXXX
    s"));
        m_wndRibbonBar.AddToTabs(pStyleButton);
    
        // Add "About" button to the right of tabs:
        m_wndRibbonBar.AddToTabs(new CMFCRibbonButton(ID_APP_ABOUT, _T("
    a"), m_PanelImages.ExtractIcon(6)));
    
    }

    2.代码

    void CMainFrame::AddContextTab_Format()
    {
        CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddContextCategory(_T("Format"), _T("Drawing tools"), ID_FORMAT_CONTEXT_TAB, /*AFX_CategoryColor_Orange*/AFX_CategoryColor_Green, 0,0);//IDB_RIBBON_FORMATSMALL, IDB_RIBBON_FORMATLARGE);
        pCategory->SetKeys(_T("jd"));
    
        // Create "Styles" panel
        CMFCRibbonPanel* pPanelStyles = pCategory->AddPanel(_T("Styles
    zs"), m_PanelImages.ExtractIcon(8));
    
        CMFCRibbonGallery* pBtnStyles = new CMFCRibbonGallery(ID_OBJECT_STYLES, _T("Styles
    k"), 0, 0, IDB_STYLES, 40);
        pBtnStyles->SetIconsInRow(7);
        pBtnStyles->EnableMenuResize(TRUE, TRUE);
        pPanelStyles->Add(pBtnStyles);
    
        std::auto_ptr<CMFCRibbonColorButton> apBtnFillColor(new CMFCRibbonColorButton(ID_OBJECT_FILLCOLOR, _T("Fill Color
    sf"), FALSE, 1, -1));
        apBtnFillColor->SetDefaultCommand(FALSE);
        apBtnFillColor->EnableAutomaticButton(_T("&Automatic"), RGB(128, 128, 128));
        apBtnFillColor->EnableOtherButton(_T("&More Fill Colors..."), _T("More Fill Colors"));
        apBtnFillColor->SetColumns(10);
        apBtnFillColor->SetColorBoxSize(CSize(17, 17));
        apBtnFillColor->AddColorsGroup(_T("Theme Colors"), m_lstMainColors);
        apBtnFillColor->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE);
        apBtnFillColor->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors);
        apBtnFillColor->AddSubItem(new CMFCRibbonButton(ID_OBJECT_NOFILL, _T("&No Fill
    n"), 2));
        apBtnFillColor->SetColor((COLORREF)-1);
        pPanelStyles->Add(apBtnFillColor.release());
    
        std::auto_ptr<CMFCRibbonColorButton> apBtnLineColor(new CMFCRibbonColorButton(ID_OBJECT_LINECOLOR, _T("Line Color
    so"), FALSE, 3, -1));
        apBtnLineColor->SetDefaultCommand(FALSE);
        apBtnLineColor->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0));
        apBtnLineColor->EnableOtherButton(_T("&More Line Colors..."), _T("More Line Colors"));
        apBtnLineColor->SetColumns(10);
        apBtnLineColor->SetColorBoxSize(CSize(17, 17));
        apBtnLineColor->AddColorsGroup(_T("Theme Colors"), m_lstMainColors);
        apBtnLineColor->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE);
        apBtnLineColor->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors);
        apBtnLineColor->AddSubItem(new CMFCRibbonButton(ID_OBJECT_NOLINE, _T("&No Line
    n"), 2));
        apBtnLineColor->SetColor((COLORREF)-1);
        pPanelStyles->Add(apBtnLineColor.release());
    
        CStringArray sa;
        sa.Add(_T("1 pt"));
        sa.Add(_T("2 pt"));
        sa.Add(_T("3 pt"));
        sa.Add(_T("4 pt"));
        sa.Add(_T("5 pt"));
        sa.Add(_T("6 pt"));
        sa.Add(_T("7 pt"));
    
        std::auto_ptr<CRibbonListButton> apBtnLineWeight(new CRibbonListButton(ID_OBJECT_LINEWEIGHT, _T("Line Weight
    sw"), 4, -1, IDB_LINEWEIGHT, 96, sa));
        apBtnLineWeight->AddSubItem(new CMFCRibbonButton(ID_OBJECT_LINEWEIGHT_MORE, _T("More &Lines..."), 5, -1));
        apBtnLineWeight->EnableMenuResize(TRUE, TRUE); // Vertical only
        pPanelStyles->Add(apBtnLineWeight.release());
    
    #ifdef ENABLE_RIBBON_LAUNCH_BUTTON
        pPanelStyles->EnableLaunchButton(ID_OBJECT_PROPERTIES, 6, _T("fa"));
    #endif // ENABLE_RIBBON_LAUNCH_BUTTON
    
        // Create "Arrange" panel
        CMFCRibbonPanel* pPanelArrange = pCategory->AddPanel(_T("Arrange
    zj"), m_PanelImages.ExtractIcon(3));
    
        pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVETOFRONT, _T("Move to Front
    mf"), 7, 1));
        pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVEFORWARD, _T("Move Forward
    mw"), 9, 3));
        pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVEBACK, _T("Move Backward
    md"), 10, 4));
        pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVETOBACK, _T("Move to Back
    mb"), 8, 2));
    }

  • 相关阅读:
    asp.net 连接 Access 的几种方法
    asp.net 连接 oracle10g 数据库
    Entity Framework实例
    LINQ链接数据库出错(There is already an open DataReader associated with this Command which must be closed first )
    Linq入门实例
    Nibatis实例(2)
    Log4net实例
    图片提交表单方法
    Nibatis实例(1)
    爱情是不离不弃吗?
  • 原文地址:https://www.cnblogs.com/sinceret/p/13162718.html
Copyright © 2011-2022 走看看