Home > Store

Old New Thing: Practical Development Throughout the Evolution of Windows, The

eBook (Watermarked)

  • Your Price: $28.79
  • List Price: $35.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Also available in other formats.

Register your product to gain access to bonus material or receive a coupon.

Description

  • Copyright 2007
  • Pages: 560
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-280063-2
  • ISBN-13: 978-0-13-280063-1

"Raymond Chen is the original raconteur of Windows."

--Scott Hanselman, ComputerZen.com

"Raymond has been at Microsoft for many years and has seen many nuances of Windows that others could only ever hope to get a glimpse of. With this book, Raymond shares his knowledge, experience, and anecdotal stories, allowing all of us to get a better understanding of the operating system that affects millions of people every day. This book has something for everyone, is a casual read, and I highly recommend it!"

--Jeffrey Richter, Author/Consultant, Cofounder of Wintellect

"Very interesting read. Raymond tells the inside story of why Windows is the way it is."

--Eric Gunnerson, Program Manager, Microsoft Corporation

"Absolutely essential reading for understanding the history of Windows, its intricacies and quirks, and why they came about."

--Matt Pietrek, MSDN Magazine's Under the Hood Columnist

"Raymond Chen has become something of a legend in the software industry, and in this book you'll discover why. From his high-level reminiscences on the design of the Windows Start button to his low-level discussions of GlobalAlloc that only your inner-geek could love, The Old New Thing is a captivating collection of anecdotes that will help you to truly appreciate the difficulty inherent in designing and writing quality software."

--Stephen Toub, Technical Editor, MSDN Magazine

Why does Windows work the way it does? Why is Shut Down on the Start menu? (And why is there a Start button, anyway?) How can I tap into the dialog loop? Why does the GetWindowText function behave so strangely? Why are registry files called "hives"?

Many of Windows' quirks have perfectly logical explanations, rooted in history. Understand them, and you'll be more productive and a lot less frustrated. Raymond Chen--who's spent more than a decade on Microsoft's Windows development team--reveals the "hidden Windows" you need to know.

Chen's engaging style, deep insight, and thoughtful humor have made him one of the world's premier technology bloggers. Here he brings together behind-the-scenes explanations, invaluable technical advice, and illuminating anecdotes that bring Windows to life--and help you make the most of it.

A few of the things you'll find inside:

  • What vending machines can teach you about effective user interfaces
  • A deeper understanding of window and dialog management
  • Why performance optimization can be so counterintuitive
  • A peek at the underbelly of COM objects and the Visual C++ compiler
  • Key details about backwards compatibility--what Windows does and why
  • Windows program security holes most developers don't know about
  • How to make your program a better Windows citizen

Sample Content

Table of Contents

Preface xxiii

Acknowledgments xxvii

About the Author xxix

Chapter One: Initial Forays into User Interface Design

Why do you have to click the Start button to shut down? 1

Why doesn't Windows have an "expert mode"? 2

The default answer to every dialog box is Cancel 3

The best setting is the one you don't even sense, but it's there, and it works the way you expect 6

In order to demonstrate our superior intellect, we will now ask you a question you cannot answer 7

Why doesn't Setup ask you if you want to keep newer versions of operating system files? 7

Thinking through a feature 9

When do you disable an option, and when do you remove it? 12

When do you put ... after a button or menu? 13

User interface design for vending machines 13

User interface design for interior door locks 15

The evolution of mascara in Windows UI 16

Chapter Two: Selected Reminiscences on Windows 95

Why isn't my time zone highlighted on the world map? 19

Why didn't Windows 95 boot with more than 1GB of memory? 20

Why did Windows 95 have functions called BEAR, BUNNY, and PIGLET? 22

What about BOZOSLIVEHERE and TABTHETEXTOUTFORWIMPS? 23

What was in the Windows 95 Special Edition box? 25

Windows brings out the Rorschach test in everyone 25

The martial arts logon picture 26

Why a really large dictionary is not a good thing 27

An insight into the Windows 95 startup sound 27

It's a lot easier to write a column if you don't care about accuracy 28

Why does the System Properties page round the memory size? 29

Why does my hard drive light flash every few seconds? 29

The hunt for a faster syscall trap 30

One byte used to cost a dollar 31

Each product-support call costs a sale 32

Why isn't Tweak UI included on the Windows CD? 32

Turns out that you can't install Windows via xcopy 34

Buying an entire Egghead Software store 35

The history of the Windows PowerToys 35

How did Windows choose its final build numbers? 38

Why doesn't the build number increment for service packs? 39

Chapter Three: The Secret Life of GetWindowText

How windows manage their text 41

Enter GetWindowText 42

What if I don't like these rules? 43

Can you give an example where this makes a difference? 44

Why are the rules for GetWindowText so weird? 44

Chapter Four: The Taskbar and Notification Area

Why do some people call the taskbar the "tray"? 47

Why does the taskbar default to the bottom of the screen? 49

Why doesn't the clock in the taskbar display seconds? 50

Why doesn't the taskbar show an analog clock? 51

When I dock my taskbar vertically, why does the word "Start" disappear? 52

Why don't notification icons get a message when the user clicks the "X" button? 52

Chapter Five: Puzzling Interface Issues

What are those little overlay icons? 53

Why are these unwanted files/folders opening when I log on? 54

What do the text label colors mean for files? 56

Why does my advanced options dialog say ON and OFF after every option? 57

What determines the order in which icons appear in the Alt+Tab list? 58

Why is the read-only property for folders so strange? 59

What's with those blank taskbar buttons that go away when I click on them? 59

What is the difference between Minimize All and Show Desktop? 60 What does boldface on a menu mean? 62

Where do those customized Web site icons come from? 62

Where did my task manager tabs and buttons go? 63

Will dragging a file result in a move or a copy? 64

Why does the Links folder keep re-creating itself? 65

Why are documents printed out of order when you multiselect and choose Print? 66

Raymond spends the day doing product support 67

Blow the dust out of the connector 68

How much is that gigabyte in the window? 69

Why can't I remove the "For test/evaluation purposes only" tag? 70

Chapter Six: A History of the GlobalAlloc Function

The early years 71

Selectors 73

Transitioning to Win32 75

A peek at the implementation 76

Chapter Seven: Short Topics in Windows Programming

The scratch program 79

Getting a custom right-click menu for the caption icon 85

What's the difference between CreateMenu and CreatePopupMenu? 86

When does the window manager destroy menus automatically? 88

Painting only when your window is visible onscreen 89

Determining whether your window is covered 93

Using bitmap brushes for tiling effects 95

What is the DC brush good for? 98

Using ExtTextOut to draw solid rectangles 100

Using StretchBlt to draw solid rectangles 102

Displaying a string without those ugly boxes 103

Semaphores don't have owners 110

An auto-reset event is just a stupid semaphore 112

Chapter Eight: Window Management

Why do I get spurious WM_MOUSEMOVE messages? 115

Why is there no WM_MOUSEENTER message? 118

The white flash 118

What is the hollow brush for? 119

What's so special about the desktop window? 120

The correct order for disabling and enabling windows 121

A subtlety in restoring the previous window position 122

UI-modality versus code-modality 123

The WM_QUIT message and modality 126

The importance of setting the correct owner for modal UI 129

Interacting with a program that has gone modal 132

A timed MessageBox, the cheap version 133

The scratch window 135

The bonus window bytes at GWLP_USERDATA 136

A timed MessageBox, the better version 136

A timed context menu 138

Why does my window receive messages after it has been destroyed? 139

Chapter Nine: Reminiscences on Hardware

Hardware backward compatibility 141

The ghost CD-ROM drives 142

The Microsoft corporate network: 1.7 times worse than hell 143

When vendors insult themselves 144

Defrauding the WHQL driver certification process 145

A twenty-foot-long computer 146

The USB cart of death 147

New device detected: Boeing 747 147

There's an awful lot of overclocking out there 148

Chapter Ten: The Inner Workings of the Dialog Manager

On the dialog procedure 151

The evolution of dialog templates 163

Why dialog templates, anyway? 196

How dialogs are created 197

The modal dialog loop 204

Nested dialogs and DS_CONTROL 216

Why do we need a dialog loop, anyway? 224

Why do dialog editors start assigning control IDs with 100? 225

What happens inside DefDlgProc? 226

Never leave focus on a disabled control 228

What happens inside IsDialogMessage? 229

Why is the X button disabled on my message box? 237

Chapter Eleven: General Software Issues

Why daylight saving time is nonintuitive 239

Why do timestamps change when I copy files to a floppy? 241

Don't trust the return address 242

Writing a sort comparison function 243

You can read a contract from the other side 245

The battle between pragmatism and purity 249

Optimization is often counterintuitive 250

On a server, paging = death 253

Don't save anything you can recalculate 254

Performance gains at the cost of other components 255

Performances consequences of polling 257

The poor man's way of identifying memory leaks 258

A cache with a bad policy is another name for a memory leak 259

Chapter Twelve: Digging into the Visual C++ Compiler

Do you know when your destructors run? 267

The layout of a COM object 272

Adjustor thunks 274

Pointers to member functions are very strange animals 276

What is __purecall? 280

Chapter Thirteen: Backward Compatibility

Sometimes an app just wants to crash 283

When programs grovel into undocumented structures 284

Why not just block the applications that rely on undocumented behavior? 286

Why 16-bit DOS and Windows are still with us 288

What's the deal with those reserved filenames such as NUL and CON? 290

Why is a drive letter permitted in front of UNC paths (sometimes)? 292

Do not underestimate the power of the game Deer Hunter 293

Sometimes the bug isn't apparent until late in the game 293

The long and sad story of the Shell Folders key 294

The importance of error code backward compatibility 297

Sure, we do that 298

When programs patch the operating system and mess up 299

The compatibility constraints of even your internal bookkeeping 300

Why does Windows keep your BIOS clock on local time? 301

Bad version number checks 302

The ways people mess up IUnknown::QueryInterface 303

When programs assume that the system will never change, Episode 1 305

When programs assume that the system will never change, Episode 2 306

The decoy Display Control Panel 308

The decoy visual style 309

Chapter Fourteen: Etymology and History

What do the letters W and L stand for in WPARAM and LPARAM? 311

Why was nine the maximum number of monitors in Windows 98? 312

Why is a registry file called a hive? 312

The management of memory for resources in 16-bit Windows 312

What is the difference between HINSTANCE and HMODULE? 313

What was the purpose of the hPrevInstance parameter to WinMain? 316

Why is the GlobalWire function called GlobalWire? 317

What was the difference between LocalAlloc and GlobalAlloc? 318

What was the point of the GMEM_SHARE flag? 320

Why do I sometimes see redundant casts before casting to LPARAM? 321

Why do the names of the registry functions randomly end in Ex? 322

What's the difference between SHGetMalloc, SHAlloc, CoGetMalloc, and CoTaskMemAlloc? 324

Why is Windows Error Reporting nicknamed Dr. Watson? 329

What happened to DirectX 4? 330

Why are HANDLE return values so inconsistent? 331

Why do text files end in Ctrl+Z? 333

Why is the line terminator CR+LF? 334

TEXT vs. _TEXT vs. _T, and UNICODE vs. _UNICODE 335

Why are dialog boxes initially created hidden? 335

When you change the insides, nobody notices 336

If FlushInstructionCache doesn't do anything, why do you have to call it? 337

If InitCommonControls doesn't do anything, why do you have to call it? 338

Why did InterlockedIncrement/Decrement only return the sign of the result? 339

Why does the function WSASetLastError exist? 340

Why are there broadcast-based mechanisms in Windows? 340

Where did windows minimize to before the taskbar was invented? 341

Why didn't the desktop window shrink to exclude the taskbar? 343

Why does the caret stop blinking when I tap the Alt key? 343

What is the deal with the ES_OEMCONVERT flag? 345

The story behind file system tunneling 346

Why do NTFS and Explorer disagree on filename sorting? 347

The Date/Time Control Panel is not a calendar 350

How did Windows 95 rebase DLLs? 351

What are SYSTEM_FONT and DEFAULT_GUI_FONT? 353

Why do up-down controls have the arrows backward? 354

A ticket to the Windows 95 launch 355

Chapter Fifteen: How Window Messages Are Delivered and Retrieved

Sent and posted messages 358

The life of a sent message 363

The life of a posted message 364

Generated posted messages 365

When does SendMessageCallback call you back? 368

What happens in SendMessageTimeout when a message times out? 369

Applying what you've learned to some message processing myths 370

How can you tell who sent or posted you a message? 371

You can't simulate keyboard input with PostMessage 371

Chapter Sixteen: International Programming

Case mapping on Unicode is hard 373

An anecdote about improper case mapping 374

Why you can't rotate text 375

What are these directories called 0409 and 1033? 379

Keep your eye on the code page 379

Why is the default 8-bit codepage called "ANSI"? 388

Why is the default console codepage called "OEM"? 388

Why is the OEM code page often called ANSI? 389

Logical but perhaps surprising consequences of converting between Unicode and ANSI 391

Chapter Seventeen: Security

World-writable files 393

Hiding files from Explorer 394

Stealing passwords 395

Silent install of uncertified drivers 396

Your debugging code can be a security hole 397

Why shared sections are a security hole 398

Internet Explorer's Enhanced Security Configuration doesn't trust the intranet 402

Chapter Eighteen: Windows 2000 and Windows XP

Why doesn't the new Start menu use Intellimenus in the All Programs list? 403

Why is there no programmatic access to the Start menu pin list? 404

Why does Windows XP Service Pack 2 sometimes forget my CD autoplay settings? 406

The unsafe device removal dialog 407

Two brief reminiscences on the Windows XP Comments? button 408

Why does Explorer eject the CD after you finish burning it? 408

Why does Windows setup lay down a new boot sector? 409

Psychic debugging: Why your expensive four-processor machine is ignoring three of its processors 410

Psychic debugging: Why your CPU usage is hovering at 50% 411

What's the deal with the DS_SHELLFONT flag? 412

Why does DS_SHELLFONT = DS_FIXEDSYS | DS_SETFONT? 413

What other effects does DS_SHELLFONT have on property sheet pages? 414

Chapter Nineteen: Win32 Design Issues

Why does Win32 fail a module load if an import could not be resolved? 417

Why are structure sizes checked strictly? 418

Why do I have to return this goofy value for WM_DEVICECHANGE? 421

The arms race between programs and users 422

Why can't you trap TerminateProcess? 424

Why do some processes stay in Task Manager after they've been killed? 424

Understanding the consequences of WAIT_ABANDONED 425

Why can't I put hyperlinks in notification icon balloon tips? 427

Why can't I use the same tree item multiple times? 429

The kooky STRRET structure 429

Why can't you set UTF-8 as your ANSI code page? 431

When should you use a sunken client area? 432

Why is there no all-encompassing superset version of Windows? 433

Why is it even possible to disable the desktop, anyway? 433

What are the window and menu nesting limits? 435

What's the difference between HWND_TOP and HWND_TOPMOST? 435

Chapter Twenty: Taxes

Hierarchical Storage Management 438

Geopolitics 439

Remote Desktop Connection and Painting 440

Fast User Switching and Terminal Services 443

Multiple users 444 Roaming user profiles 445

Redirected folders 447

My Documents vs. Application Data 450

Large address spaces 451

Power management and detecting battery power 455

Intermittent network connectivity 457

Anti-aliased fonts and ClearType 459

High DPI displays 462

Multiple monitors 467

The work area 470

Displaying your pop-up windows in the right place 471

Accessibility 472

Chapter Twenty-One: Silliness

The much-misunderstood "nop" action 481

Don't let Marketing mess with your slides 482

Whimsical bug reports 482

Watch out for those sample URLs 483

No code is an island 484

But I have Visual Basic Professional 485

It's all about the translucent plastic 485

My first death threat 486

You can't escape those AOL CDs 487

Giving fair warning before plugging in your computer 487

Spider Solitaire unseats the reigning champion 488

There's something about Rat Poker 489

Be careful what you name your product group 490

The psychology of naming your internal distribution lists 490

Differences between managers and programmers 491

Using floppy disks as semaphore tokens 492

When a token changes its meaning midstream 492

Whimsical embarrassment as a gentle form of reprimand 493

Using a physical object as a reminder 494

The office disco party 495

The Halloween-themed lobby 495

Index 497

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020