How do you add tooltips for CMenu Items? I couldn't find any straightforward and helpful resource. Please help. Thanks...
The easiest way is to pass multiple strings to the Menu text separated by newline characters.
This will automagically make CMenu display the second part of the text as the menu tooltip.
e.g., If a menu item text is "Click here", change it to
"Click here\nThis is the tooltip for the menu item ..."
Of course, if you like more advanced/fancy tooltips, then try
http://www.tooltips.net/downloads.html
Its easy to implement, and the output is very cool
Tooltips for Menu Item and popup menuitem - CodeProject
http://www.codeproject.com/KB/menus/menuitemtooltip.aspx
Tooltips for Menu Items and Popup Menu Items - CodeGuru
http://www.codeguru.com/cpp/controls/controls/tooltipcontrols/article.php/c5233
I can't vouch for whether this sample works, but the strategy of handling WM_MENUSELECT is sound:
http://msdn.microsoft.com/en-us/magazine/cc164067.aspx
Related
How we can highlight first item of a ClistCtrl which is created in ICON format? I want to highlight first item default.
Use
CListCtrl::SetItemState(0,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
You find all Infos about such things in the MSDN.
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.
I have filled my NSPopUpButton with menu and submenus.
When I select a menuItem on the root menu (so, not a sub-menuItem), it propery displays the menuItem selected. And when I re-click on the popUp button, I get the selected menuItem under the mouse.
But if I select a sub-menuItem, it doesn't display it. And if I re-click on the popUp button, I don't get it under the mouse. Any time I click on the button, I have to look for the selected item diving in the menu hierarchy.
Any solution?
The Human Interface Guidelines state:
Avoid adding a submenu to an item in a pop-up menu. A submenu tends to
hide choices too deeply and can be physically difficult for users to
use.
I assume that since the practice is discouraged (albeit not that strongly) that it is not supported either. I can see how submenus would break some of NSPopUpButton's functionality, all of the item index related methods would not make sense. Those methods would have to use NSIndexPaths instead of simple indexes.
A potential substitute would be to use different indention levels in the menu to indicate hierarchy. I am about to try that myself.
I noticed some applications have a blue circular instead of a checkmark which MF_CHECKED produces. Which style produces this circular one?
Thanks
You normally use the CheckMenuRadioItem function to handle menu radio buttons since it does all the style and checkmark handling for you
Check out the MFT_RADIOCHECK menu type flag...
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.