Learn the MFC C++ Classes pdf

637 682 5
Learn the MFC C++ Classes pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Brief Full Advanced Search Search Tips To access the contents, click the chapter and section titles. Learn the MFC C++ Classes (Publisher: Wordware Publishing, Inc.) Author(s): Shirley Wodtke ISBN: 1556225121 Publication Date: 01/01/97 Search this book: Introduction Learn the MFC C++ Classes Acknowledgment Chapter 1—Windows and MFC Windows Operating Systems and MFC C++ Compilers and MFC Windows User Inputs to a Window Messages MFC and Windows OS Interaction The Structure of an MFC Application Creating a Main Window Using MFC The CFrameWnd::Create() Function Registering a New Window Class Resource Files Customized Icon and Cursor Resources Summary Exercise Chapter 2—Menus and Message Maps An Example With a Simple Menu Message Maps Go! Keyword Go! Menus Accelerators Handler Functions Setting the Timer Displaying a Message Box Adding Message Map Entries With Compiler Tools An Example That Changes Menus and Submenus Using CMenu Objects CWnd Functions for Messages Summary Exercise Chapter 3—Graphics and Text Drawing The Graphics Device Interface (GDI) The Device Context GDI Objects Device Context Settings Stock Drawing Objects The CDC Class The Device Context Classes An Example That Draws Text and Shapes An Example That Sets the Viewport Origin How a Screen Repaints Itself Creating a Pen Creating a Brush The RGB Macro The Raster Drawing Mode and SetROP2() A Graphics Editor Example C++ Objects for the Rectangle and Ellipse The Graphics Output Process Deleting Drawing Objects Drawing the Rectangles and Ellipses The OnPaint() Function Maintaining the Update Region The Background Color The Handy Utility Classes: CRect, CPoint, and CSize Using a Private Device Context An Example With a Private Device Context Summary Exercise Chapter 4—Fast Drawing and Bitmap Graphics Using Exclusive-or and Exclusive-nor for Fast Redraws Details of the Exclusive-or (Exclusive-nor) Process Limitations of the Exclusive-or (Exclusive-nor) Process Using Backing Store for Fast Redraws Bitmaps Using a Memory Device Context The CDC::BitBlt() Function Using Bitmap Graphics for Animation The Message Handler OnCreate() The Message Handler OnTimer() Device Independent Bitmaps (DIBs) Palettes The System Palette Loading and Using the System Palette Displaying a DIB Using the System Palette Summary Exercise Chapter 5—Child Windows A Child Window The CWnd::Create()Function Message Maps for Child Windows User Messages A Popup Window A Fixed Child Window Summary Chapter 6—Dialogs, Common Dialogs, and Button Controls Dialogs Modal vs. Modeless Dialog Boxes Common Dialogs Class CFileDialog Class CPrintDialog Class CPageSetupDialog Class CFindReplaceDialog Class CFontDialog Class CColorDialog Using the ChooseColor Common Dialog Designing Dialog Boxes Overview of Common Controls Window Styles for Win3.1 Common Controls Button Controls Static Controls Placing Controls on the Mainframe Window Messages To and From Button Controls Messages From the Button Control Messages To the Button Control Example Program Programming the Buttons Example Generating the Main Window’s Code Generating the Dialog Box Code The Buttons Program Listing Discussion of the Buttons Program Summary Chapter 7—List Box, Combo Box, and Edit Controls and Data Transfer Functions Overview of List Box, Combo Box, and Edit Controls Edit Control Styles List Box Styles Combo Box Styles Operations and Messages for Win3.1 Common Controls An Example Program Programming the UsrInput Example Generating the Main Window’s Code Generating the Dialog Box Code The UsrInput Program Listing Discussion of the UsrInput Program Data Transfer Do Data Exchange Functions Dialog Data Validation (DDV) Functions CString Features String Tables and Internationalization Summary Chapter 8—Communication Between Parent and Child for Modal and Modeless Dialogs The Modal Dialog Example The MFC Class CCmdUI The ModalCom Program Listing Data Transfer Modeless Dialog Example Modeless Dialog Creation User Messages Modeless Program Listing Data Updating Special Virtual Functions Summary Exercise Chapter 9—The Document-View Architecture The Structure of the Four Classes Message Routing An Example Document-View Program The PreCreateWindow() Function Customizing the Mainframe Window Overriding the CFrameWnd::PreCreateWindow() Function Mainframe Resources Customizing the View Window The OnDraw() Function Message Maps The Custom Program Listing The Document Template The RUNTIME_CLASS Macro The CView Class Views Based on a Dialog Template Views Based on a Control Summary Chapter 10—Document-View Applications With Filing and Printing Creating an AppWizard Project Designing the Application’s Data Designing the User Interface The Application’s Menu Printing the View The Function OnPrepareDC() Mapping Modes Functions for Printing Print Preview and Print Setup Data Persistence—Filing the Document’s Data Serialization and CArchive The OnNewDocument() Function Multiple Views of the Document ElipsMin Program with Minimum Code ElipsMin Program Listing Discussion of the “ElipsMin” Program Making the Dialog Box Modeless Diagnostic Code Summary Chapter 11—More About Splitter Windows and Filing The Starter Application Multiple View Classes Static Splitter Windows Collection Classes Array Collections List Collections Map Collections Designing the Document’s Data Coding the Document Class CByteArray Member Functions Designing the View of the Rules Using Logical Fonts Text Metrics Coding the View Class Containing the Rules Designing the View of the Game Drawing The Tic Tac Toe Board Drawing the Moves Summary Chapter 12—An MDI Application An MDI Application Class Structure Characteristics Creating New Views Creating New Documents Multiple Menus Keyboard Accelerators The CFormView Class Creating the “Form” Program The “Form” Starter Application The Multiple Document Template The Trace Macro The Document Class Code Additions to the Document Class The View Class Code Additions to the View Class Running the “Form” Program in Debug Mode The “FormMin” Program With Minimum Code “FormMin” Program Listing Discussion of the “FormMin” Program Summary Chapter 13—Toolbars and Status Bars The Bars Example Creating the Bars Starter Application Designing the Document Class Designing the View Class Drawing Adding Scrolling Customizing the Status Bar Adding the Handler Functions Customizing the Toolbar Visual C++ 4 Toolbar Editing Visual C++ 1.5 Toolbar Editing Using Two Document Templates Adding a Dynamic Splitter To An MDI Adding a Document Template Resources for Document Templates Summary Exercise Chapter 14—Custom Controls, New Common Controls, and Property Sheets Custom Controls The CustCtrl Example Building the “CustCtrl” Program The New Common Controls Creating New Common Controls The NewCmnCtrls Example New Common Control Styles Building the NewCmnCtrls Program Getting the AppWizard Starter Application Add the Menu Item Create the Dialog Template Creating the Dialog Class Notification Messages Property Sheets The PropertySheet Example Creating a Modal Property Sheet Building the “PropertySheet” Program Using the Apply Button Summary Appendix A Appendix B Appendix C Appendix D Appendix E Appendix F Appendix G Index Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. Brief Full Advanced Search Search Tips To access the contents, click the chapter and section titles. Learn the MFC C++ Classes (Publisher: Wordware Publishing, Inc.) Author(s): Shirley Wodtke ISBN: 1556225121 Publication Date: 01/01/97 Search this book: Table of Contents Introduction It is not necessary to learn the Windows API in order to begin using the Microsoft Foundation Class (MFC) Library of C++ classes; you do not even have to know more than a few basic C++ concepts in order to begin. I have been teaching extension classes through the University of California, Berkeley, since 1993. My students have ranged from expert to beginning Windows programmers. As an MFC teacher, I had to design a system that addressed the “common denominator” in the class, since so many of my students were put onto MFC projects and expected to “ramp up” in a matter of weeks, despite whatever their previous experience may have been. With the help of input from my students, I developed my simple one-idea-at-a-time approach to the MFC Library. I start with the most fundamental concept that a student needs to know and show the student how to master that one concept only. Then, I add the next concept. When exposed to a steady progression of clear ideas and exercises, my students have been able to truly master the fundamental concepts of MFC. This approach has worked for them, and I am sure that it will work for you. I adapted this book from my lengthy course notes, updating it for the new MFC compilers. But I use the same approach and the same examples. All of the examples have been student-tested for clarity and effectiveness in getting each concept across. All potential misunderstandings and errors have already been caught by my students and corrected. You can type in what you see and follow it line by line, because it will run on either Windows NT, Win3.1x, or Win95. Additionally, I have done my best to ensure that no code was “corrupted” during the production of this book and have included, as a backup (and so that you do not need to retype it), two diskettes with the original, typo-free code. My experience as a teacher has taught me that if you show a programmer effective, error-free code, the code explains itself; therefore, I Go! Keyword Go! [...]... summarizes the functions of these components Collectively, these three components are called the API These components interact with the MFC application An MFC application calls functions in the API The base classes in the MFC library incorporate API functions, so the MFC classes also call functions in the API The three API components are each provided as DLLs An application can call functions in the DLL... discussed All the MFC classes are defined in the header file The angle brackets around the header file tell the compiler to look in the compiler subdirectories for the file, rather than in the working directory The prefix “afx” is an acronym for “application framework x.” The header file contains the MFC class definitions, which is how the compiler knows to include the CWinApp and... and 4 versions of the tools In one case, in Chapter Thirteen, the differences are sufficiently different that both versions of the tool are covered Otherwise, the reader is expected to make the translation to his version The main focus of the examples of this book is the MFC features, not the features of the tools The Symantec C++7 compiler also provides tools to assist the programmer The Symantec tools... advantages, such as the ability to interrupt an errant program, are built into NT Because they are built in, using them requires no special effort on the part of the programmer, and most MFC applications can be created without modifying the MFC classes or needing multithreaded execution C++ Compilers and MFC C++ compilers that can build MFC applications are: Microsoft, Symantec, and Borland The MFC examples... access the contents, click the chapter and section titles Learn the MFC C++ Classes Go! Keyword q Brief Full Advanced Search Search Tips (Publisher: Wordware Publishing, Inc.) Author(s): Shirley Wodtke ISBN: 1556225121 Publication Date: 01/01/97 Search this book: Go! Table of Contents - Learn the MFC C++ Classes Companion Diskette Information The code for each of the examples given in the book... “Minimize,” and “Restore.” Minimizes the window when clicked In Win3.1x the window shrinks to an icon and the text of the window’s caption appears below the icon In Win95 the minimized application appears in the task bar (also referred to as the “launch bar"), which is the bar at the bottom of the screen; the minimized application’s icon precedes its title in the task bar Expands the window to full screen when... with any of these compilers Appendices are included that cover the important compiler aspects to get the reader started Appendix D covers Microsoft’s Visual C++ 4 Appendix E covers Microsoft’s Visual C++1 .5 Appendix F covers Symantec’s C++ 7 Appendix G covers Borland’s C++ 5 The Microsoft compiler, known as Visual C++, is the most prevalent of the compilers that host MFC Visual C++ 1.5 is for the Win3.1x... frameworks, because they give the user a framework for an application The MFC classes have been built using the operating system’s Application Programming Interface (API) functions The API is the original Windows OS library of functions, coded in C, that subsequent libraries were built from, such as MFC MFC provides easier-to-use functionality that incorporates the API functions Using the MFC classes means... box Resizes the window when dragged with the mouse Appears with scroll bars This feature is included on Win32 applications only The example applications given later in this chapter show how to use the MFC classes to create a main window These examples demonstrate how your application defines classes that are derived from classes in the MFC library Applications use objects of these derived classes to... define constructor The preceding program makes heavy use of inheritance from the MFC library An MFC program will always use the CFrameWnd and CWinApp classes, which contain all of the code necessary to create and operate the main window To build the internal engine that runs the program we need to derive an application class The MFC class that defines an application is CWinApp, which is the backbone of . Contents Learn the MFC C++ Classes Companion Diskette Information The code for each of the examples given in the book is on the included disks. In addition to the examples given in the book,. Introduction Learn the MFC C++ Classes Acknowledgment Chapter 1—Windows and MFC Windows Operating Systems and MFC C++ Compilers and MFC Windows User Inputs to a Window Messages MFC and Windows. such that they work on any of these operating systems. An exception to this rule is the code for the toolbar in Chapter 13, which differs for MFC 2.5 and for the newer MFC 4.0. Also, the final

Ngày đăng: 13/07/2014, 20:20

Tài liệu cùng người dùng

Tài liệu liên quan