Exemple #1
1
LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM)
{
	UINT uiToolBarId = (UINT) wp;
	if (uiToolBarId == IDR_MAINFRAME)
	{
		// Replace "Back" and "Forward" buttons by the menu buttons
		// with the history lists:

		CMenu menuBackward;
		menuBackward.LoadMenu (IDR_BACKWARD_MENU);

		m_wndToolBar.ReplaceButton (ID_GO_BACK, 
			CMFCToolBarMenuButton (ID_GO_BACK, menuBackward, 
						GetCmdMgr ()->GetCmdImage (ID_GO_BACK), NULL));

		CMenu menuForward;
		menuForward.LoadMenu (IDR_FORWARD_MENU);

		m_wndToolBar.ReplaceButton (ID_GO_FORWARD,
			CMFCToolBarMenuButton (ID_GO_FORWARD, menuForward, 
						GetCmdMgr ()->GetCmdImage (ID_GO_FORWARD), NULL));
	}

	return 0;
}
void CMyMenuBar::AddSubMenu () {
  CMenu menu;
  menu.LoadMenu (IDR_DYNAMIC_MENU);

  InsertButton (CMFCToolBarMenuButton (0, menu, -1, _T ("&DynamicMenu")));

  AdjustLayout();
  AdjustSizeImmediate ();
}
afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM)
{
	UINT uiToolBarId = (UINT) wp;
	if (uiToolBarId != IDR_MAINFRAME)
	{
		return 0;
	}

	// Replace "Back" and "Forward" buttons by the menu buttons
	// with the history lists:

	CMenu menuHistory;
	menuHistory.LoadMenu (IDR_HISTORY_POPUP);

	CMFCToolBarMenuButton btnBack (ID_GO_BACK, menuHistory, 
					GetCmdMgr ()->GetCmdImage (ID_GO_BACK), _T("Back"));
	btnBack.m_bText = TRUE;
	m_wndToolBar.ReplaceButton (ID_GO_BACK, btnBack);

	m_wndToolBar.ReplaceButton (ID_GO_FORWARD,
		CMFCToolBarMenuButton (ID_GO_FORWARD, menuHistory, 
					GetCmdMgr ()->GetCmdImage (ID_GO_FORWARD), _T("Forward")));

	// "Folders" button has a text label:
	m_wndToolBar.SetToolBarBtnText (m_wndToolBar.CommandToIndex (ID_VIEW_FOLDERS),
		_T("Folders"));

	// Replace "Views" button by the menu button:
	CMenu menuViews;
	menuViews.LoadMenu (IDR_VIEWS_POPUP);

	m_wndToolBar.ReplaceButton (ID_VIEW_VIEWS,
		CMFCToolBarMenuButton ((UINT)-1, menuViews, 
					GetCmdMgr ()->GetCmdImage (ID_VIEW_VIEWS), _T("Views")));

	return 0;
}
Exemple #4
0
void CWordsBaseFrame::AddDict(UINT nID, CUIDict* pUIDict)
{
    int count = m_wndToolBarDicts.GetCount();
    if(count > 0) --count;
    if(auto pUIDictItem = dynamic_cast<CUIDictItem*>(pUIDict))
        m_wndToolBarDicts.InsertButton(CMFCToolBarButton(nID, CMFCToolBar::GetDefaultImage(ID_TB_DICTS_OFFLINEALL + pUIDict->m_ImageIndex)));
    else{
        auto pUIDictCol = dynamic_cast<CUIDictCollection*>(pUIDict);
        if(pUIDictCol->IsPile())
            m_wndToolBarDicts.InsertButton(CMFCToolBarButton(nID, CMFCToolBar::GetDefaultImage(ID_TB_DICTS_OFFLINEALL + pUIDict->m_ImageIndex)));
        else{
            auto pUIDictItem = pUIDictCol->m_vpUIDictItems[0].get();
            CMenu menu;
            menu.LoadMenu(IDR_POPUP_NAVIGATE);
            m_wndToolBarDicts.InsertButton(CMFCToolBarMenuButton(nID, menu.Detach(), CMFCToolBar::GetDefaultImage(ID_TB_DICTS_OFFLINEALL + pUIDictItem->m_ImageIndex)));
        }
    }
	m_wndToolBarDicts.SetToolBarBtnText(count, pUIDict->m_strName);
	m_wndToolBarDicts.EnableCustomizeButton(TRUE, nID, _T(""));
	m_wndToolBarDicts.AdjustSizeImmediate();
}
	pDlgCust->ReplaceButton (ID_FAVORITS_DUMMY,
		CMFCToolBarMenuButton ((UINT)-1, menuFavorites, -1, strFavorites));
	pDlgCust->EnableUserDefinedToolbars();
	pDlgCust->Create ();