MFC: Copy/Paste from toolbar when using EditLabel in a CListView/CListCtrl - mfc

I have a CFormView with a CListView, when using CListView::EditLabel() you can right click and paste, or highlight and copy. However the toolbar has copy/paste disabled. What is the appropriate way to handle that and have the copy/paste work via the toolbar ?
I know I can use ON_UPDATE_COMMAND_UI to get the enabled, but when enabled they don't copy/paste when editing a label on the CListView.
Thanks.

Related

How can I put a menu inside a CDockablePane?

I would like to put a menu inside a CDockablePane so that the pane can have a standard menu as well as a toolbar. The menu itself does not have to be dockable (neither does the toolbar).
As my first attempt, I started with a standard SDI from the VS project wizard, with a dockable Properties pane from which I cut out all the content except the toolbar (I'll be adding a form view eventually). I then tried putting a standard CMFCMenuBar into the pane in much this same way as is done for the main menu in the main frame, but with the dockable pane as the parent. This eventually displays OK in the pane, but only after ignoring various ASSERTS along the way (and on exit), presumably because it is expecting a CFrameWndEx rather than CDockablePane as parent. I suspect it's getting in a tangle with the main frame dock manager.
I would greatly appreciate any advice (or better still sample code) on how to do this properly. Clearly the CMFCMenuBar route is a kludge.

How to hide a custom toolbar from IE

I have developed a toolbar with one button for IE.
My toolbar displays with a default close button in the IE window.
When I click on the close button the toolbar prompts for the disable option.
This completely disables the toolbar.
But what I need is I just want to hide the toolbar. So still it can perform some actions even though the toolbar is not visible.
How can I make the toolbar just to hide instead of disable?
have you tried any IE statements? There are a few for JS aConditional comments

MFC VSListBox change icons

Does anyone know if it is possible to change the icons on the MFC VSListBox Dialog Control?
Specifically I'm trying to change the folder icon to a '+' icon instead:
I haven't tried it myself, but CVSListBoxBase::AddButton() seems to be what you need.
CVSListBox derives from CVSListBoxBase, and when you call CVSListBoxBase::SetStandardButtons to set the buttons, it calls AddButton() for each button.
The documentation for CVSListBoxBase is unfinished, so you'll have to "play" with it, but you can read the code in afxvslistbox.cpp/.h

How to change the tooltip 'Active Files' on the CMFCtabCtrl's TabbedDocumentsMenu?

We have two ways in which we scroll through the tabs in the CMFCTabCtrl, either using the two buttons to scroll the window tabs or an interface that displays a pop-up menu of tabbed windows. This option depends on the EnableTabDocumentsMenu method in the CMFCTabCtrl. Be defualt the tooltip option on this button(menu) is "Active Files".
Same tabbed control seems to be used in Visual Studio even and I see the same tooltip there?
Is there any way we can change this tooltip text?
The tool tip is set to IDS_AFXBARRES_OPENED_DOCS ("Active Files") in afxtabctrl.cpp when you EnableTabDocumentsMenu. To change it try calling:
m_btnScrollRight.SetToolTip(_T("My Customized ToolTip"));
Your main problem is that m_btnScrollRight is protected so you're probably best off inheriting from CMFCTabCtrl and doing it in your own class (after calling EnableTabDocumentsMenu).

Is there a way to prevent the hide operation of a toolbar?

In Qt, if I right-click on a toolbar the menu will be shown that allows me to hide the toolbar. I need to disable this functionality because I don't want the toolbar to possible to hide. Is there a way to do this?
I was able to set the ContextMenuPolicy directly on the toolbar (not the main window), as long as I used either Qt::PreventContextMenu or Qt::ActionsContextMenu. Prevent eliminated the context menu and made right-click have no effect on the toolbar, while Actions made a nice context menu composed of the actions already in my toolbar. Qt::NoContextMenu didn't seem to have any effect.
toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
Use setContextMenuPolicy (Qt::NoContextMenu) for the main window of the toolbar.
There are several ways to achieve this without having to alter the contextMenu functionality. See the following 3 PySide examples:
1. Disable the toggleViewAction of the QToolBar:
UnhidableToolBar = QToolBar()
UnhidableToolBar.toggleViewAction().setEnabled(False)
2. Connect to the visibilityChanged signal:
toolbar.visibilityChanged.connect(lambda: toolbar.setVisible(True))
3. Subclass QToolBar and use the hideEvent:
class UnhideableQToolBar(QToolBar):
def hideEvent(self, event):
self.setVisibile(True)
Recommendation:
While 2 & 3 are pretty dirty, solution 1 shows the toolbar in the context menu like a QDockWidget that has the feature DockWidgetClosable set. So either use solution 1 or if you want to remove the action have a look at Steven's answer.
Override QMainWindow::createPopupMenu() e.g.
QMenu* MyApp::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
filteredMenu->removeAction( mUnhidableToolBar->toggleViewAction() );
return filteredMenu;
}
Note that the other answers that suggest disabling the context menu will only work if you want to disable hiding/showing of all toolbars and all dock widgets.
Inherit QToolbar and reimplement contextMenuEvent().
The simplest thing to do is:
self.toolbar.toggleViewAction().setVisible(False)
Unlike self.toolbar.toggleViewAction().setEnabled(False), which still shows the disabled popup if you're right-clicking the toolbar for any reason.