Windows MFC Programming II Long Table of Contents

Windows MFC Programming II Long Table of Contents

Back to previous book promo page(With page numbers)

Chapter 1 A Primer on Fonts 1

Fonts Basic Terminology 1
Reviewing installed fonts using the Registry 6
Stock Fonts 7
Physical Devices and Their Metrics 9
Font Metrics 10
Case A: Simple Placement of Strings Using the Average Character Width 12
Case B: Text Processing Maintaining a Caret with Non-bold, Non-italic Fonts 13
Case C: Text Processing Maintaining a Caret with Any Font 15
Which Approach to Use 16
Functions to Draw Text to Screens and Printers 17
The DrawText Function 17
The TabbedTextOut Function 19
The TextOut Function 20
The ExtTextOut Function 20
Text Formatting Functions 21
Setting and Getting the Background Mode 22
Setting and Getting the Background Color 22
Setting and Getting the Text Color 23
Setting and Getting the Text Alignment Criteria 24
Using Text Justification 26
Intercharacter Spacing 28
The Sample Pgm01a 28
Design Units — an Alternative Measurement 32
Case D: Using Design Widths to Get the Best Printer Portability 33
Creating Fonts 34
The LOGFONT Structure 36
Font Matching or Realization 39
How to Specify Point Size 40
The Font Matching Process 41
Pgm01b — Font Mapping Illustration 44


Chapter 2 Working with Fonts

Using the Choose Fonts Common Dialog and Font Enumeration Functions To Make a Multi-line Edit Control for Text Display 59
Introduction 59
The Choose Fonts Common Dialog Box — CFontDialog 60
The CHOOSEFONT Structure Members 62
Windows Memory Allocation 63
File Handling Under Windows 65
File Handling Principles 66
Working With the Windows File Functions 67
The CFileDialog Implementation 71
Working with Multi-Line Edit Controls — CEdit 73
Editing Features Provided By CEdit Controls 75
Sample Program Illustrating the Use of the Choose Fonts Common Dialog Box and Using the CEdit Control — Pgm02a 75
Font Enumeration Functions 86
Older Windows NT Font Enumeration Functions 89
Sample Program Pgm02b 89
Constructing a Useful Font Enumeration Control Using CListCtrl 98


Chapter 3 Scaling Methods and Mapping Modes 108

Mapping Modes — Viewport Versus Window Coordinates 108
Altering the Origin Point 110
Altering the Extents or Scaling Ratio 112
Mapping Modes and Round-Off Errors 112
Calculating the Point Size and the Choose Fonts Common Dialog Box 114
Constructing a Ruler 116
Pgm03a And Text Display Methods 121
Using the System Registry 132


Chapter 4 Printing Basics 136

Basic Printing Methods 137
Printing Method 1: Printing a Mixed Page of Text and Graphics from the Screen Paint Function 137
Printing Method 2: Printing Multiple Page Documents or Printing Reports 137
Scaling the Page 137
Using Fonts 138
The Print Spooling Process 138
Pgm04a — Printing Method 1 — Using a Dual Purpose Render Function 139
Modifying Data in the Print Dialog Box 155
The Printing Sequence for MFC 156
Printing Directly Within PrintPage Not Via OnPaint 156
Printing Situation #1: (Pgm04b) 157
Creating a Program/Text Editor with Print Support — Pgm04b 158
Partial Listing of the PRINTDLG Structure 160


Chapter 5 A Review of Document-View Architecture and Print Preview 188

Introduction 188
The Application Design 189
Printing Situation #2: (Pgm05a) 195
The Doc-View Implementation of Pgm05a 195
Designing a Serializeable SalesData Class 195
MFC File Handling: the CFile Class 201
Other MFC Container Classes 203
The MFC Document-View Implementation 204
Creating the Document-View Shell Application 207
The CDocument Derived Class for Pgm05a 211
The Resource File for Pgm05a and the Application and Frame Windows 220
The Application Class — Pgm05aApp 224
System Registry Revisited 226
The Main Window Class — FrameWin 229
The Decorations — A Quick Review 233
The MFC Implementation of Decorations 234
Control Bar and Status Bar Construction 235
The CView Classes: AcmeView and AcmePlot 239
The Printing and Print Preview Process of AcmeView 259
The AcmePlot View Class 264
Using the Document-View in the Multiple Document Interface (MDI) — Pgm05b 274


Chapter 6 WYSIWYG — Word Wrap and Justification 279

Principles of WYSIWYG 279
Printing Situation #3: (Pgm06a) 281
The Document Class as the Repository for the Current Printer 281
Using a CScrollView Class 283
The Sample Program Pgm06a — a Text File WYSIWYG Viewer 286


Chapter 7 Printing Bitmap Images and Handling the Color Palette 331

Bitmaps versus DIBs 331
BitBlt 332
Creating Memory DCs 333
Important Notes 335
The Effect of User Display Changes 335
DIBs and Color Palettes 336
Handling Color — The Palettes 349
Methods to Display the DIB Image 354
The SetDIBitsToDevice Method 354
The StretchDIBits Approach 355
Two Methods of Constructing a Memory DC 355
Memory DC Method 1 For Converting DIBs into DDBs With Possible Color Loss Using SetDIBits 356
Memory DC Method 2 For Converting DIBs into DDBs With No Color Loss Using CreateDIBitmap 357
The DIB Section Method for Constructing Blazing Fast Memory DCs for Game Animation 358
Gray Scale Conversions 363
Guidelines for Printing Bitmaps with a Digression on Color Adjustments 365
Scaling DIBs for the Printer 367
Pgm07a — Printing BMP Files 368
Printing Situation #4: (Pgm07a) 370
The OptionsDlg Class 378
Pgm07a Design Considerations 380
Registry Implications 410


Chapter 8 — Database Report Printing 411

The External Access Database 411
The ODCB MFC Classes 415
Using the Application Wizard to Build a Beginning ODBC Shell 416
The ODBC Classes of Pgm08a 423
The CWinApp Class — Forcing a Printer into Landscape Mode 430
The Printing Operations of Pgm08a 431
Printing Situation #5: (Pgm08a) 431
The SalesView Class 432
Handling the Recordset — SalesView.cpp 434
Printing Operations of SalesView 444
Quick View and the Calculations — ODBC Look Up Tables 447
The Data Access Objects System (DAO) 458
The DOA Classes Used in Pgm08b 458
The Implementation of the Five CDaoRecordSet Classes in Pgm08b 460
Adding, Updating and Deleting Records; User-defined Data on the Clipboard 469
Accumulating the Total Sales By Category and Item — Using Five Record Sets — Dynamic Allocation of Two-dimensional Arrays 479
The Printing Operations of Pgm08b 485


Chapter 9 Using CTreeCtrl and CListCtrl Classes with Data From a DAO Database 496

The Access War Database 497
The Resources, Application, and Framewindow Classes of Pgm09a 504
The DOA Classes to Read the Database 509
The ChooseLandObjects Dialog 521
Details of the Tree and List Control Structures 524
Details of the CTreeCtrl Class 528
Details of the CListCtrl Class 532


Chapter 10 An In-depth Look At Control, Dialog and Tool Bars 552

The Basic Tool Bar — Using the CToolBar Class 553
Constructing a Floating Palette Box — Deriving from CToolBar 556
Handling the Status Bar 559
Dynamically Obtaining a Pointer to the Status Bar or the Main Tool Bar 560
The EditBar — Placing a Combo Box in a Tool Bar 561
Using CDialogBars 572
The OptionsBar 572
The MapLocalStatsBar — Displaying Information in CDialogBar Text Controls 576
Working With Private Ini Files 580
The MapControlBar — Combining Text and CBitmapButtons 583
Controlling the Initial Placement of the Three Dialog Bars 587
Saving and Restoring Tool Bar States — Using the System Registry 589
Saving and Restoring the Main Window Position 590
The MainFrame Class Coding 593
The GeoDoc and GeoView Classes 605
The Position Class 616


Chapter 11 Complex Document Handling 624

Multi-view Sample 1 624
Multi-View Sample 2 628
Multi-View Sample 3 632
Multi-View Sample 4 638
Handling Complex Documents 644
The Framework Actions to Open a Document File 651
Instructions for the Initial First Execution of Pgm11a 654
The Header Data Class 655
The Resource and Application Class of Pgm11a 658
The App Class and More Registry Functions 662
Registry Coding 666
The Main Color Palette 668
The MainFrame Class 672
The HeadDoc and HeadView Classes 676
The ControlDoc and ControlView Classes 687
The Off Screen Buffer Class 704
The GameDoc, GameFrame, GameView Classes 712
The GameView, PlayerView, and OtherView Classes 720
Back to the MainFrame Implementation and the OtherView 734


Chapter 12 Enhanced Metafiles and Printing 738

Printing Situation #6: (Pgm12a) 739
Program Pgm12a in Operation 740
Overall Design Principles for Constructing Enhanced Metafiles 747
The Use of Fonts in Enhanced Metafiles 749
Creating an Enhanced Metafile using the CMetaFileDC 751
The Rendering Process — Drawing on the Enhanced Metafile Surface — Pitfalls to Avoid 753
Coordinate Mappings and World Transformations 754
The Implementation of Pgm12a 757
The Pgm12aApp Class 758
The Document Class of Pgm12a — GraphDoc 762
The GraphView Class 798
Printing Enhanced Metafiles 806


Chapter 13 Introduction to the Internet Classes Making an FTP File Browser with Download Capabilities 808

Adding E-mail support to an application 808
The Internet MFC Classes 808
CInternetSession Details 809
The CFtpConnection Class 811
The CFtpFindFile Class 813
Pgm13a — FTP Browser and File Download Program 814
The Implementation of Pgm13a — FTP Browser 816
The View and CListCtrl Classes 819
The SiteList (CListCtrl) Class 820
The FTPView Class 823
Improvements to the Browser 836


Chapter 14 Fancy Controls, Property Pages, Owner-drawn Controls 838

Property Sheets or Tabbed Dialogs 838
MFC Property Sheet Pgm14a 841
Launching the CPropertySheet 851
Using Sliders and Spin Controls 856
MFC Implementation of Sliders and Spin Control Buttons 858
Owner-drawn Controls 863
Writing Replacement Controls Based on CWnd 874
Choose or Make a Folder, Progress Controls, Using the Recycle Bin, and Spawning Other Programs 881
Deriving a Class from CProgressCtrl 883
The ProgressBar Class 884
Deleting Files, the Recycle Bin, and Spawn 888
The _access Function 890
Spawning Other Programs 890
Choosing a Folder or Path Dialog 891


Chapter 15 ActiveX Controls 916

Writing an ActiveX Control Using the MFC — Pgm15a — Stoplight Control 921
Using the Stoplight Control — Pgm15b 934


Chapter 16 Writing DLLs 942

The Four Calling Conventions Used in Windows Programming 942
The __cdecl Convention 946
The __stdcall Convention 947
Stack Frames and Register EBP 949
Handling the this Pointer in C++ Classes — __thiscall Convention 952
The __fastcall Convention 953
Obsolete Calling Conventions 954
Basic DLL Theory 954
DLL Loading 956
Making MFC DLLs 957
Pgm16DLL and Pgm16b Client Sample Program 958


Chapter 17 Multithreading 961

C Functions for Multithreading, a Quick Glance 963
The MFC Multithreading Functions 963
Pgm17a’s Worker Thread Watches for Changes to Files in a Folder 965
Launching and Coding of the Thread 970
MFC User-Interface Threads 975
MFC Synchronizations 975
Back to previous book promo page

Share Button