The Old New Thing

Answers to exercises

What is the significance of the (int) cast in the computation of dLines?
It isn’t. I got the question wrong. The real question should have been “What is the significance of the (int) cast in the computation of g_iWheelCarryover?”
The answer is to ensure that the computation is performed with signed integers throughout.

Why is a registry file called a "hive"?

Useless trivia day.
Why is a registry file called a “hive”?
Because one of the original developers of Windows NT hated bees.  So the developer who was responsible for the registry snuck in as many bee references as he could.  A registry file is called a “hive”,

A subtlety in the keyboard code

I neglected to call it out explicitly in the text for Part 5:  Notice that I use cRepeat to determine how many lines/pages to scroll.  This allows us to scroll the correct amount even if we are falling behind on input processing and are missing some autorepeats.

Scrollbars bart 6 – The wheel

The mouse wheel is tricky because the mouse wheel UI guidelines indicate that you
should scroll by a user-specified amount for each “click” of the mouse, where one
click is WHEEL_DELTA mouse units (called a “detent”). There are two subtle
points about the above requirement: First,

Limitations on DLL resources in Windows 95

Ancient history lesson.
When Win9x loads a 32-bit DLL, it creates a shadow 16-bit DLL so 16-bit code (like USER) can access resources in it.
The shadow DLL is effectively a resource-only 16-bit DLL, created by taking the 32-bit resources and converting them to 16-bit format.

Keyboard accessibility for scrollbars

Note that so far, the scrollbar is accessible only with the mouse. Our next step is
to add keyboard access to the scrollbar. Fortunately, this is not all that difficult.
We merely map some keystrokes to equivalent scrollbar actions.

void OnKey(HWND hwnd,

Changing the Windows boot logo

This is the answer I give to IT people when they ask if it’s okay to customize the Windows boot logo.
DO NOT DO THIS ON A PRODUCTION MACHINE OR YOU WILL REGRET IT.
If you hack the bitmap everything will seem fine until six months down the road when you decide to install the latest service pack.

Answer to previous exercise

If you look at the WM_VSCROLL message, you’ll see that the scroll position is a 16-bit
value. So if the number of entries is more then 65535, you won’t be able to use the
scroll thumb to get to the ones at the end.

Scrollbars, part 4: Adding a proportional scrollbar

To obtain a proportional scrollbar, you need to tell Windows the minimum and maximum
values covered by the scrollbar, the current scrollbar position, and the size of the
scrollbar thumb (called the “page size”). One annoyance of the way scrollbars are
set up is that the maximum value is attainable.

Answer to yesterday's exercise

iMin is the lowest-index element which intersects the paint rectangle, so a
simple truncating division produces the desired index.

The formula for iMax can be interpreted two ways. One is that it is the roundup
of the first invisible line. Recall the rectangles are exclusive of the endpoint,

Old New Thing

Should there be a standard C++ pattern for this? transform_to

Or maybe you should expect to write it out the slow way.

How to save a lot of money on cable car tickets in San Francisco

Go downstairs and buy it from the machine.

How can I configure my Windows NT service to autostart when the system gains Internet access?

You can ask to be started when the system gets an IP address.

What’s up with the CF_SYLK and CF_DIF clipboard formats?

From a galaxy far, far away.

The custom-made computers powered by pepperoni pizza

Once more for old time's sake.

The 2020/2021 Seattle Symphony subscription season at a glance

The pocket reference guide for 2020/2021.

Why are there trivial functions like Copy­Rect and Equal­Rect?

You could call them to save a dozen bytes!

Why you might need additional control over the secret event hiding inside the file object

Sometimes every little bit of contention means a lot.

If you’re not keeping the parameter, then you still want to have separate T const& and T&& overloads

Forwarding it onward.

If you plan on keeping the parameter anyway, then there’s no need to have separate T const& and T&& overloads

You can just take it by value and move it out.