C + +: Strengthening Windows applications with the Visual C + + 2008 Feature Pack

Source: Internet
Author: User
Tags bool new features pack visual studio

This article discusses:

Microsoft Basic Class Library update

Programming the Ribbon with C + +

Implementing a tabbed MDI using C + +

Polymorphic functions and smart pointers This article is based on a pre-release version of the Visual C + + Feature Pack. All information contained in this article is likely to change.

This article uses the following techniques:

Visual Studio 2008,MFC

Directory

Office Ribbon User Interface

Tabbed Multi-Document interface

New features in the standard C + + library

Multi-state Function object

Smart pointers

As a Visual C + + developer, you may feel a bit neglected in recent years, as it seems that Microsoft has added new features and new features to visual c++® much less than visual c#®. In fact, although the Visual C + + compiler is constantly improving in terms of performance, security, and standard compliance, it has long been doing less in terms of new libraries and productivity features. Later, although MFC was updated to better support Windows vista®, there is still a lot of work to be done.

But now, in order to provide better support to developers who use native code and MFC, Microsoft has released the Visual C + + 2008 Feature Pack. The following are some of the main elements of the Visual C + + update.

This feature pack includes a large set of new MFC classes for building modern user interfaces. It also includes a large number of features added to the standard C + + library as part of Technical Report 1 (TR1). TR1 is the first major update and addition to the standard C + + library used by the C + + committee.

For years, single and multiple document/view applications, menus, toolbars, and dialog boxes in traditional mode have been a major aspect of MFC development. If you want to make the MFC application look more modern, users need to find a way to do it.

Now it's completely different. MFC now includes a number of new user interface patterns, even with dockable panes similar to those in Microsoft®office and Visual studio®. It also fully supports the Microsoft Office Ribbon user interface as well as numerous other new controls, dialog boxes, and Windows.

Next, I'll demonstrate two new user interface features in MFC: The Office ribbon and the tabbed Multiple document interface (MDI).

Office Ribbon User Interface

So far, I'm sure you've seen the new 2007 Microsoft Office system ribbon element, and you might want to know how to create that effect in your own application. Happily, you can now add a ribbon bar to the MFC frame window very easily.

Many new features are dependent on the new version of CWINAPP, CFrameWnd, and CMDIFrameWnd classes, which represent the foundation of most MFC applications. CWinAppEx is derived from CwinApp and should be used as the base class for application objects. CFrameWndEx is derived from CFrameWnd and should be used as the base class for a single document interface (SDI) frame window. Similarly, CMDIFrameWndEx is derived from CMDIFrameWnd and should be used as the base class for the MDI frame window. These new base classes provide all the necessary elements to support many new user interface features, such as dockable, resizable window panes, and workspace persistence.

Figure 1 shows the smallest application object that can support the ribbon bar. As you can see, the application class is derived from CWinAppEx to implement the familiar InitInstance member functions (typically used to create the main window of the application). Never forget to call the Setregistrykey member function to set the registry location of the application settings, because the framework class depends on it. Then, InitInstance continues to create the main window in the usual way.

Figure1 Ribbon Application Object

class Application : public CWinAppEx
{
public:
  virtual BOOL InitInstance();
};
BOOL Application::InitInstance()
{
  SetRegistryKey(L"SampleCompany\\SampleProduct");
  m_pMainWnd = new MainWindow;
  m_pMainWnd->ShowWindow(m_nCmdShow);
  m_pMainWnd->UpdateWindow();
  return TRUE;
}

The code in Figure 2 shows a minimum SDI frame window with the Ribbon bar and application buttons. Application buttons are not required, but are typically used in conjunction with the ribbon bar to provide applications with a wide variety of main menus in place of the traditional File menu.

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.