ribbon control in mfc dialog based application - mfc

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.

Related

How do I edit my Windows Desktop Application main dialog in VIsual Studio Commun2019?

I have to create a Win32 app for a college class.
I created the "Windows Desktop Application" in the create project section of the Visual Studio Community 2019 and it comes already with a standard dialog that can be tested on the go. Problem is: I cannot edit the main dialog. I can create another dialog and edit it but the main one is not accessible in the resource editor. What can I do? I can't find anything on google. Please help.
The main window of the default application created by the "Windows Desktop Application" project template in Visual Studio is not created with a dialog resource. It is created by registering a window class associated with a window procedure, as is standard when creating a desktop application.
You "edit" that window by changing the source code not with a visual editor.
>>I cannot edit the main dialog. I can create another dialog and edit it but the main one is not accessible in the resource editor.
Yes you can create it, but it has no class and can't be an object.You can try to create a Win32 desktop application, and then create a dialog. When you right-click the dialog box, you will find that you cannot add class.
If you want to use this dialog, you can only use this function DialogBoxW(hInstance, lpTemplate, hWndParent, lpDialogFunc) to create and show the dialog in your program. The third parameter is the Handle of parent window and it can be NULL. The forth parameter is the callback function.
So we test to call DialogBoxW in WinMain. You can check the picture below. We abandoned the traditional Win32 framework and made the custom window our main window. It work.
However, it should be noted that windows created in this form are modal, which is not applicable in many scenarios. What you say and what you want to do may be better done with MFC. Win32 does not encapsulate many interfaces like MFC for you to call.
I use Visual Studio 2013 Enterprise, but the procedures will be the same:
1 - On the Solution Explorer, click on the .RC file
2 - In the new window (Resource View), click in Dialog
3 - Double-click the dialog you want to edit...
That´s it...

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.

How to use MFC ListCtrl in SDI

I am really a beginner with MFC. I just want a few guidelines on how to use a ListCtrl in an SDI application. For example, getting input from the user and displaying it in the listctrl when a button is clicked. Please guide me.
In SDI application I would use CListView-derived class for main view. This class has been designed to be used in SDI/MDI apps and supports standard MFC document-view architecture. The CListView class internally uses CListCtrl, but it does automatic resizing and other handy things, you can also get direct access to embedded list ctrl by calling CListView::GetListCtrl() method that returns CListCtrl*.

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.

Controls on main window using Visual C++ designer?

Is is possible to draw controls using Visual C++ designer on the main window, in the same way you can design dialogs? I'd preferably like to be able to design the main window controls this way without using MFC, rather than creating them on WM_CREATE.
EDIT: I don't want a dialog-based app, just to be able to design the main window graphically similar to what can be done using Windows Forms Designer in .NET?
Your options are:
Use MFC and create a main window that has a dialog view (based on the CFormView class).
Use WinForms/.NET
Use Qt.
If you're starting a new project and you want to stick with C++, then I highly recommend Qt. Not only is it an excellent framework, but it's cross-platform so your app could be built on Linux and the Mac.
http://www.qtsoftware.com/products/
A Visual C++ plugin is available and you can design your main window visually using a tool called Qt Designer.
I'm not sure if I understand what you want your app to look like. If you want your application to be a dialog, then make it a dialog app.
Just create a new MFC Application, and set it to "Dialog based". Now your application will start at that dialog.
If you want to use a native win32 app, just create the dialog in your InitInstance, using CreateDialog (instead of CreateWindow).
In both cases, you use the resource editor to create the dialog.