Delphi 3

User Interface Design

by Warren Kovach

with Ludovic Dubois

Published by Prentice Hall, 1997

ISBN 0-13-617960-6


Contents

 

Introduction

1
Intended audience 1
Further reading 2
Delphi 3 2
Windows API and assembly language 3
CD-ROM 3
Conventions 3

Chapter 1 - Basic User Interface Design

7
Assessing user needs 7
Computer expertise 8
What data? 10
What tasks? 11
Prototypes 12
Assessing the prototype 13
Do's and Don'ts 13

Chapter 2 - Application Styles

15
SDI 16
SDI and Delphi 16
MDI 17
MDI and Delphi 18
Workspace 19
Workspaces and Delphi 19
Workbooks 22
Workbooks and Delphi 23
Top Tabs 26
Projects 27
Projects and Delphi 28
Console 34
Console applications and Delphi 35

Chapter 3 - Menus

37
Organization 37
Primary menu items 38
Other common menu items 40
Application specific menus 41
Iconic menus 41
Tips for good menus 42
Keyboard support 44
Context menus 46
Delphi and menus 46
Menu templates 47
Adding separators 47
Hints 47
Expert and novice menus 48
Disabling items 49
Disabling clipboard items 51
Updating whenever the menu is invoked 51
Updating whenever the clipboard changes 52
Updating whenever the selection changes 54

Chapter 4 - Status Bars and Toolbars

57
Status bars 57
Toolbars 60
Toolbars in Delphi 1 and 2 62
New Win95 common controls 63
Drop-down menu buttons 65
CoolBars and flat buttons 67
Creating a CoolBar 69
Cool buttons 69
Dockable toolbars 70
The dragging outline 77
Dragging 77
Rearranging buttons 79

Chapter 5 - Effective Dialog Boxes

81
Features of a dialog box 81
Buttons 82
Placement 84
Style 85
Keyboard access 86
Modal and modeless 86
Tiny captions 88
Tiny captions in Windows 3.1 89
Roll up, roll up 93
Populating the dialog 96
Choosing the correct control 97
To edit or not to edit 99
Error checking and prevention 99
Alternative visual controls 101
Arrangement and labelling 102
Alignment 103
Tab order and keyboard access 104
Multiple choice 105
Dual list boxes 105
Checked list boxes 110
ListView 114
Pictures 116
Working with different resolutions 118
Scaling 119
Scaling to exact size 122
Multipage dialogs 123
Tabbed dialogs 124
Releasing resources 125
Wizards 126
Wizards in Delphi 126

Chapter 6 - User Assistance

137
Status bar messages 137
Tooltips or help hints 138
Context-sensitive help 139
Help button on dialogs 140
More specific context 140
'What's this?' buttons 141
Toolbar and menu 'What's this?' 141
What's This? mode 146
Help files 147
Help access 147
Indexing 150
The topics 150
Wizards 152

Chapter 7 - Polishing the User Interface

155
Most recently used files list component 155
Component design 156
Building the file list 158
Adding files 161
Responding to OnClick 163
File drag and drop 163
Dropping on an icon 163
'Running' a file 166
Dropping on the program Window 169
Splash screens 171
Displaying the splash screen 173
Removing the splash screen 173
Bitmap on background of MDI frame 174
Trapping client messages 175
Drawing the background 177
Starting minimized 178
16-bit method 179
32-bit method 180
Gang screens and animated About Boxes 181
Trapping the keystrokes 182
Silent ALTs 183
Trapping a whole sequence 184
Animation 189
Creating and loading the bitmaps 189
Animating the bitmaps 191
Single instances of program 193
Improvements 195
Bring previous instance to front 198
Terminating current instance 198
Changing the class name 199
Alternatives 200
Saving window position and state 201
TWindowPlacement 202
Inheriting saveable MDI children 207
Saving and recreating the child windows 212
Saving fonts 214
Resurrection 217

Chapter 8 - Bullet-proof Programming

219
Exceptions 220
Exception handlers 221
Giving more details 222
Input/output exceptions 225
Modifying the default message 227
Error checking Windows API calls 227
Raising exceptions from API errors 229
Overriding default exception handler 233
Creating the error dialog 237
Procedure stack 238
Implementing the stack 239
Disabling methods 242
Setting CurrentProc 242
Exceptions 243
Printable exception dialog 244
Inner workings 247
Reading system files 252
Printing and copying 253
Using the dialog 253
Hiding the details 254
Effective error reporting 259
Improving the example code 259
Problems opening the file 260
Errors reading the data 263
Good error messages 265
Resource protection 268
Try..finally 268
Create and Destroy 269
Initialization and finalization sections 271
Debugging hints 273
Testing 274
Debugging 275
Breakpoints 275
Watching variables 276
CPU Window 277
Turbo Debugger for Windows 279
Status messages 280
Following variables 280
Taking over the status bar 281
Assertions 281
Common bugs 283

Chapter 9 - Coexisting with Windows

293
Multitasking 293
Handling events 294
Relenting control 295
Trade-offs 297
No entry 298
Pre-emptive multitasking 299
Win 95 and 16-bit programs 300
Background processing 301
Idle days 302
Which to choose? 304
Interrupting long tasks 305
Great escape 307
Centralized behaviour 308
Using Windows' settings 309
International settings 309
Ringing in the changes 311
Windows 95 & NT 313
Printers 313
Other steps to coexistence 315
Closing down help 315
Freeing DLLs 315
File associations 315
Staying on top 316
Threads 317
Multithreading concepts and issues 317
Protecting variables 318
Critical sections 319
Synchronization 321
Priorities 321
Exceptions 322
Where to use threads? 322
Threading example 322
Aborting 327
Running the sort 327
Multiple sorts 328

Chapter 10 - Accessing System Information

331
Operating System 333
Detecting version 3.11 335
Windows for Workgroups 339
Processor 341
16-bit detection 343
Memory statistics 346
Physical RAM 346
Free Memory 347
Disk drives 350
Drive type 355
32-bit drive type 361
Disk size and free space 362
Volume label and serial number 362
Currently loaded modules and tasks 367
Windows 3.1 371
Windows 95 372
Windows NT 376
Performance data 377
Walking the list 386
PSAPI method 387

Chapter 11 - Writing International Applications (Ludovic Dubois)

391
Introduction 392
Different levels for the users of your application 392
Unilingual or multilingual? 393
Unilingual binary 393
Multilingual binary 394
Process 394
Code preparation 395
Source code and display separation 395
Non-Latin applications 395
Multilingual binaries 396
Translation 396
Context 397
Homogeneity 397
Multilingual or unilingual integration 397
When do we start? 397
How Delphi works 398
Construction 398
Files used by Delphi 398
Manipulating Delphi files 399
Execution 400
Form creation 400
Resources reading 401
OnCreate event activation 401
Delphi and Internationalization 402
Copy of DFM files 403
Subclasses of controls 406
Form inheritance 412
Translation management by specific components 417
Database solution 425
Managing several DFMs for the same source code 430
Translation Suite 434
Non-Latin languages 435
MBCS and Unicode 435
IMEs 436
Conclusion 436

Chapter 12 - Use of On-line Services

439
On-line discussion groups 439
Usenet 440
CompuServe 441
CIX 442
Libraries 443
Off-line 444

Chapter 13 - New Features of Delphi 3

447
Packages 447
Using packages 448
Palette packages 449
COM/ActiveX support 450
Interfaces 450
Interfaces in Delphi 451
Creating ActiveX controls 453
ActiveForms 454
IDE Enhancements 455
Code Insight 455
Code templates 455
Code completion 456
Code parameters 456
Tooltip expression evaluation 456
Component Templates 456
VersionInfo 457
Other IDE enhancements 458
VCL Enhancements 459
Database features 460
Internet components 461
Compiler changes 461
Resource strings 462

Appendix A - Windows API and Assembly Language

465
Linking 465
Types 466
PChars 467
Unicode 468
Handles 469
Device contexts 469
Messages 470
Callbacks 471
Window procedures 472
Checking return values 473
Sources of information about API 474
Assembly language basics 474
Binary and hexadecimal 475
Segments 476
Registers 476
Interrupts 478
Common statements 479

Appendix B - The CD-ROM

483
Source code 483
On-line book 484
Information 484
DTopics 484
Lloyd's help file 485
Ralf Brown's Interrupt List 485
SWAG 486
The Unofficial Newsletter of Delphi Users 487
InfoPlus 487
Internationalization components 488
  

Copyright © 2008 Kovach Computing Services, Anglesey, Wales. All Rights Reserved. Portions copyright Addinsoft, Provalis Research, and Data Description Inc.

Last modified 25 January, 2008