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.
Related
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.
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...
Well I am working with visual studio 2015 on an mfc project.
I have enabled the office like ribbon in the project creation wizard.
I am inheriting from CView for my view class to get printing support as documentation suggests.
I have also overrided OnDraw too.
Now I want to get a print preview of the document with the print preview options on the ribbon.
I don't know where to start or how to act.
Any suggestions, propositions or examples ?
Thanks in advance.
You do not need to do it again for print preview window.
When you start a new "MFC application" for MDI and "Ribbon control", the application it self provides a print preview option.
Once you create a new application, Run the application.
The application runs and a windows opens.
Select the options as shown in below images.
You will get "print preview" option.
Search in the source code for "print view" to understand how it is implemented.
I'm using visual studio 2010 and i'M creating aN MFC dialog based application. Everything was working fine until recently when the add variable wizard stopped showing up when we right click on a control in main dialog and choose add variable.
I have 3 dialogs in the project. The add variable wizard shows up for the other dialogs. Only for the main dialog the wizard is not showing up, ie. nothing
is happening when we right click and choose add variable on say picture control embedded in main dialog.
I'm using 64 bit Windows 7.
The problem was ID mismatch(ID of main dialog) in the properties of dialog and the header of the corresponding class of the dialog. It is fixed and is working correctly now.
I've been trying to create a custom toolbar in a MFC project in Visual Studio 2010. I've been following the Sketcher tutorial in Ivan Horton's Beginning Visual C++ 2010. The problem I'm running into is that the toolbar doesn't update to reflect the order and spacing of icons I have created.
I've created a small screenshot to demonstrate the problem:
In the background is the visual studio toolbar editor with my desired toolbar configuration. In the foreground is the actual app, which does not reflect the spacing or order of icons I've designed. It does reflect NEW icons being added, and the icons work fine, but I just can't seem to get them to re-order or appropriately space themselves. They just append to the end in whatever order I create them.
I've tried the rudimentary techniques of restarting both VS and windows, but to no avail.
Any tips on getting it to play nicely? Lacking that, is there somewhere to manually view or edit the code generated by the toolbar editor?
For starters, if you create an MFC SDI/MDI project in VS.NET 2005, there is no such issue. It happens in VS.NET 2008 and 2010.
In fact, your rearrangement of the standard toolbar does takes effect. It's just not showing you the default state. To restore the state: click the small arrow button at the end of toolbar -> Add or Remove Buttons -> Standard -> Reset Toolbar.
Though I'm not 100% sure why it happens like this(design like this or a bug), there is a way to work around it and it works:
Add following code to the end of CMainFrame::LoadFrame(...)
BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
...
// Explicitly restore toolbar state
m_wndToolBar.RestoreOriginalstate();
return TRUE;
}
I recommend you to contact Microsoft support engineers as there's little resource on the web.
The reason could be that the toolbar state is already loaded from the registry whenever your application starts. So the framework reads the toolbar state and adds the new buttons to the end. Is there a Workspace key in your Registry and did you try to delete it anytime you make changes to the toolbar? The key should be at a location like HKEY_CURRENT_USER\Software\MyCompany\MyApp\Workspace
The values for MyCompany and MyApp are usually set in InitInstance. Always calling RestoreOriginalState() would break the code to allow user modifications to the toolbar.