Adding drop down arrows to CMFCToolBar buttons - mfc

Can anyone explain how to add dropdown arrows to CMFCToolBar toolbar buttons - like for undo/redo buttons. We had this with CToolBar by using the TBSTYLE_EX_DRAWDDARROWS style and TBN_DROPDOWN notification. This doesn't seem to work with CMFCToolBar. These dropdown arrows i believe are added to the VisualStudioDemo MFC feature pack demo but i can not figure out how.

In the VisualStudioDemo sample, in CMainFrame::OnToolbarReset they replace the Undo button of the toolbar with a custom class called CUndoButton, like this:
m_wndToolBar.ReplaceButton(ID_EDIT_UNDO, CUndoButton(ID_EDIT_UNDO, _T("&Undo")));
CUndoButton is declared in file "UndoBar.h" of the sample project, so you can use it or change it however you like.

Related

Change content of a menu bar in different stack widget page in qt

Forgive me if this question is silly but I want to know
if there is a way to change the content of a menu bar in different
page on a stacked widget directly in qt designer.
For example I want the menu of the menu bar for page 1 of the stacked widget to be menu, inbox, multimedia, exit. For the second page I want the menu bar to contain the following menu; Text, outbox, contact, back. The reason is because
I want different menu controls for different pages of the
QstackeWidget. Is this possible from the qt designer ui or I'll have
to ultimately do it programatically?
As far as I know (which is QtCreator 3.3.0) the Creator only supports graphically inserting and editing a menu bar in QMainWindow. So for the first part of your question: Yes, you probably have to create the menus programmatically.
For the second part, it is possible to insert a menu bar in any given layout using QLayout::setMenuBar. This also includes the layout inside your stacked widget.
See also: Can you add a toolbar to QDialog?

Different kinds of buttons on CToolBar

Give me a tip please how to add different kinds of buttons (I need to have pushbuttons and radio buttons) on the same CToolBar.
You need to use CMFCToolbar::ReplaceButton.
You replace the regular button with either one of the default CMFCToolBarButton derived classed or with one of your own derived class.
The toolbar need to have a "placeholder" button (empty button) at the position you want to replace the button.
for example to replace a toolbar button with a combo box:
CMFCToolBarComboBoxButton myCombo(IDC_BUTTON_TO_REPLACE, GetCmdMgr()->GetCmdImage(IDC_BUTTON_TO_REPLACE, FALSE), CBS_DROPDOWNLIST, 80);
myCombo.m_strText.LoadString(IDS_MY_STRING);
myToolbar.ReplaceButton(IDC_BUTTON_TO_REPLACE, myCombo);
There are a couple of standard "buttons" available (in particular):
CMFCToolBarEditBoxButton to replace a toolbar button with an edit box.
CMFCToolBarDateTimeCtrlImpl to replace a toolbar button with a date picker
CMFCToolBarComboBoxButton to replace a toolbar button with a combo box.
(there are a couple more for menus and one for "outlook" ).
Good luck.

Remove the "Customize Quick Access Toolbar" button

I'm working on a project where we want to have a quick access bar that is unchangeable/static. We've looked at inheriting from the CMFCQuickAccessToolbar and removing that button, but those attempts seem fruitless. Just getting rid of the button completely gets rid of the toolbar. Anyone have some experience with this, or an alternative approach?
After a lot of headache we found that there was no clean solution to removing just that button from the toolbar. Instead, we opted to place the buttons we wanted to display in the quickaccess bar in the tabs group. These button will appear on the right side (beside the help icon in word). To replicate the look of the QA buttons, I had to create an imagelist and load our buttons into it.
CImageList theList;
CBitmap bm;
bm.LoadBitmap( IDB_QASMALL );
theList.Create(16,16, ILC_COLOR32 | ILC_MASK, 5, 0);
theList.Add(&bm, RGB(192,192,192));
I then created ribbonButtons to be added to the tabs group, with the proper command IDs, empty text, and the proper icon from my image list.
CMFCRibbonButton* button = new CMFCRibbonButton( ID_SOMECOMMAND, _T("\na"), theList.ExtractIcon(<IconOffset>));
m_wndRibbonBar.AddToTabs(mp);
It's not a perfect solution, but it at least gives us a similar UI without the worry of getting rid of that stupid customize button. You also have the freedom to use labels on your buttons.

MFC (Windows Mobile). How to create a radio button with custom images and labels for checked and unchecked state?

I tried to create a custom button class and use it. But it works for CBitmapButton class only.
Is it possible with subclassing of radio button?
My current temporary solution is to extend my custom button class by adding the radio button functionality.
I haven't found a solution so I have created a button which look likes a radio button

MFC Menu Drop Down (Screenshot included)

I'm having difficulties with an MFC application menu drop down. I want the drop down to display all items when it is clicked. Instead it displays arrows which the user must click in order to show the drop down items.
See the pic below. Any help would be appreciated. Thanks!
I believe this is a feature of the MFC feature pack where the menu will hide rarely used items. You should be able to disable this feature using the CMFCMenuBar::SetShowAllCommands method.