MFC customise - add new toolbar? - c++

In an MFC app, when customising toolbars at runtime, is there an option for users to create their own new toolbars?
I have recently moved my app to the new MFC controls in VS2010. I was previously using the BCG version of this functionality, which pre-dates VS2008. (Microsoft bought the BCG stuff and wrapped it in to VS, as of VS2008). Anyway, I noticed that the Microsoft MFC version does not seem to allow the functionality for users to add their own toolbars under the toolbar customisation. Users can customise the icons on the toolbars, but the button to add their own new toolbars doesn't seem to be there.
Is there some way to enable this option in my code, so that users can create their own new toolbars?

It is also in the new MFC classes
When I create a new MFC program with the wizard in VS-2010 you can choose this feature on the page "User Interface Features". Select "Use a menu bar and toolbar. There are two further settings "User-defined toolbars and images" and "Personal menu behavior". You have to select the first.
Look into the created code...
HTH
PS: Also the new BCG classes are completely compatible with MFC 2010 and later.

Related

ribbon control in mfc dialog based application

I am using visual studio 2010 professional edition. I am working on MFC dialog based application.
I have created the ribbon resource and try to load the same using the following:-
m_wndRibbonBar.Create(this);
m_wndRibbonBar.LoadFromResource(IDR_RIBBON);
Where CMFCRibbonBar m_wndRibbonBar is declared in the header file as well.
But I can't create the same in dialog based application, it will work in SDI or MDI application.
I would like to create the ribbon control in a dialog based application.
Is there any possibility to do so, if not, what are the alternatives for the same?
As answered elsewhere on the internet, for example:
ribbon control in mfc dialog based application
To quote:
According to the MSDN documentation:
Ribbons cannot be created in dialog-based applications. For more information, see see Application Type, MFC Application Wizard.
Possible workarounds:
To use a Ribbon, use an SDI application with a View derived from CFormView.
Use a toolbar instead.

Why can't I add Class for a dialog in VS2019?

I want to write a simple minesweeper as some practice. I created a dialog and I want to create a class to relate variables to the input for edit box. However when I right clicked the dialog, I cannot select "create a class".
Here is the screenshot. There wasn't any error so I don't know what to provide. If you need any extra information please let me know.
You can't add a class for a dialog of a Windows Desktop application. A Windows Desktop application uses only basic Win32 API which does not provide a class framework.
You have to choose the MFC application wizard, when creating a new project. From this wizard select "dialog based" to create the most basic application. It will automatically add a dialog with a corresponding class.
You only need to "Add Class" when adding more dialogs to the application.

How can I implement a MFC resource within a Win32 window?

I have two projects, an old project using the Win32 API that has an old toolbar using Win32 graphics and another one using MFC code with better graphics (I am creating a ribbon toolbar similar to the one that Microsoft Office uses). The MFC classes I use inherit from CDialogEx and CWinApp.
What I am trying to do is to place the ribbon toolbar in my Win32 window and replace the old one. I am already referencing the MFC project using it as a static library and can call the classes from my Win32 project but I can't get to show the new toolbar yet.
What do I need to do in order to achieve this?
It might be much easier to create the freamework with the MFC and move the old code into the new framework.
It is possible to create a MFC project without Doc/View architecture.
The MFC Ribbons will and can only live inside a CMFCFrameWnd that is part of a CWinAppEx... extracting just the ribbon code into a plain Win32 application should fail.
But there is also a Win32 Ribbon Framework. It might be much easier to implement this into your old Win32 project.
How to implement this is described here.
In Codeproject you find a sample how to use it.

Quick Access Toolbar (QAT) doesn't shown in Ribbon MFC

I'm converting an existing application to use ribbon. I'm using visual studio 2012. I tried to add buttons through QAT properties editor in the ribbon designer. The QAT shown in the Test Ribbon mode correctly. But It's not shown when I debugging the application. The dropdown box button is there but not functional.
I've also tried to add buttons in code, but it makes no difference:
MFCRibbonQuickAccessToolBarDefaultState qatState;
qatState.AddCommand(ID_FILE_SAVE);
qatState.AddCommand(ID_EDIT_UNDO);
m_wndRibbonBar.SetQuickAccessDefaultState(qatState);
Any idea would be appreciated. The part of QAT in ribbon1.mfcribbon-ms is:
<QAT_ELEMENTS><ELEMENT_NAME>QAT</ELEMENT_NAME><QAT_TOP>TRUE</QAT_TOP><ITEMS><ITEM><ID><NAME>ID_FILE_NEW</NAME><VALUE>57600</VALUE></ID><VISIBLE>TRUE</VISIBLE></ITEM><ITEM><ID><NAME>ID_FILE_OPEN</NAME><VALUE>57601</VALUE></ID><VISIBLE>TRUE</VISIBLE></ITEM></ITEMS></QAT_ELEMENTS>
I solved it. In the CAppnameApp::InitInstance() function in the Appname.cpp, call InitContextMenuManager() function. This initialize the CContextMenuManager object which manage shortcut menus. This object is introduced in VC2008. Also other functions like InitShellManager(); InitKeyboardManager(); InitTooltipManager();need to be called at the same place.

MFC SHELLLIST does not paint

If I create a new MFC GUI using VS2010, create a dialog box, add an MFC SHELLLIST control to the dialog box, DoModal on the dialog box, the MFC SHELLLIST is filled with the various high level objects that can then be navigated through.
But I have an old MFC GUI that was initially created with VS2005, imported to VS2010, and when I do exactly the same as above, the MFC SHELLLIST is empty.
There are numerous MainFrm.cpp actions that are boilerplate for VS2010 that were not for VS2005. Probably one or more of them is responsible for activating MFC SHELLLIST.
Anybody know which one(s)?
I just created a new MFC dialog application in VS2012, and added a shell list control (works fine). The biolerplate code, which is a lot less for a dialog than for an SDI/MDI application, contains the following codie in CMyWinApp::Initinstance
// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;
// Activate "Windows Native" visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
The CShellManager is deleted when the application closes
// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}
So, I think that at least you need to create the CShellManager and may need the visual manager for theming.
The problem was that the MFC GUI was originally developed under VS2005 then imported into VS2010. The MFC SHELLLIST would not work until I created an entirely new project with VS2010 then methodically imported the sources from the original project. Had to WinMerge sources like MainFrm.cpp and MainFrm.h in order to avoid annoying MFC SHELLLIST functionality.