Chapter two
THE Microsoft Foundation Class Library Application Framework
Microsoft Application Basics Framework Category Library
This chapter introduces the Microsoft Foundation Class (MFC) library 7.0 Application Framework and explains its benefits. It includes a stripped-down but fully operational MFC library program for Microsoft Windows that should help you understand what application framework programming is all about. I'm Keeping theory to a minimum here
This chapter mainly explains the Microsoft Application Basic Framework Class Bank and its benefits. I will show the operation of the MFC class library, and make you understand that the application framework is to help you build a Windows program. I will remain here. Little pure theoretical discussion, but I will help you find some examples behind the message map, document, and view part of the view.
Why use the application framework?
Why use the application framework
If you're going to develop applications for Windows, you've got to choose a development environment Assuming that you've already rejected non-C options such as Microsoft Visual Basic and Borland Delphi, here are some of your remaining options.:
PROGRAM IN C with The Win32 API.
Writ your OWN C Windows Class Library That Uses Win32.
Use the MFC Library Application Framework
Use annother Windows-based Application Framework. (MOST OF THEM
Are Defunct, However-Such As Borland's Object Windows Library [OWL].
If you want to develop Windows applications, you will choose the development environment. Pride you may have given up non-C environment, such as VB, Delphi, there are other options:
Write WIN32-based procedures with C language
Write WIN32-based Windows Category Library using C
Use the MFC application framework
Use other Windows-based application frames (many other frames have disappeared, however, for example, Bailan's OWL is very good).
Note We'll Cover .NET Windows Forms In Part Vi of this book.
Explanation: The sixth part of our book includes the form of a .NET's Windows.
If you're starting from scratch, any option will involve a big learning curve. If you're already a Win32 programmer, you'll still have a learning curve with the MFC library. Since its release, the MFC library has become the dominant Windows Class Library. But Even if you're Familiar with It's Still A Good Idea To Step THROUGH The Features of this Programming Choice. If you start reading this book from the beginning, you should have a probably learning curve. If you are already Win32 master, you will still learn the MFC library, because MFC has occupied the rule of the Windows class library in the latest version, even if you just are familiar with it, the MFC is still good, you choose a good program. s Choice.
The MFC Library is The Low-Level C Interface To The Windows API
C has been a standard for many developers for a number of years. It's turned into a mature, well-understood framework with great third-party support. If you need the highest-performance applications, your applications must live as closely to the Windows API AS Possible. C and mfc are asking wndproc methods by hand.
The MFC library is an interface based on a low-grade C language Windows API
C is a standard for many years. It is a mature frame for many third-party support. If you need efficient applications, your application must be close to the WINDOWS API running possible .c and MFC It is not supporting how you write WNDPROC.
Application Framework Applications Uses Use A Standard Structure
Any programmer starting on a large project develops some kind of structure for the code. The problem is that each programmer's structure is different, and it's difficult for a new team member to learn the structure and conform to it. The MFC library application framework includes its own application structure-one that's been proven in many software environments and in many projects. If you write a program for Windows that uses the MFC library, you can safely retire to a Caribbean island, knowing that your minions can easily maintain and enhance your code Back home.
The application framework is the standard structure of the application development. Each programmer has some structural code when starting a big project. There is a problem in every programmer, and the new member is difficult to learn this. Structure and complies with it. MFC library Application Framework only contains a structure in our program and is tested in many software environments and many projects. If you write Windows applications with MFC, you can safely evacuate the Caribbean Island, your servant can easily continue to maintain and improve your code after you go home.
Don't Think That The MFC Library's Structure Makes Your Program Inflexible. With the MFC Library, Your Program Call Win32 Functions at Any Time, So You Can Take Maximum Advantage Of Windows.
Don't think that the MFC library structure will make your program dead. With the MFC library, your program can call the Win32 function anywhere, so you have the biggest favorable conditions in Windows.
Application Framework Applications Are Small and Fast
BACKIT BUILD A Self-Contained Windows Exe File Today 5 kb in size. Today, Windows-based Programs Are Larger. One Reason Is That 32-Bit Code Is Fatter. Even with the large memory model, a Win16 program uses 16-bit addresses for stack variables and many globals. Win32 programs use 32-bit addresses for everything and often use 32-bit integers because they're more efficient than 16-bit integers. In addition, The C Exception-Handling Code Consumes a Lot of Memory.
Small and fast applications using the application framework
In the 16-bit era, you can only build an exe file less than 20KB. Today, Windows-based procedures are great. A commonly used 32-bit code is very large. Even use large memory space, Win16 The program can only use 16-bit common stack variables. The program of Win32 can use 32-bit addresses for each program and use 32-bit integer because it is more efficient than 16-bit integers. In addition, C Abnormal operation will consume a lot of memory.
That old 20KB program did not have a docking toolbar, splitter windows, print preview capabilities, or control container support-features that users now expect. MFC programs are bigger because they do more and look better. Fortunately, it's now easy to build applications That Dynamically Link to The MFC Code (and To C Run-Time Code), So The Size Goes Back Down Again-from 192kb To About 20kb! of Course, You'll Need Some Big Support Dlls in The Background, But Those Are A Fact of life.
The old 20KB program does not support the docking, window separation, print preview, or support for container controls, and now the user can use these features. MFC program is big because it is more beautiful. Lucky Yes, it is now easy to build an app and dynamically connect to the MFC code (simultaneously to the code at C run), so your program can return from 192K to 20K. Of course, your program needs some big The DLL is supported behind, but this fact cannot be changed in the current .a're Working with machine code produduced by an Optimizing Compiler. Execution is found, but you might notice a startup delay as the Support Dlls Are Loaded.
As for the speed problem, your machine code has been optimized by the compiler. Execution is fast, but you may feel delay when the program starts to load the DLL.
The Visual C . Net Tools Reduce Coding Drudgery
The Visual C . NET resource editors, the MFC Application Wizard, and the code wizards available from Class View significantly reduce the time needed to write code that's specific to your application. For example, the resource editor creates a header file that contains assigned values for #define constants. The MFC Application Wizard Generes Skeleton Code for your entire application, and you can use the the property window to add message handlers and map messages to the.
Visual C comes with a self-contained tool to reduce the difficulty of encoding
Visual C Self-contained Resource Editor, Application Wizard, Class Code Generator Wizard can greatly reduce our coded time. For example: build a constant defined in the header file in the resource editor. MFC application wizard You can create a complete frame code for your program, and you can add a message header message mapping in the Properties window.
The MFC Library Application Framework is Feature Rich
The MFC Library 1.0 Classes, Introducesd With C / C 7.0, Included The Following Features:
A C Interface to the Windows API
General-purpose (Non-Windows-Specific) Classes, Including:
Collection Classes for Lists, Arrays, And Maps
A useful and effect stand class
Time, Time SPAN, And Date Classes
File Access Classes for Operating System Independence
Support for Systematic Object Storage and Retrieval To and from Disk
A "Common root object" Class Hierarchy
Streamlined Multiple Document Interface (MDI) Application Support
Some Support for Ole1.0mFC Class Library Application Framework Development History:
The class library of MFC 1.0 introduces C / C 7.0, including the following features:
Windows API is an interface for C language packaging
Generality (non-Windows class) ¸ 包括:
Collection classes include, lists, arrays, and mapping
Effective, useful string
Time, time calculation, date class
Documentation access class with independent and operating system
Support system objects from disk storage and recovery.
Class level of "same root object"
The application supports a new multi-document interface.
Support a small number of OLE1.0
The MFC library 2.0 classes (in Visual C 1.0) picked up where the version 1.0 classes left off by supporting many user interface features that are found in current Windows-based application, plus they introduced the application framework architecture. Here's a summary of the important New features:
Full Support for File Open, Save and Save As Commands and the Most Recently Used File LIST
Print Preview and Printer Support
Support for scrolling windows and splitter Windows
Support for Toolbars and Status Bars
Access To Visual Basic Controls
Support for context-sensitive help
Support for Automatic Processing of Data Entered In a Dialog Box
An Improved Interface To OLE 1.0
DLL Support
The MFC2.0 library (in Visual C 1.0) is streamlined on the basis of 1.0, and the current program finds that the application framework system is introduced in the feature of many user interfaces that it supports. Here is the following Important features:
Full support file open, save, save the list of files that are very recent users open
Print preview with the printer support.
Support the rolling window separated by the window.
Support toolbar follow status bar
Access VB control
Support sensitive context help
Support for automatic processing of data in dialog boxes
Improved OLE 1.0 interface
Support for DLL
The MFC Library 2.5 Classes (In Visual C 1.5) Contributed The Following:
Open Database Connectivity (ODBC) Support That Allows You Application To Access And Update Data Stored In Many Popular Databases Such AS Microsoft Access, Microsoft FoxPro, and Microsoft SQL Server
An Interface To Ole 2.01, With Support for In-Place Editing, Linking, Drag and Drop, And Ole Automation
MFC2.5 (in Visual C 1.5) has the following contributions:
Open Database Interconnection It is an allowed to support access and support for many universal databases,
For example Microsoft Access, Microsoft FoxPro, and Microsoft SQL Server.
Enhance OLE2.01 interface, support editing, connection, drag and drop, and OLE automation.
Visual C 2.0 WAS The First 32-Bit Version of the Product. Its IT IT Version 3.5. It Also Contained The MFC Library 3.0, Which Had The Following New Features:
Tab Dialog Box (Which Was Also Added to Visual C 1.51, Included on the Same CD)
Docking Control Bars That Were Implement Withnin MFC
Support for Thin-Frame Windows
A Separate Control Development Kit (CDK) for building 16-bit and 32-bit ole controls, Although No Ole Control Container Support Was Provided
Visual C 2.0 is the first 32-bit version of the product. It supports Windows NT3.5. It contains the library of MFC3.0. Here is a few new features:
TAB dialog (property page) support (also added in Visual C 1.51, in the same CD)
The stop bar has also been added to MFC
Support light frame window
A separate control development package for establishing 16-bit and 32-bit OLE controls, no support for the OLE control container.
A Subscription Release, Visual C 2.1 with The MFC Library 3.1, Added The Following:
Support for the New Windows 95 (Beta) CommON Controls
A New Odbc Level 2 Driver Integrated with The Access Jet Database Engine
Winsock Classes for TCP / IP Data Communication
Use the release of the MFC3.1 version of Visual C 2.1, add the following characteristics:
Support new Windows 95 (Beta) universal control
Integrated Jet Database Engine New ODBC
Use the TCP / IP protocol data communication to the Winsock class.
Microsoft Decided to Skip Visual C 3.0 and proceded Directly to 4.0 in Order to Synchronize The Product Version with the MFC Library. The MFC Library 4.0 Contains these Additional Features:
New OLE-BASED DATA Access Object (DAO) CLASSES for USE with the Jet Engine
Use of the windows 95 Docking Control Bars Instead of the MFC Control Bars
Full Support for the Common Controls in The Released Version of Windows 95, With New Tree View and Rich-Edit View Classes
New classes for thread synchronization
Ole Control Container Support
Microsoft decides to skip Visual C 3.0 and continue to develop MFC4.0 class libraries. MFC4.0 adds the following features:
Use the JET engine based on the new OLE data access object. Use the WINDOWS 95 docking block instead of the MFC control.
Fully supports the public control of Windows 95, and the new tree control with the Richedit control.
New synchronous thread class
OLE container support
Visual C 4.2 Was and Important Subscription Release That Included The MFC 4.2. The Following New Features WERE Included:
Wininet Classes
Activex Documents Server Classes
ActiveX Synchronous and Asynchronous Moniker Classes
ENHANCED MFC ActiveX Control Classes, With Features Such As Windowless Activation, Optimized Drawing Code, And So Forth
Improved MFC ODBC Support, Including Recordset Bulk Fetches and Data Transfer without Binding.
Visual C 4.2 is an important version that includes MFC4.2. It includes the following new features:
Winint class
ActiveX Document Service Class
ActiveX synchronization and asynchronous class
Enhanced MFC ActiveX class, which includes a flexible window, optimized drawing code, and more.
Improved support for MFC ODBC, including the size of the record set and the unbound data transfer.
Visual C 5.0 Included The MFC Library 4.21, Which Fixed Some 4.2 BUGS. Visual C 5.0 Introduces Own As Worthwhile Features of Its Own As Well:
A Redesigned IDE, Microsoft Developer Studio 97, Which Included and html-based online help system and integration with oth, incruding java
The Active Template Library (ATL) for Efficient ActiveX Control Construction for Internet
C Language Support for Com (Component Object Model) Client Programs with The New #import Statement for Type Libraries, As Described in Chapter25.
Visual C 5.0 includes MFC4.21, which fixes some of the 4.2 errors. Visual C 5.0 includes some highly outstanding features:
Designed Ide, Microsoft Developer Studio 97, which contains HTML online help systems and integrates other languages, including Java
In Chapter 25, the C Language-supported COM (Component Object Model) client can use the new #import statement to declare the type library.
Visual C 6.0 includes the MFC library 6.0 (. Notice that the versions are synchronized again) Many of the features in the MFC library 6.0 enabled developers to support the modern platform at the time, the Microsoft Active Platform, including the following: MFC classes that Encapsulate the New Windows Common Controls Introducesd AS Part of Microsoft Internet Explorer 4.0
Support for Dynamic HTML (DHTML), Which Allows MFC Program TO CREATE Applications That Can Dynamical Or Manipulate and Generate HTML Pages
Active Document Containment, Which Allows Mfc-based Applications to Contain Active Documents
OLE DB Consumers and providers Template Support and ActiveX Data Objects (ADO) Data Binding, Which Help Database Developers Who Use The MFC Library OR ATL
Visual C 6.0 includes MFC6.0 (also version of the synchronous system), MFC6.0 has many new features help developers support the latest platforms, Microsoft active platform, including the following features:
The MFC encapsulates the new Windows general control and introduces Microsoft IE4.0.
Support for dynamic HTML (DHTML), allowing MFC's programmers to operate and generate HTML pages when establishing an application.
Active document container allows MFC-based applications to include an activity document
OLE customers and providers touch board support and ADO data binding, can help those database developers use MFC and ATL
The latest edition of Visual C , Visual C . NET, includes the MFC library 7.0. Many of the features in the MFC library 7.0 support Internet programming (and the new Microsoft .NET platform) and also improve the Windows development environment. The new features INCLUDE The FOLLOWING:
ENHANCED Support for HTML Help Withnin MFC Applications
Support for Windowless Controls
DHTML Dialog Boxes and Editing Components
HTTP Argument Management Classes
Windows 2000 Print Dialog Box
STRICTER Message-Handler Type CHECKING
Date Support Beyond The Year 2038
The nearest Visual C version, Visual C . Net contains MFC7.0. MuFC7.0 supports Internet programming (in new Microsoft .NET platform) and also improves the Windows development environment. New features:
Enhance the MFC application HTML help support window control
DHML dialog and editing components
HTTP discussion management class
Windows 2000 print dialog
Strict message management type inspection mechanism
Date to support to 2038