Visual C + + MFC Concise Tutorial (1)

Source: Internet
Author: User

Part I.: Introduction to MFC

Visual C + + is more than just a compiler. It is a comprehensive application development environment that you can use to leverage C + + with object-oriented features to develop professional-level Windows applications. In order to fully utilize these features, you must understand the C + + programming language. With C + +, you have to master the hierarchy of the Microsoft Basic Class library (MFC). This hierarchy embraces the user interface section of the Windows API and enables you to easily build Windows applications in an object-oriented manner. This hierarchy applies to all versions of Windows and is compatible with each other. The code you have built with MFC is completely portable.

This tutorial will introduce you to MFC's basic concepts and terminology, as well as event-driven programming methods. In this section, you will enter, compile, and run a simple MFC program. The code will be explained in detail in the next section. The third part discusses MFC control and how to customize them. The Forth part will introduce the message map, and you will be dealing with MFC events.

What is MFC?

If you want to build a Windows application, how should you do it?

A good start is starting with the design user interface. First, you have to decide what users can use the program and set the corresponding user interface objects as needed. The Windows user interface has some standard controls, such as buttons, menus, scroll bars, and lists, which are already familiar to those Windows users. Keep in mind that as a programmer you have to choose a set of controls and decide how to arrange them on the screen. Traditionally, you need to sketch the user interface on a piece of paper until you're satisfied with the elements. This is possible for some of the smaller projects, as well as the early prototyping phases of some large projects.

The next step is to implement the code. When you build an application for any Windows platform, programmers have two choices: C or C + +. With C, programmers write code at the level of the Windows application Interface (API). The interface is made up of hundreds of C functions, which are described in the Windows API Reference manual. For Windows NT, the API is called the "Win32 API" to distinguish it from its 16-bit API for Windows 3.1.

Microsoft also provides a C + + library, which sits on top of any Windows API, making it easier for programmers to work. It is the Microsoft Basic Class Library (MFC), the main advantage of which is its high efficiency. It reduces the amount of code that must be written to create a Windows program. It also provides the benefits of all general C + + programming, such as inheritance and encapsulation. MFC is portable, for example, code written under Windows 3.1 can be easily ported to Windows NT or Windows 95. As a result, MFC is a great way to develop Windows applications, all of which are MFC throughout this tutorial.

When using MFC, the code you write is used to create the necessary user interface control and customize its appearance. You will also write code that responds to the user's manipulation of these controls. For example, if a user clicks a button, you should have code to respond to it. This is the event-driven code that makes up all the applications. Once the application is properly responsive to all allowable controls, its task is completed.

You can see that using MFC for Windows programming is a relatively easy process. The purpose of this tutorial is to give you a more detailed idea of how to quickly build a professional-level application technology. The Visual C + + application development program environment is especially good for using MFC (and other development environments using MFC), so learning MFC and Visual C + + can enhance your development program's capabilities.

Windows glossary

The vocabulary used in the Windows user interface and software development is both basic and unique. For new users who are exposed to the environment, review several definitions below to make our discussions easier.

Windows applications use several standard controls:

Static text label

Button

list box

Combo Box (a more advanced list box)

radio button

Check button

Edit boxes (single and multiple lines)

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.