Table of Contents
1. The Spirit of Basic
Language Purification
While/Wend
Gosub/Return
Goto
Exiting from Procedures
Let
Rem
Option Base and Zero-Based Arrays
For Next Loops
Data Types
A Short History of Basic Types
Choosing a Data Style
Visibility and Lifetime of Variables
Naming Convention
Basic Hungarian
Efficient Code
Compiled Code--Not a Panacea
P-Code Versus Native Code
Static Versus Dynamic-Link Libraries
What You Don't Know Hurts You
Examining Code
The Time It Application
Timing in Basic
Short-Circuiting Logical Expressions: A Timing Example
Assert Yourself
Assert the Basic Way
An Assertion Implementation
Other Debug Messages
Setting Debug Constants
What to Assert
2. The Second Level of Basic Enlightenment
Never Write Another Damn Declare Statement
What Is a Type Library?
Rolling Your Own
Calling the Windows API from Basic
Anatomy of a Basic Procedure Call
Anatomy of a DLL Procedure Call
The API Contract
Integer Parameters
Pointers to Integers
Large Integers and Currency
User-Defined Types
Arrays
Typeless Variables
Dealing with Strings
Strings Inside Out
Sending Strings to the Windows API
Passing Null Pointers
Wrapping String Functions
Getting Strings from the Windows API
Wrap It Up
Unicode Versus Basic
What Is Unicode?
Unicode API Functions
Dealing with Pointers
Bring Your Hatchet
Fixed-Length Strings in UDTs
Variable-Length Strings in UDTs
Other Pointers in UDTs
Typeless Strings
The Ultimate Hack: Procedure Pointers
Limits of Procedure Pointers
Enumerating Stuff
Crash Testing
Putting Procedure Pointers in Variables
Strings in Callback Procedures
FindAnyWindow
3. An Object Way of Basic
The Three Pillars
Encapsulation
Reusability
Polymorphism
Object-Oriented Anyway
Object-Oriented Programming, Visual Basic Style
Types
Declaring Class Instances
Initializing Objects
Declarations with New
Procedures Versus Methods
More About Properties
Where Do Objects Come From?
Objects from CreateObject
New Objects from Type Libraries
ActiveX Control Objects
Form Objects
Class Objects
Dual Interfaces and IDispatch
First Class: CDrive
Drive Design
Test Drive
Class Diagrams
Implementing CDrive
Other Class Features
Static Members
Friend Members
Events
The Form Class
Polymorphism and Interfaces
Interfaces
Polymorphic Filters
Variations on Implements and Polymorphism
4. Collecting Objects
A List of Link Objects
A Link Class
Using a List Class
Using a List Iterator Class
Implementing a List Class
Implementing a List Iterator
Back to CList for Iterators
Vectors as Resizeable Arrays
Using Vectors
CVector Implementation
Stacking Objects
Using a Stack
Implementing a Stack
The Collection Class
Collections 101--Data Storage
Collections 201--Indexing
What Makes a Collection Walk?
Delegating a Collection
Creating a Collection
Variant Iterators
Enumerating Variants
Collection Wizard to the Rescue
5. Functional Programming's Last Gasp
Functional DLLs
The VBCore Component
Creating Global Procedures
Creating Global Objects
Developing for the Real World
An Imaginary Real Project
Developing Real Imaginary Projects
What's Wrong with That?
What Can You Do?
When to Raise Errors
How to Raise Errors
Turning API Errors into Basic Errors
Handling Errors in the Client
Code Review
The Program That Wouldn't Die
StrSpan and StrBreak
GetToken
Trouble in Paradise
Coding C in Basic
Fastest Versus Safest
Fixing the Windows API
GetFullPathName
SearchPath
GetTempPath and GetTempFileName
Hammering Bits
Five Low Words
Shifting Bits
Reading and Writing Blobs
Sorting, Shuffling, and Searching
Recursive QuickSort
Iterative QuickSort
Sorting Different Types
Comparing and Swapping
The Helper Class Hack
Shuffling
Binary Search
6. Taking Control of Windows
WinWatch
Elements of WinWatch
All About Windows
The Window Class
Visual Basic Wrappers for Windows Functions
Iterating Through Windows
All About Programs
System-Specific API Functions
Processes, Modules, Top Windows, Instances, and
Threads
More About Handles and Process IDs
Handling Multiple Instances
Sending and Receiving Messages
Sending Messages
Receiving Messages
Encapsulating Message Traps
7. Painting Pictures
Windows to Basic and Back Again
Device Contexts and Canvas Objects
Borrowing Device Context Handles
Screen Capability
Two Ways of Drawing
The Basic Way of Drawing
The Windows Way of Drawing
Basic Windows Painting
Picture Objects
The Windows Way of Painting
A Word About Blitting
BitBlt Versus PaintPicture
StretchBlt Versus PaintPicture
The Bottom Line on PaintPicture
All About ROPs
Blitting Images onto Backgrounds
Creating Masks
Animating Pictures
The Glass Picture
Using CPictureGlass
Inside the Glass
Cleaning Up Glass
Moving a Glass Object
Other Properties and Methods
The XPictureGlass Control
Deal Me In
Card Functions
Timer Loops
No Timer Control
Animating Card Backs
8. A Handle on Data
Three Approaches to Data
The Data Initialization Problem
Initializing Local Variables
Initializing Form Variables
Initializing Class Objects and Internal Variables
Initializing Standard Module Variables
Using Your Own Resources
Creating a Resource Script
Anatomy of a Resource Block
Compiling Resource Scripts
Using Other People's Resources
Stealing Your Own Resources
Finding Resources
Using Resources the Windows Way
Using Data Resources
Using Bitmaps
Icons with an Attitude
Using Cursors
Using String Resources
Using Sounds
Using Version Data
Using Other Resources
Creating Your Own Resources
9. Writing Code for the Ages
Edwina and the XEditor Control
The XEditor Control
Edwina's Interface
The XEditor Control
Initialize It
Name It Right
Pass It On
Replace It
XEditor Extends RichTextBox
The Dirty Bit
Text and Rich Text Modes
Undo Methods and Properties
Status Methods and Properties
Common Dialog Extensions
The Windows/Basic Way of Implementing Common
Dialogs
Using Common Dialogs
Implementing VBGetOpenFileName
Find and Replace Extensions
Designing Find and Replace Dialog Boxes
Implementing the FSearch Form
The XDropStack Control
Using a Drop Stack
XDropStack Calling XEditor
The Keyboard Object
Using the Keyboard Object
Controlling the RichTextBox Insert State
The CKeyboard Class Implementation
10. COM Behind the Curtain
The COM Vision
COM Terminology
COM From All Angles
The Prime Number Server
The Sieve Client
A Functional Way of Prime Numbers
An Object-Oriented Way of Prime Numbers
The ActiveX DLL Way of Prime Numbers
The ActiveX EXE Way of Prime Numbers
The XSieve Control
Behind the Scenes at the COM Factory
The Name of the Class
What You Don't Know
Reference Counting and Not Reference Counting
COM RAQs
Interfaces Everywhere
IShellLink--Shortcuts the Long Way
Interface Type Libraries
From CShellLink to CShortcut
The CShortcut Class
Registry Blues
Registry Tools
Registry Nodes and Items
What to Write Where
COM and the Registry
The Windows Programs in the Registry
11. Stir-Fry
Everything You Always Wanted to Know About...
Using the CAbout Class
A Class Wrapping a Form
A Form Wrapped by a Class
Animating
The CSystem Class and the System Object
Sorting List Boxes
Collection Methods and Properties
Finding Items
Sorted Collections
Other People's Programs
Using Shell
Executive Privilege
Character-Mode Sentenced to Execution
The Executive's Mom
Using ShellExecute
Interprocess Communication
Shared Memory Through Memory-Mapped Files
Threads and Synchronization
Where Angels Fear to Thread
The Next Thread
File Notification
The Client Side of File Notification
The Server Side of File Notification
The New Look and Feel
The 3-D Feel
System Colors and Sizes
More Interface Stuff
Grid Boxes
The CColorPicker Class
The XColorPicker Control
Bit Editors
What Is a File?
File Dates and Times
Politically Correct File Operations
Getting File Interface Information
Walking Through Files
Walking Through Folders
Famous Explorers and Common Controls
The ImageList Control
The Toolbar and StatusBar Controls
The TreeView Control
The ListView Control
Index
|