Preface

Bear with me as I quote from the preface of James Coplien's Advanced C++ Programming Styles and Idioms:

Not everything you need to know about a product is described in the owner's manual. Before the arrival of our first child, my wife and I were admonished by a friend that no book, and no training, could completely prepare us for the art of parenting. We must of course learn minimal, essential skills. But the interesting, challenging, and rewarding aspects of raising a child go beyond this basic knowledge. For example, no book or "owner's manual" will help you understand why your three-year-old daughter rubs toothpaste into your one-year-old's hair, or why your children hang their socks on the refrigerator.

The same is true of programming languages. Programming language syntax shapes our thinking to a degree, but what we learn in the "owner's manual" about syntax alone only gets us started. Most of what guides the structure of our programs, and therefore of the systems we build, is the styles and idioms we adopt to express design concepts.

Coplien describes how styles and idioms differ from regular programming as a whole, but the critical point of his introduction is already clear--that no owner's manual or basic guide to Object Windows Language (OWL) is going to give you the rest of the story. There's a lot more to OWL than just application objects, window objects, and dialog objects.

It serves as a source of constant amazement to me that books on the market (not just OWL books--pick any subject you like) promise to bring a potential reader from ignorant to expert within two covers. I don't know about anybody else, but none of the experts I've ever spoken with became that way by studying a single book. Instead, it's a process, starting, perhaps, with a single book, but progressing into much, much more. There's an old American folk tale that speaks of this:

A famous pianist was giving a concert in Carnegie Hall. His form and style were excellent, and the crowd applauded enthusiastically. Afterward, at the reception for the pianist, a breathless fan approached him and said, "Sir? I just want to tell you that you played some of the best piano music I've ever heard."

"Why, thank you."

The young man continued. "I'd give my life to be able to play like that."

The pianist smiled, and said quietly, "I did, my friend. I did."

I don't promise to bring you up to expert status just by reading between these two covers. I do promise, however, to show you some of the tricks that the other OWL experts use; tricks to bring their applications greater power, greater features, and greater flexibility. I promise to show you how OWL can be used more efficiently. Most of all, I promise to show you how OWL can already perform a lot of those functions that your users are clamoring for, but you haven't got a clue how to do.

Why this book?

The Borland documentation leaves much to be desired, not because it doesn't cover the subjects it covers well, but because there's a lot that the documentation doesn't cover. The Borland documentation has not kept up with the growth of OWL. To compound matters, all of the after-market books on Borland's C++ product discuss the compiler, some C++, and perhaps a bit of OWL. This book is designed to help you get a firm grip on all aspects of OWL, from the underlying libraries, to the high-level abstractions used to make tasks like docking toolbars easier.

OWL 5.0 has almost doubled the size of OWL 2.5 (not counting the ObjectComponents Framework (OCF) or the Borland International Data structures (BIDS) components), and has easily more than doubled the capabilities you now have before you. It brings to you all of the new controls spawned by Windows95's CommonControls dynamic link libraries (DLL), like RichEdit and ImageList controls, as well as introducing new user-interface components of its own, like the TRollDialog and the TPickList . Common document-centered capabilities have been thrown in too, like the TRecentFiles mixin class, as well as dockable toolbars.

More importantly, OWL 5.0 has not forgotten its roots, nor the fact that not everyone is moving to Windows95 or has the hardware to effectively run NT. Much of the OWL capabilities, those that aren't restricted to Win32 (like preemptive multithreading or Unicode), are either graciously handled or implemented by hand for 16-bit Windows.

OWL 5.0 has capabilities that reach far beyond the imagination. OWL 5.0 has all of the common user-interface idioms your customers and clients and bosses and coworkers are demanding, and has provided them in the same clean, object-oriented style introduced with OWL 2.0. Almost all of your OWL 2.0 code can port over with no recoding necessary (although you may get spurious messages in your Interactive Development Environment (IDE) message window when building), and you can still maintain a single code base for 16-bit Windows, WindowsNT and Windows95.

One of the issues we'll be running into again and again is that despite C++ being viewed sometimes as "a better C," C++ and Windows programming do not get along very well. Certain features which provide power in C++ can in turn create a hassle for Windows, and vice versa. As these issues come up, we'll examine them and see if there are effective and easy workarounds. Windows callbacks versus C++ member functions, C++ name-mangling, runtime dynamic linking, and C++ member functions make the C++ Windows programmer's life a living Heck.

All of this combines to produce a single, inescapable conclusion: OWL programming is not as straightforward as we would like. Combine this with the complex interactions that C++ can provide, and understanding OWL and everything that can happen in your OWL applications can be a daunting task. This book, and its companion volume, Core OWL 5.0, should help reduce some of that stress.

What you should know to use this book effectively

I'm assuming a few things before we begin:

You know some OWL

OWL 5.0, taking away all the new stuff, is (aside from some bug fixes) the same as OWL 2.x. If you have a good background in OWL 2.x, you should be OK here. If you still think OWL is a type of bird that flies around at night and hoots about cleaning up after yourself while camping, put this book back on the shelf.

If you're not comfortable with OWL, you may want to take a look at one of the more beginning-level OWL texts, such as Teach Yourself OWL 5.0 in 21 Days (Arnush, SAMS Publishing).

You know some C++

You shouldn't have to reach for your favorite C++ book if I start talking about multiple inheritance and virtual base classes. Some of the template usage in OWL may be a bit above the average C++ programmer, especially in some of the new stuff added to TModule and company, but anywhere OWL has taken advantage of the new C++, I'll point it out and make sure to explain what's going on and why. For those of you who don't read the American National Standards Institute (ANSI) draft standard document each week, there's a brief review of the new changes to C++ in the last year or two.

If you're not comfortable with C++, I'd recommend you take a look at a couple of C++ books before diving into this one. Some of my favorites are listed in the bibliography. These books are not C++ tutorials; those of you who count yourself a C++ beginner, consider looking at any of the myriad beginner level books available.

You know some Windows/Win32 API

You should be at least passingly familiar with the Windows Application Program Interface (API) (16- or 32-bit). It isn't required, but let me stress that, in my experience, the best OWL programmers are those who are equally familiar with OWL and the API. There are some times, especially during some intricate debugging, when knowledge of what the API is doing can be instructive in finding your bug.

If you're not familiar with the Win16 or Win32 API, I recommend a basic Windows programming book, like Charles Petzold's Programming Windows 3.1, or Jeffrey Richter's Advanced Windows and Windows 95: A Developer's Guide. These books talk API, but the concepts can easily be brought into OWL.