Visual C + + 2010 new features: Three great changes in MFC __c++

Source: Internet
Author: User
Tags visual studio 2010


"IT168" in Visual C + + 2010, the IDE has great improvements in both the user experience and performance, which greatly improve the programmer's development efficiency. In addition, enhanced MFC, for programmers to develop a colorful, secure and stable application has laid a solid foundation. This article describes the new features of MFC under Visual C + + 2010 from Visual C + + 2010, which makes it easy to build Windows 7 applications, restart the Manager, Tasks dialog box three.

easy to build windows 7 applications

Mention Windows 7, from the user experience, gorgeous window, gorgeous animation effect is one of its major features. It is rather difficult, if not impossible, to develop applications that have similar effects in vc++6.0. For programmers, to be able to "advance with the Times" to reflect the spirit of modern programmers, in the face of Windows 7 so powerful gorgeous effect, can we only be "sigh and use" it? Thanks to Visual C + + 2010, the application we developed ourselves can also be "dazzle".

(1) Support access to Windows APIs

Windows 7 introduces a number of exciting new technologies and new features, as well as new APIs, which provide users with a new experience that is simple, easy to use, and gorgeous. Visual Studio 2010 provides access to all new Windows APIs. Visual Studio 2010 provides the Windows SDK components needed to write code for native Windows APIs, and you can use the SDK header files and libraries in Visual Studio 2010 to leverage such as Direct3D 11, Direc Innovations in Twrite, direct2d, and Windows Web Service APIs.

In addition to opening all Windows APIs to developers, this version of Visual Studio enables you to write Windows applications more easily with the help of enhanced MFC. You can access the main Windows 7 features through the MFC library without having to write directly to the native APIs. With just a recompile, your existing MFC application can shine on Windows 7. Also, your new application can take full advantage of new features.

(2) Enhanced integration with Windows shell

MFC's integration with the Windows Shell has also been enhanced. By using the additional file handlers in Visual C + + 2010 to preview, create thumbnails, and search, our applications can be better integrated with Windows Explorer. These features are provided as options in the MFC Application Wizard, and as shown in the following illustration, we simply tick the appropriate options and MFC automatically generates the ATL DLL project that implements the handlers.


(3) Super task bar

One of the most noteworthy user interface changes in Windows 7 is the Super taskbar. Enhanced MFC allows us to use these features such as jump Lists, tabbed thumbnails, thumbnail previews, progress bars, icon overlays, and more. The following illustration shows a thumbnail preview and tabbed thumbnails for a tabbed multi-document MFC application.

 

(4) Windows 7 Style Ribbon

Applications created in Visual C + + 2010 can have the ability to create a Windows 7 style ribbon that you can switch from several Office style ribbon to Windows 7 styles. The following figure


(5) Multi-point touch and DPI recognition is supported

Enhanced MFC makes it easy for us to develop multi-touch applications, call the corresponding messages when various touch events occur, and develop such applications by registering touch and gesture events only. MFC enables high DPI recognition by default, so applications can implement high DPI screens without pixel or blur. MFC scales and changes fonts and other elements internally to ensure that the UI is also as clear on the high DPI display.

The enhanced MFC, in the overall support of window 7, is ready for us to develop similar Windows 7 applications, so that gorgeous, eye-sucking apps are no longer exclusive to window 7, and we can.

 Restarting the manager

For most computer users, it's depressing to see that you've spent a lot of time writing documents that have been accidentally shut down or restarted by an application. In the Office2007 to increase the automatic save function, once encountered in this situation, you can revert to the state of the unexpected situation, not to let their work results due to failure and lost. The addition of the Reboot manager in Visual C + + 2010 is similar to this application.

The reboot manager is a useful feature introduced in Windows Vista that enables applications to perform saved operations before terminating. The application can call this feature and then restore its state at reboot. In Visual C + + 2010, we can take full advantage of the restart Manager in an MFC application to better handle application crashes and reboots. How do I use the reboot manager? In two cases: one is to add a reboot manager to an existing application, and the other is to use this feature in a newly created MFC application.

The ability to add a reboot manager to an existing application

1. Open an existing MFC application.

2. Open the source file for the main application. By default, this file is a. cpp file with the same name as the application. The main application source file, such as Restartmanagerdemo, is RestartManagerDemo.cpp.

3. Find the constructor for the main application. For example, if the project is Restartmanagerdemo, the constructor is Crestartmanagerdemoapp:: Crestartmanagerdemoapp ().

4. Add the following highlighted lines of code to the constructor.


5. Ensure that the application's InitInstance method calls its parent InitInstance method: CWinApp::InitInstance or Cwinappex::initinstance.

6. Compile and run the application.

Second, add the Restart Management feature in the newly created MFC application, just check the appropriate feature items in the MFC Application Wizard. See figure below


List of features for each option:

Option name Function description Code that is automatically added in the constructor
Support for Reboot Manager Indicates that your application will only support the reboot feature. In other words, your program can be restarted after an upgrade or crash, but you cannot automatically open a document that is not closed, and you cannot recover the data. m_dwRestartManagerSupportFlags =
Afx_restart_manager_support_restart;
Reopen a previously opened document Indicates that your application can reopen a previously opened document after a reboot, i.e. automatically revert to current working state m_dwRestartManagerSupportFlags =
afx_restart_manager_support_restart_aspects;
Support for Application Recovery Indicates that after restarting your application, you can not only reopen documents that were previously open, but also try to recover automatically saved documents m_dwRestartManagerSupportFlags =
afx_restart_manager_support_all_aspects;

The behavior of the reboot manager is related to the type of application. In the case of an application such as a document editor, restarting management enables the application to automatically save the state and content of the document that has been opened, to save Run-time data when the program is abnormal, and to automatically revert to a situation where no exception occurred. Thus the robustness and reliability of the program are improved. If the application is not a document editor, the restart Manager restarts the application, but the application's state cannot be saved by default.

After you restart the application, depending on the application, a Task dialog box (Unicode version) or message box (non-Unicode version) will pop up, asking the user if they need to restore the document that is automatically persisted. If the user chooses Yes, the automatically persisted document will be opened as the current document. If the user chooses no, the last document saved by the user will be opened as the current document, and the automatically saved document will be deleted.

The addition of a reboot manager enhances the robustness and reliability of the program and enhances the user experience.

  Task dialog Box

In order to improve the user experience, in Visual C + + 2010, you can use the Task dialog box (mission Dialog) to replace the previously widely used message box. In contrast to message boxes, task dialogs can display messages to users as well as custom buttons, command-line options, and richer ancillary information. The new CTaskDialog class provides a number of simple and useful functions that we can easily use to improve the user experience of the application by using task dialogs, and to keep the interface style of your application consistent with the Vista system. The following figure:


In VC + + 6.0, the Task dialog box is not supported, the message is displayed to the user, only the AfxMessageBox class can be used to set the display content, icon and button style. The following figure


Before the CTaskDialog, AfxMessageBox is also a good choice, CTaskDialog provides users with comprehensive information and operating methods, providing users with adequate information to make accurate choices.

Summary

As you can see from the above three aspects, enhanced MFC facilitates programmer development and provides the foundation for cool, flashy applications that are consistent with Windows 7, Vista, and greatly enhance the user experience, The application we develop is no longer just a powerful feature, and the user experience is the direction of our efforts, and Visual C + + 2010 helps us to improve.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.