| Introduction | xvii |
| 1 Console Thyself | 1 |
| The Return of the Console | 2 |
| Anatomy of a Program | 6 |
| .NET Namespaces | 7 |
| String Formatting | 9 |
| Visual Basic Data Types | 11 |
| The Leap to Objects | 16 |
| Shared Methods | 21 |
| Exception Handling | 23 |
| Throwing Exceptions | 25 |
| Getting and Setting Properties | 27 |
| Constructors | 31 |
| Instances and Inheritance | 34 |
| A Bigger Picture | 38 |
| Naming Conventions | 39 |
| Beyond the Console | 40 |
| 2 Hello, Windows Forms | 43 |
| The Message Box | 45 |
| The Form | 51 |
| Showing the Form | 53 |
| It's an Application and We Want to Run It | 55 |
| Variations on a Theme | 57 |
| Form Properties | 58 |
| Event-Driven Input | 60 |
| Handling the Paint Event | 62 |
| Displaying Text | 66 |
| The Paint Event Is Special! | 71 |
| Multiple Forms, Multiple Handlers | 71 |
| Inheriting Forms | 74 |
| The OnPaint Method | 76 |
| Is the Module Necessary? | 77 |
| Events and "On" Methods | 79 |
| 3 Essential Structures | 85 |
| Classes and Structures | 86 |
| Two-Dimensional Coordinate Points | 87 |
| Arrays of Points | 89 |
| The Size Structure | 90 |
| The Float Versions | 91 |
| A Rectangle Is a Point and a Size | 93 |
| Rectangle Properties and Methods | 94 |
| A Nice-Sized Form | 97 |
| The Form and the Client | 99 |
| Point Conversions | 103 |
| The Color Structure | 104 |
| The 141 Color Names | 105 |
| Pens and Brushes | 107 |
| System Colors | 108 |
| The Known Colors | 112 |
| What to Use? | 112 |
| Getting a Feel for Repaints | 113 |
| Centering Hello World | 116 |
| Measuring the String | 120 |
| Text in a Rectangle | 122 |
| 4 An Exercise in Text Output | 127 |
| System Information | 127 |
| Spacing Lines of Text | 128 |
| Property Values | 129 |
| Formatting into Columns | 131 |
| Everything Is an Object | 133 |
| Listing the System Information | 137 |
| Windows Forms and Scroll Bars | 140 |
| Scrolling a Panel Control | 141 |
| The Heritage of ScrollableControl | 145 |
| Scrolling Without Controls | 146 |
| Actual Numbers | 149 |
| Keeping It Green | 150 |
| Don't Be a Pig | 153 |
| Reflecting on the Future | 155 |
| 5 Lines, Curves, and Area Fills | 161 |
| How to Get a Graphics Object | 162 |
| Pens, Briefly | 163 |
| Straight Lines | 165 |
| An Introduction to Printing | 167 |
| Properties and State | 173 |
| Anti-Aliasing | 174 |
| Multiple Connected Lines | 177 |
| Curves and Parametric Equations | 182 |
| The Ubiquitous Rectangle | 185 |
| Generalized Polygons | 188 |
| Easier Ellipses | 188 |
| Arcs and Pies | 190 |
| Filling Rectangles, Ellipses, and Pies | 197 |
| Off by 1 | 199 |
| Polygons and the Filling Mode | 200 |
| 6 Tapping into the Keyboard | 205 |
| Ignoring the Keyboard | 205 |
| Who's Got the Focus? | 206 |
| Keys and Characters | 207 |
| Keys Down and Keys Up | 209 |
| The Keys Enumeration | 210 |
| Testing the Modifier Keys | 221 |
| Reality Check | 222 |
| A Keyboard Interface for SysInfo | 223 |
| KeyPress for Characters | 225 |
| Control Characters | 225 |
| Looking at the Keys | 226 |
| Invoking the Win32 API | 231 |
| Handling Input from Foreign Keyboards | 233 |
| Input Focus | 237 |
| The Missing Caret | 238 |
| Echoing Key Characters | 242 |
| Right-to-Left Problems | 246 |
| 7 Pages and Transforms | 249 |
| Device Independence Through Text | 249 |
| How Much Is That in Real Money? | 250 |
| Dots Per Inch | 253 |
| What's with the Printer? | 254 |
| Manual Conversions | 256 |
| Page Units and Page Scale | 258 |
| Pen Widths | 263 |
| Page Transforms | 266 |
| Saving the Graphics State | 267 |
| Metrical Dimensions | 268 |
| Arbitrary Coordinates | 272 |
| What You Can't Do | 275 |
| Hello, World Transform | 276 |
| The Big Picture | 281 |
| Linear Transforms | 282 |
| Introducing Matrixes | 285 |
| The Matrix Class | 286 |
| Shear and Shear Alike | 289 |
| Combining Transforms | 291 |
| 8 Taming the Mouse | 295 |
| The Dark Side of the Mouse | 296 |
| Ignoring the Mouse | 297 |
| Some Quick Definitions | 297 |
| Information About the Mouse | 298 |
| The Mouse Wheel | 299 |
| The Four Basic Mouse Events | 300 |
| Doing the Wheel | 303 |
| Mouse Movement | 307 |
| Tracking and Capturing the Mouse | 309 |
| Adventures in Tracking | 312 |
| Clicks and Double-Clicks | 322 |
| Mouse-Related Properties | 323 |
| Entering, Leaving, Hovering | 324 |
| The Mouse Cursor | 325 |
| An Exercise in Hit-Testing | 334 |
| Adding a Keyboard Interface | 336 |
| Putting the Children to Work | 338 |
| Hit-Testing Text | 343 |
| Scribbling with the Mouse | 345 |
| 9 Text and Fonts | 351 |
| Fonts Under Windows | 351 |
| Talking Type | 352 |
| Font Heights and Line Spacing | 354 |
| Default Fonts | 356 |
| Variation on a Font | 357 |
| Creating Fonts by Name | 359 |
| A Point Size by Any Other Name. | 364 |
| Clash of the Units | 369 |
| Font Properties and Methods | 371 |
| New Fonts from FontFamily | 378 |
| Understanding the Design Metrics | 380 |
| Arrays of Font Families | 385 |
| Font Collections | 391 |
| Variations on DrawString | 392 |
| Anti-Aliased Text | 394 |
| Measuring the String | 396 |
| The StringFormat Options | 398 |
| Grid Fitting and Text Fitting | 400 |
| Horizontal and Vertical Alignment | 403 |
| The Hotkey Display | 408 |
| A Clip and a Trim | 410 |
| Start a Tab | 417 |
| 10 The Timer and Time | 425 |
| The Timer Class | 426 |
| The DateTime Structure | 430 |
| Local Time and Universal Time | 432 |
| The Tick Count | 436 |
| Calendars Around the World | 439 |
| A Readable Rendition | 441 |
| A Simple Culture-Specific Clock | 447 |
| The Retro Look | 452 |
| An Analog Clock | 457 |
| A Little Puzzle Called Jeu de Taquin | 463 |
| 11 Images and Bitmaps | 469 |
| Bitmap Support Overview | 471 |
| Bitmap File Formats | 472 |
| Loading and Drawing | 477 |
| Image Information | 482 |
| Rendering the Image | 487 |
| Fitting to a Rectangle | 490 |
| Rotate and Shear | 495 |
| Displaying Part of the Image | 497 |
| Drawing on the Image | 502 |
| More on the Image Class | 507 |
| The Bitmap Class | 510 |
| Hello World with a Bitmap | 513 |
| The Shadow Bitmap | 514 |
| Binary Resources | 517 |
| Animation | 521 |
| The Image List | 528 |
| The Picture Box | 531 |
| 12 Buttons and Labels and Scrolls (Oh My!) | 535 |
| Buttons and Clicks | 536 |
| Keyboard and Mouse | 540 |
| Control Issues | 541 |
| Deeper into Buttons | 542 |
| Appearance and Alignment | 546 |
| Buttons with Bitmaps | 549 |
| Multiple Handlers or One? | 552 |
| Drawing Your Own Buttons | 552 |
| Dropping Anchor | 557 |
| Dock Around the Clock | 561 |
| Children of the Form | 564 |
| Z-Order | 567 |
| The Check Box | 569 |
| The Three-State Alternative | 573 |
| The Label Control | 574 |
| Tab Stops and Tab Order | 577 |
| Identifying the Controls | 578 |
| The Auto-Scale Option | 581 |
| A Hexadecimal Calculator | 587 |
| Radio Buttons and Group Boxes | 592 |
| Scroll Bars | 596 |
| The Track Bar Alternative | 604 |
| 13 Béziers and Other Splines | 611 |
| The Bézier Spline in Practice | 612 |
| A More Stylish Clock | 617 |
| Collinear Béziers | 619 |
| Circles and Arcs with Béziers | 621 |
| Bézier Art | 624 |
| The Mathematical Derivation | 626 |
| The Canonical Spline | 630 |
| Canonical Curve Derivation | 638 |
| 14 Menus | 641 |
| Menus and Menu Items | 642 |
| Menu Shortcut Keys | 645 |
| Your First Menu | 647 |
| Unconventional Menus | 651 |
| MenuItem Properties and Event | 653 |
| Checking the Items | 655 |
| Working with Context Menus | 659 |
| The Menu Item Collection | 663 |
| The Standard Menu (A Proposal) | 669 |
| The Owner-Draw Option | 674 |
| 15 Paths, Regions, and Clipping | 685 |
| A Problem and Its Solution | 685 |
| The Path, More Formally | 691 |
| Creating the Path | 694 |
| Rendering the Path | 698 |
| Path Transforms | 702 |
| Other Path Modifications | 705 |
| Clipping with Paths | 712 |
| Clipping Bitmaps | 717 |
| Regions and Clipping | 721 |
| 16 Dialog Boxes | 725 |
| Your First Modal Dialog Box | 726 |
| Modal Dialog Box Termination | 731 |
| Accept and Cancel | 733 |
| Screen Location | 734 |
| The About Box | 738 |
| Defining Properties in Dialog Boxes | 742 |
| Implementing an Apply Button | 747 |
| The Modeless Dialog Box | 751 |
| The Common Dialog Boxes | 755 |
| Choosing Fonts and Colors | 756 |
| Using the Windows Registry | 763 |
| The Open File Dialog Box | 768 |
| The Save File Dialog Box | 776 |
| 17 Brushes and Pens | 781 |
| Filling in Solid Colors | 782 |
| Hatch Brushes | 782 |
| The Rendering Origin | 792 |
| Texture Brushes | 795 |
| Linear Gradient Brushes | 800 |
| Path Gradient Brushes | 810 |
| Tiling the Brush | 814 |
| Pens Can Be Brushes Too | 822 |
| A Dash of Style | 826 |
| Caps and Joins | 829 |
| 18 Edit, List, and Spin | 837 |
| Single-Line Text Boxes | 837 |
| Multiline Text Boxes | 842 |
| Cloning Notepad | 845 |
| The Notepad Clone with File I/O | 851 |
| Notepad Clone Continued | 860 |
| Special-Purpose Text Boxes | 875 |
| The Rich Text Box | 876 |
| ToolTips | 876 |
| The List Box | 884 |
| List Box + Text Box = Combo Box | 891 |
| Up-Down Controls | 897 |
| 19 Font Fun | 909 |
| Getting Started | 909 |
| Brushed Text | 911 |
| Font Transforms | 919 |
| Text and Paths | 930 |
| Nonlinear Transforms | 944 |
| 20 Toolbars and Status Bars | 951 |
| The Basic Status Bar | 952 |
| The Status Bar and Auto-Scroll | 954 |
| Status Bar Panels | 957 |
| StatusBarPanel Properties | 959 |
| Menu Help | 963 |
| The Basic Toolbar | 970 |
| Toolbar Variations | 974 |
| Toolbar Events | 978 |
| Toolbar Styles | 983 |
| 21 Printing | 993 |
| Printers and Their Settings | 994 |
| Page Settings | 1002 |
| Defining a Document | 1006 |
| Handling PrintDocument Events | 1008 |
| The Page Dimensions | 1014 |
| The Print Controller | 1018 |
| Using the Standard Print Dialog Box | 1023 |
| Setting Up the Page | 1027 |
| Print Preview | 1031 |
| 22 Tree View and List View | 1039 |
| Splitsville | 1039 |
| Tree Views and Tree Nodes | 1055 |
| Images in Tree Views | 1059 |
| Tree View Events | 1060 |
| Node Navigation | 1062 |
| The Directory Tree | 1065 |
| Displaying Images | 1071 |
| List View Basics | 1078 |
| List View Events | 1086 |
| 23 Metafiles | 1095 |
| Loading and Rendering Existing Metafiles | 1096 |
| Metafile Sizes and Rendering | 1098 |
| Converting Metafiles to Bitmaps | 1106 |
| Creating New Metafiles | 1108 |
| The Metafile Boundary Rectangle | 1116 |
| Metafiles and the Page Transform | 1119 |
| The Metafile Type | 1122 |
| Enumerating the Metafile | 1125 |
| 24 Clip, Drag, and Drop | 1133 |
| Items and Formats | 1134 |
| The Tiny (But Powerful) Clipboard Class | 1134 |
| Getting Objects from the Clipboard | 1136 |
| Clipboard Data Formats | 1145 |
| Clipboard Viewers | 1155 |
| Setting Multiple Clipboard Formats | 1164 |
| Drag and Drop | 1169 |
| APPENDIX A Files and Streams | 1179 |
| The Most Essential File I/O Class | 1179 |
| FileStream Properties and Methods | 1182 |
| The Problem with FileStream | 1186 |
| Other Stream Classes | 1187 |
| Reading and Writing Text | 1188 |
| Binary File I/O | 1197 |
| The Environment Class | 1200 |
| File and Path Name Parsing | 1202 |
| Parallel Classes | 1204 |
| Working with Directories | 1206 |
| File Manipulation and Information | 1212 |
| APPENDIX B Math Class | 1217 |
| Numeric Types | 1217 |
| Checking Integer Overflow | 1218 |
| The Decimal Type | 1219 |
| Floating-Point Infinity and NaNs | 1222 |
| The Math Class | 1224 |
| Floating-Point Remainders | 1227 |
| Powers and Logarithms | 1227 |
| Trigonometric Functions | 1228 |
| APPENDIX C String Theory | 1233 |
| The Char Type | 1235 |
| String Constructors and Properties | 1237 |
| Copying Strings | 1239 |
| Converting Strings | 1241 |
| Concatenating Strings | 1241 |
| Comparing Strings | 1243 |
| Searching the String | 1247 |
| Trimming and Padding | 1249 |
| String Manipulation | 1251 |
| Formatting Strings | 1252 |
| Array Sorting and Searching | 1252 |
| The StringBuilder Class | 1255 |
| INDEX | 1259 |