Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Visual C++ and MFC Fundamentals programming phần 1 pps
Nội dung xem thử
Mô tả chi tiết
Visual C++ and MFC Fundamentals Table of Contents
© FunctionX, Inc. 1
an action creates a document and this document must reside somewhere.
Visual C++ and MFC
Programming
Table of Contents Visual C++ and MFC Fundamentals
2 © FunctionX, Inc.
Visual C++ and MFC Fundamentals Table of Contents
© FunctionX, Inc. 3
Table of Contents
TABLE OF FIGURES ...............................................................................................13
CHAPTER 1: INTRODUCTION TO MICROSOFT VISUAL C++...........15
1.1 The Microsoft Visual C++ Environment.....................................................16
1.1.1 Introduction..............................................................................................16
1.1.2 The Integrated Development Environment ........................................17
1.1.3 The Title Bar............................................................................................17
1.1.4 The Main Menu.......................................................................................18
1.1.5 The Toolbars............................................................................................21
1.1.6 The Studio Windows..............................................................................23
1.2 Floatable and Dockable Windows................................................................26
1.2.1 Description...............................................................................................26
1.3 Visual C++ Projects and Files.......................................................................27
1.3.1 Creating a New Project ..........................................................................27
1.3.2 Creating Files...........................................................................................28
1.3.3 Adding Existing Files to a Project .......................................................29
1.3.4 Adding Classes........................................................................................30
1.3.5 Opening Files...........................................................................................31
1.3.6 Opening Existing Projects.....................................................................33
1.4 Getting Help .....................................................................................................34
1.4.1 Online Help ..............................................................................................34
1.4.2 Other Help Types....................................................................................35
CHAPTER 2: INTRODUCTION TO MFC .......................................................37
2.1 The Microsoft Foundation Class Library ....................................................38
2.1.1 Introduction..............................................................................................38
2.1.2 CObject, the Ancestor............................................................................38
2.1.3 The Basic Application............................................................................39
2.2 Frames Fundamentals .....................................................................................42
2.2.1 Introduction..............................................................................................43
2.2.2 Reference to the Main Window............................................................44
2.2.3 Introduction to Macros...........................................................................47
2.2.4 Windows Styles.......................................................................................48
2.2.5 Windows Location..................................................................................51
2.2.6 Windows Size ..........................................................................................53
2.2.7 Windows Dimensions............................................................................54
2.2.8 Windows Parents....................................................................................57
2.3 Message Boxes.................................................................................................58
2.3.1 Definition .................................................................................................58
2.3.2 Message Box Creation ...........................................................................59
2.3.3 Message Box Implementation ..............................................................59
2.3.4 The Box’ Message..................................................................................60
2.3.5 The Message’ Title .................................................................................62
2.3.6 Message Box Options............................................................................63
2.3.7 The Message’s Return Value................................................................66
CHAPTER 3: WINDOWS RESOURCES ..........................................................69
Table of Contents Visual C++ and MFC Fundamentals
4 © FunctionX, Inc.
3.1 Introduction to Resources..............................................................................70
3.1.1 Introduction..............................................................................................70
3.1.2 Converting a Resource Identifier.........................................................71
3.2 Icons...................................................................................................................73
3.2.1 Icons Overview .......................................................................................73
3.2.2 Icons Design............................................................................................74
3.3 Menu Fundamentals........................................................................................80
3.3.1 Overview..................................................................................................80
3.3.2 The Main Menu.......................................................................................80
3.3.3 Main Menu Design.................................................................................81
3.4 Toolbars.............................................................................................................85
3.4.1 Overview..................................................................................................85
3.4.2 Creating a Toolbar..................................................................................85
3.5 Accelerators......................................................................................................85
3.5.1 Access Keys.............................................................................................86
3.5.2 Shortcuts...................................................................................................86
3.5.3 Accelerator Table ....................................................................................87
3.6 Version Information........................................................................................88
3.6.1 Overview..................................................................................................88
3.6.2 The Version Information Editor...........................................................88
3.7 Cursors ..............................................................................................................89
3.7.1 Overview..................................................................................................89
3.7.2 Creating and Using Cursors..................................................................90
3.8 The String Table ..............................................................................................92
3.8.1 Description...............................................................................................92
3.8.2 Creating and Using a String Table .......................................................92
3.9 Other Techniques of Creating Windows.....................................................94
3.9.1 Window Registration and Standard Resources..................................94
3.9.2 Window Registration and Custom Resources....................................95
3.9.3 Frame Loading ........................................................................................97
CHAPTER 4: MESSAGES AND EVENTS ......................................................101
4.1 Introduction to Messages ............................................................................ 102
4.1.1 Overview............................................................................................... 102
4.1.2 A Map of Messages............................................................................. 102
4.2 Windows Messages...................................................................................... 104
4.2.1 Window Creation................................................................................. 105
4.2.2 Window's Showing State.................................................................... 106
4.2.3 Window Activation ............................................................................. 108
4.2.4 Window Painting ................................................................................. 112
4.2.5 Window Sizing..................................................................................... 114
4.2.6 Window Moving.................................................................................. 116
4.2.7 Window Destruction ........................................................................... 119
4.3 Command Messages .................................................................................... 119
4.3.1 Definition .............................................................................................. 120
4.3.2 Creating a Command Message.......................................................... 120
4.4 Keyboard Messages ..................................................................................... 120
4.4.1 Introduction........................................................................................... 120
4.4.2 The Key Down Effect ......................................................................... 122
4.4.3 The Key Up Effect............................................................................... 124
4.5 Mouse Messages........................................................................................... 124
4.5.1 Introduction........................................................................................... 124
4.5.2 Mouse-Down Messages...................................................................... 124
4.5.3 The Mouse-Up Messages ................................................................... 127
4.5.4 The Double-Click Message................................................................ 129
Visual C++ and MFC Fundamentals Table of Contents
© FunctionX, Inc. 5
4.5.5 Mouse Moving..................................................................................... 130
4.6 Anytime Messages ....................................................................................... 130
4.6.1 Introduction........................................................................................... 130
4.6.2 Sending Messages................................................................................ 131
CHAPTER 5: THE DOCUMENT/VIEW ARCHITECTURE....................133
5.1 Overview of the Document/View Architecture....................................... 134
5.1.1 Introduction........................................................................................... 134
5.1.2 The View............................................................................................... 134
5.1.3 The Document ...................................................................................... 134
5.1.4 The Frame ............................................................................................. 134
5.1.5 The Document/View Approach......................................................... 135
5.2 The Single Document Interface (SDI)...................................................... 136
5.2.1 Overview............................................................................................... 136
5.2.2 Creating a Single Document Interface ............................................. 137
5.3 SDI Improvements ....................................................................................... 143
5.3.1 SDI Improvements: The Application ............................................... 143
5.3.2 SDI Improvements: The Document.................................................. 146
5.3.3 SDI Improvements: The Frame ......................................................... 150
5.3.4 SDI Improvements: The View........................................................... 151
5.4 The Multiple Document Interface (MDI)................................................. 151
5.4.1 Overview............................................................................................... 151
5.4.2 Creating a Multiple Document Interface ......................................... 154
5.4.3 The Visual C++ AppWizard .............................................................. 157
5.5 The AppWizard............................................................................................. 157
5.5.1 An SDI With AppWizard ................................................................... 158
5.5.2 An MDI With AppWizard .................................................................. 161
CHAPTER 6: THE GRAPHICAL DEVICE INTERFACE........................163
6.1 Introduction to the GDI ............................................................................... 164
6.1.1 The Device Context ............................................................................. 164
6.1.2 Grabbing the Device Context ............................................................ 164
6.2 The Process of Drawing .............................................................................. 165
6.2.1 Getting a Device Context ................................................................... 165
6.2.2 Starting a Device Context's Shape.................................................... 165
6.3 GDI Lines and Shapes ................................................................................. 167
6.3.1 Lines....................................................................................................... 167
6.3.2 Polylines................................................................................................ 170
6.3.3 Multiple Polylines................................................................................ 173
6.3.4 Polygons................................................................................................ 175
6.3.5 Multiple Polygons................................................................................ 176
6.3.6 Rectangles and Squares...................................................................... 177
6.3.7 A Rectangle With Edges..................................................................... 179
6.3.8 Ellipses and Circles ............................................................................. 180
6.3.9 Round Rectangles and Round Squares............................................ 183
6.3.10 ..Pies......................................................................................................... 184
6.3.11 ..Arcs........................................................................................................ 185
6.3.12 ..The Arc's Direction ............................................................................. 187
6.3.13 ..Angular Arcs........................................................................................ 190
6.3.14 ..Chords................................................................................................... 191
6.3.15 ..Bézier Curves....................................................................................... 192
CHAPTER 7: GDI ACCESSORIES AND TOOLS .......................................197
7.1 Colors ............................................................................................................. 198
Table of Contents Visual C++ and MFC Fundamentals
6 © FunctionX, Inc.
7.1.1 Overview............................................................................................... 198
7.1.2 The Color as a Data Type................................................................... 199
7.1.3 Color Palettes........................................................................................ 200
7.2 Drawing With Colors................................................................................... 201
7.2.1 Coloring a Pixel.................................................................................... 201
7.2.2 Rectangles With 3-D Effect ............................................................... 201
7.2.3 Drawing Text ........................................................................................ 202
7.3 Bitmaps........................................................................................................... 205
7.3.1 Introduction........................................................................................... 205
7.3.2 Bitmap Creation ................................................................................... 206
7.4 Fonts............................................................................................................... 209
7.4.1 Introduction........................................................................................... 209
7.4.2 Font Selection....................................................................................... 209
7.4.3 Font Creation ........................................................................................ 209
7.4.4 Font Retrieval....................................................................................... 215
7.5 Pens................................................................................................................. 216
7.5.1 Introduction........................................................................................... 216
7.5.2 The Fundamentals of a Pen ................................................................ 216
7.5.3 Creating and Selecting a Pen ............................................................. 216
7.5.4 Retrieving a Pen ................................................................................... 220
7.6 Brushes........................................................................................................... 220
7.6.1 Introduction........................................................................................... 220
7.6.2 Solid Brushes........................................................................................ 221
7.6.3 Hatched Brushes.................................................................................. 225
7.6.4 Patterned Brushes................................................................................ 227
7.6.5 Logical Brushes.................................................................................... 229
CHAPTER 8: GDI ORIENTATION AND TRANSFORMATIONS ........231
8.1 The Default Coordinate System................................................................. 232
8.1.1 Introduction........................................................................................... 232
8.1.2 Changing the Coordinate System...................................................... 234
8.2 The Mapping Modes.................................................................................... 238
8.2.1 Mapping Mode Choices...................................................................... 238
8.2.2 Unit and Coordinate Systems Options............................................. 243
CHAPTER 9: STRINGS .........................................................................................249
9.1 Fundamentals of Strings.............................................................................. 250
9.1.1 Null-Terminated Strings..................................................................... 250
9.1.2 The Standard string Class................................................................... 251
9.1.3 The Length of a String ........................................................................ 252
9.1.4 String Formatting................................................................................. 253
9.2 Operations of Strings................................................................................... 255
9.2.1 String Copy........................................................................................... 255
9.2.2 String Concatenation........................................................................... 257
9.3 The Characters of a String .......................................................................... 259
9.3.1 Access to Characters ........................................................................... 259
9.3.2 Sub-Strings............................................................................................ 260
9.4 The CString Class......................................................................................... 260
9.4.1 Introduction........................................................................................... 260
9.4.2 String Initialization.............................................................................. 261
9.4.3 The String and its Length................................................................... 261
9.5 Working with Individual Characters......................................................... 263
9.5.1 Character Indexing .............................................................................. 263
9.5.2 Character Insertion .............................................................................. 264
9.5.3 Finding a Character............................................................................. 264
Visual C++ and MFC Fundamentals Table of Contents
© FunctionX, Inc. 7
9.5.4 Character Identification ...................................................................... 265
9.5.5 Removing Characters.......................................................................... 265
9.6 Sub Strings..................................................................................................... 266
9.6.1 Introduction........................................................................................... 266
9.6.2 Finding a Sub String............................................................................ 267
9.6.3 Character and String Removal........................................................... 268
9.6.4 Replacing String Occurrences ........................................................... 268
9.6.5 String Formatting................................................................................. 269
9.7 Operations on Strings................................................................................... 270
9.7.1 About Constructing a String .............................................................. 270
9.7.2 String Assignment ............................................................................... 270
9.7.3 String Copy........................................................................................... 271
9.7.4 Strings and Their Cases...................................................................... 271
9.8 String Comparisons...................................................................................... 272
9.8.1 Case Sensitivity.................................................................................... 272
9.8.2 Case Insensitivity................................................................................. 273
CHAPTER 10: CHARACTERISTICS OF A WINDOW'S FRAME........277
10.1 Introduction to Win32 Library .................................................................. 278
10.1.1 ..Overview............................................................................................... 278
10.1.2 ..The Framework.................................................................................... 279
10.1.3 ..A Window's Instance.......................................................................... 280
10.1.4 ..The Command Line............................................................................. 281
10.1.5 ..Frame Display Options....................................................................... 282
10.1.6 ..Window Class Initialization .............................................................. 282
10.1.7 ..Window Registration .......................................................................... 291
10.2 Window Creation......................................................................................... 292
10.2.1 ..The Main Window .............................................................................. 292
10.2.2 ..The Window Class Name................................................................... 294
10.2.3 ..The Window Name ............................................................................. 296
10.2.4 ..Windows Styles................................................................................... 297
10.2.5 ..Window's Location and Size ............................................................. 298
10.2.6 ..Window's Parenting ............................................................................ 305
10.2.7 ..The Window's Menu........................................................................... 306
10.2.8 ..Window Display.................................................................................. 309
10.2.9 ..Considering Window's Messages ..................................................... 310
10.3 The Mini Frame Window........................................................................... 314
10.3.1 ..Introduction.......................................................................................... 314
10.3.2 ..Creation of a Miniframe Window..................................................... 314
CHAPTER 11: INTRODUCTION TO WINDOWS CONTROLS ............317
11.1 Controls Fundamentals ............................................................................... 318
11.1.1 ..Introduction.......................................................................................... 318
11.1.2 ..The Parent-Child Window Relationship.......................................... 320
11.2 Parent Controls............................................................................................. 321
11.2.1 ..Definition .............................................................................................. 321
11.2.2 ..Parent Windows Styles....................................................................... 321
11.3 Windows Controls....................................................................................... 321
11.3.1 ..Introduction.......................................................................................... 322
11.3.2 ..Control Creation Options................................................................... 322
11.3.3 ..The Control's Class Name .................................................................. 325
11.3.4 ..The Control's Window Name ............................................................ 327
11.4 Controls Styles and Common Properties................................................. 327
11.4.1 ..Childhood.............................................................................................. 327
11.4.2 ..Visibility................................................................................................ 328