how to show the print preview category? - c++

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.

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 do I use the "new" Common Item Dialog with wxwidgets?

I want to create a file open dialog with wxwidgets that uses the "new" style of the Common Item Dialog under Win-Vista and newer. Is there any way to achive this? With the wxFileDlg() I get a dialog as shown on the right side but I'd like to get th left dialog...
both dialogs
The dialogs sample included in wxWidgets shows the example of "new style" file dialog if you use e.g. "Dialogs|File operations|Save dialog" menu item (or just press Ctrl+S) and there is nothing special to do. If this doesn't work for you, check that you're
Not using some ancient version of wxWidgets.
Have correct manifest in your application.
Not using any custom controls in your dialog, as those are only supported in old style version.
I struggled with this today so thought I would post here for the next person who has the same issue. If I were to guess, your code was calling either dialog.Center() or dialog.CenterOnParent(). I've posted a lengthy explanation of why this happens here.
From all my time spent on this today, you have to choose whether you want have the old common control dialog and be able to center it, or use the new common item dialog and have it appear in your windows top-left corner.
The good news is that Visual Studio, Word, Excel, Firefox, Chrome, and many others all use the new dialog and they all open at the top-left of the application window.

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 customise - add new toolbar?

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.

Visual Studio MFC Toolbar Editor icon order won't update

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.