Table of Contents

preface xiii
about this book xvii
acknowledgments xxiii
A brief recap of OWL 1
HELLO.EXE 2
HELLO as a C/SDK app 3
WinMain 4, The message loop 6, WndProc 7
HELLO as an OWL app 8
OwlMain 9, TOWLHelloApp 9, TOWLHelloWindow 10, What HELLO.CPP provides without asking 10
Where'd everything go? 11
The wonders of encapsulation 11, The power of inheritance 13
The fundamental components of OWL 15
TWindow 15, TFrameWindow 15, TDialog 16, TApplication and TModule 16
Where we go from here 17
Begin at the beginning 19
Process space 20
The Win16 concept of the task, the module, and the instance 22, The Win32 concept of the module and the instance 24, How this affects your code 25
TModule 27
TModule 28
A brief DLL primer 28, Calling the entry point 29, TModule for user-defined DLLs 32, Stepping back to pure C++ 36, No guarantees 38, TModule API overview 40, Initialization not exclusive 42
Sharing data among Win32 DLLs 45
The linking game 46, TDllLoader 48
TModuleProc 51
Import Libraries 54, TModuleVersionInfo 58, A comprehensive TModule example: TOWLEXTDll 61
The heart of your EXE 65
TApplication 66
There's more to TApplication than just a base class: an API overview 69, The littlest OWL (OwlMain as a real main) 72, GetApplicationObject 73, TAppDictionary 73, Win32 WinMain versus main: have your IOStreams and GUI too 75, Example: TSimpleApplication 79, Problems 80, Example: TDialogApplication 85, Dialog-as-a-main-window, revisited 87, A simple application, revisited 88, Applications with no main windows (hidden apps) 90, Applications with only an icon (iconized apps) 90, Applications with more than one main window 91, Simulating hPrevInstance under Win32 92
Conclusion 93
Through the maze: OWL message handling 95
Messages and message queues 96
C/SDK window event handling 100, Why we want to get away from that 101, Class: a WNDCLASS, by another language 103, Diary of a traveling WM_ message 104
Retrieving the message 104
Special case handling 107
Finding object from widget 109
Finding out what this is 109, A first approach: storing this in window properties 110, A second approach: the MFC way--using collections 112, A third approach: the OWL way--using thunks 113
Dispatching the event 115
Passing the current event 117
Routing the event 119
A first approach: lots of virtuals 119, A second approach: message maps and TEventHandler 120, Expanding the macros 123
Handling the event--cracking the generic parameters 127
Message map macros you may not know about 130, Message map macros the Borland manuals don't seem to know about 132
From the fat into the fire: OWL event handling 135
Commands, controls, and enablers 136
Commands 136, Controls 137, Enablers 138
Default processing 140
Other message info you may need 144
ChildBroadcastMessage 144, DefWindowProc 145, ForwardMessage 145, PostMessage 146, SendDlgItemMessage 146, SendMessage 146
Idle-time processing 146
Conclusion 148
Controls 151
C/SDK controls: a recap 154
OWL's controls 157
Borland's custom controls 159, Common controls and OWL emulation 161, Type of control is the key 163, TUpDown 165, TUpDown's buddy controls 169, TGauge 169, TSlider 173, TCheckList 176, TGlyphButton 178, TGlyphButton to the rescue 179, THotKey 180, TAnimateCtrl 181, TDragList 181, TImageList and TCelArray 181, TTabControl and TNoteTab 181, Can be owner-drawn 184, TPropertySheet and TPropertyPage 186, TColumnHeader 188, TListWindow 190, TTreeWindow 195, TRichEdit 197, Helping RichEdit 199, Common controls, in summary 204
Tooltips 204
No controls on sample 207, A second bug 209, Tooltip enablers for customizing 211
Owner-drawn controls and OWL 212
Method called twice 215
Standard C/SDK controls, custom OWL classes 217
Custom C/SDK controls and OWL 219
Subclassing and superclassing 223
Windows subclassing and superclassing, and OWL 224
Superclassing 224, Subclassing 227
Custom OWL controls 228
TStaticBitmap 229, Other customized controls 229
VBX controls and OWL 230
Interacting with a VBX control in OWL 230, A different story 232
OCX controls and OWL 236
OCX controls 236, AUTOGEN.EXE 237, Moving on 238
All the "Visual" you need 238
What makes "Visual" Basic visual? 239, What makes "Visual" C++ visual? 239
Borland "Visual" C++ 5.0--the resource editor 240
Conclusion 241
Gadgets and gadget windows 243
A history of gadgets 244
TGadget 246
Gadget overview 246, Gadget rules 250, The OWL gadgets 253, TSeparatorGadget 254, TTextGadget 254, TBitmapGadget 255, TButtonGadget 256, TControlGadget 258, TSizeGripGadget 259, TTimeGadget 261, TModeGadget 265, TMenuGadget 267
Writing your own gadgets 269
THotTextGadget 269, TFontMenuGadget 270
The TGadgetWindow 273
TGadgetWindow 274
Lists of gadgets 274, Message handling 277, Keeping the gadget informed 280, Layout 284, Hints 286
The OWL GadgetWindows 287
TControlBar 287, TMessageBar 288, TStatusBar 289, TToolBox 289, TGadgetControl 290
Writing your own gadget windows 291
Dockable gadget windows 293
TDockable 295, THarbor 296, Work shunted off 299, Container methods 301, Approach the same 305, TDockingSlip 309, TFloatingSlip 309
TEdgeSlip 312
Conclusion 313
Dialogs and windows and frames, oh my! 315
TDialogs and TWindows 316
What makes them different? 317, Modal windows and modeless dialogs, modal dialogs and modeless windows 318
TWindow 319
TWindow API overview 319, Widgets versus objects 323, Child widgets versus child objects 324, TWindow things your mother (and Borland) never told you 327
Transfer buffers 328
What is a transfer buffer? 328, Transfer buffer drawbacks 331, Transfer buffers under the microscope 334, Transfer in a child window 336, Alternatives 339, Writing your own transfer buffer mechanism 342, Should I use the transfer buffers? 343
TWindow classes 344
TPictureWindow 344, TSplashWindow 349, Another option for closing 353, TScroller 355, What is happening in EvPaint 361, TTinyCaption and other decorations 365, A problem for the derived class 369, TLayoutWindow 371, Four constraints 373
TFrameWindow 375
TDecoratedFrame 377, MDI 381
Custom TWindow derivatives 385
TTabWindow 385
TDialog 387
TDialog 388
Dialog messaging 389, Custom dialogs 391, TBWCCDialog: the myth 396, Win16 and Win32 common dialogs 397, TInputDialog 405, TRollDialog 406, TPickListDialog and TPickListPopup 407
Conclusion 411
Q&A 413
OWL implementation 414
Why does OWL call LoadLibrary on the BIDS and RTL DLLs? 414, Why should I call OwlInitUserDLL in an OWL DLL I write? 415, How come I get link errors using a DLL I was able to use with BC++ 4.5 and OWL 2.5? 418
Windows 419
Where did THandle come from, and what happened to my HWND? 419, How do I prevent my windows from being moved? 420, How do I prevent my windows from being sized? 422, How do I prevent my main window from appearing in the Windows Explorer TaskBar? 424, What other nifty new styles does the Windows 4.0 API introduce? 426, How do I put one of those cute little icons into the Windows 4.0 TaskBar? 428, How can I use a TPropertySheet as my main window? 430, How can I create a "Wizard"? 431, How can I get rid of that stupid "Close" button in my caption? 431
Controls 432
Why don't I have to explicitly call "delete" on my child controls? 432, How can I use BWCC controls without using EnableBWCC? 433, I want a TSocialSecurityEdit; how can I limit the input in an edit control? 435
appendix A The Borland experts 439
appendix B Guide to the Borland OWL examples 442
APPS 443
CLASSES 445
EXPERTS 451
GAMES 451
OCF 452
TASKS 452
TOOLS 454
TUTORIAL 454
WINAPI 455
appendix C Guide to the CD 457
Book samples 458
Extras 460
author's resources 464
glossary 472
index 479