September, 2009

  • The Old New Thing

    We accept cash, credit cards, and Microsoft cardkeys

    • 11 Comments

    One of the restaurants that opened at the new Microsoft Commons is Spitfire, which opened under its own name instead of one of the many wonderful alternatives proposed. At The Commons, the dining establishments operate in a variety of ways (cafeteria, buffet, fast casual, deli, etc.) but they share the common characteristic that you pay for your meal before you sit down to eat, and you clear your own table when you're done. In other words, it's a giant upscale food court spread out over two buildings.

    Except for Spitfire, which has its own building and operates as a sit-down restaurant with table service.

    One thing that I still can't get over is that you can pay for your lunch at Spitfire with your Microsoft cardkey. That somehow just seems wrong.

    (This week is Share Our Strength's Great American Dine Out. Dine out at a participating restaurant and support efforts to help children at risk of hunger in the United States.)

  • The Old New Thing

    What is the logic behind the thumb size and position calculation in scroll bars?

    • 16 Comments

    Commenter sarathc asks, "How do we implement a custom scroll bar as Windows does? What is the logic behind the thumb size and position calculation? How we could dynamically manage it?"

    Let's look at the three questions in turn.

    To implement a custom scroll bar... don't do it. It's just not worth the effort, and there will almost always be little seams, like not lighting up when the mouse hovers over them.

    The logic behind the thumb size and position calculation I thought I covered in my scroll bar series. The size of the thumb relative to the size of the scroll bar is the same as the page size relative to the scroll bar range. In other words:

    thumb size / scroll bar size = page size / scroll bar range

    A little high school algebra tells you, then, that

    thumb size = scroll bar size * page size / scroll bar range

    There may be some off-by-one errors in the above formula, and some special tweaks for extreme cases (you don't want a thumb smaller than one pixel after all), but that's the basic idea.

    Similarly, the screen position of the thumb relative to the scroll bar is equal to the programmatic thumb position relative to the scroll bar range (roughly).

    To dynamically manage it, use the usual scroll bar functions like SetScrollInfo.

  • The Old New Thing

    Windows 95's ticking death

    • 24 Comments

    A few years ago, Larry Osterman explained the famous beeping death. Windows 95 had its own noise-related death, what nobody has called ticking death, but that's what I'm going to call it. (Let's see how long before somebody decide to add it to Wikipedia.)

    When your machine fell into ticking death, each time you moved the mouse or pressed a key, it was acknowledged with nothing more than a tiny click from the speaker. What was the cause of ticking death?

    When the hardware drivers report a mouse or keyboard event on Windows 95, they call the mouse_input or keybd_input function. Since this happens at hardware input time, those functions are very limited in what they can do. All they do is appends the new input to a queue of "input that arrived while I was busy doing something else." When the window manager reaches a stable state, it takes the input from the "input waiting to be processed" queue and farms them out to the appropriate application input queues. The window manager needs to be stable, since mouse input gets routed depending on which window is under the mouse pointer when the pointer moves, and you don't want to do this while some other part of the window manager is in the process of rearranging the windows (and the window tree is consequently unstable).

    For compatibility reasons, the window manager promises not to change anything while 16-bit code is running, so that a 16-bit application doesn't see, for example, a window becoming destroyed behind its back. (Recall that 16-bit Windows is a co-operatively multi-tasked system, which means that applications have control of the CPU until they voluntarily relinquish it.)

    If a 16-bit application hangs, then the buffer for holding all of these "distribute this input to application queues as soon as it is safe to do so" fills up and can't accept any more input. If new input arrives and there's nowhere to save it, the window manager emits a little tick sound as a mini-error message.

    Of course, as the end user, you probably knew something was up because the screen hasn't changed in a long time. Some 16-bit application is not responding and is preventing the window manager from doing anything. To get out of this situation, you can hit Ctrl+Alt+Del and try to kill the hung application.

  • The Old New Thing

    Should I fix the spelling in the United States Constitution?

    • 23 Comments

    Commenter Dave jokingly remarked, "I've grown used to handling characters with ASCII. (If it was good enough to represent every character in the US Constitution, it's good enough for me.)"

    But there's a double-joke in there. You see, not every character in the United States Constitution can be represented in ASCII!

    If you take a close look, you'll see that some words appear to be "misspelled": At the end of the second line, it says "Bleſsings of Liberty", and Article 1 Section 1 declares that "All legislative Powers herein granted shall be vested in a Congreſs of the United States."

    That f-like character is actually a long S, a character which has fallen into disuse in modern English. It also doesn't exist in ASCII.

    My friend The Knitty Professor told me a story of a class she taught many years ago. A student emailed a question:

    When I want to quote an excerpt from Locke in my paper, should I fix the spelling? Some words use f instead of s, and others are incorrectly capitalized.

    Today is Constitution Day, a United States holiday celebrating the United States Constitution. Since 2005, all educational institutions which receive federal funds must teach about the United States Constitution on this day, even hairdresser schools.

  • The Old New Thing

    Rentonites concerned about Hooters opening in their town, but not for the reason you think

    • 7 Comments

    To support my claim that Renton has a reputation for being a working-class town, I submit this article from last week's news: Hooters too pretentious for us, some Renton, South Park locals say.

  • The Old New Thing

    Whoa there, logging on awful fast now are we?

    • 16 Comments

    Occasionally, a customer will run into a problem that manifests itself only when Autologon is enabled. Here are some examples:

    If we log on manually, everything works just fine. But if we log on using Autologon with the same userid and password, we get a networking error from our wireless network card. Is there a known problem with Autologon and wireless networking?
    If we log on manually, everything works just fine. But if we log on using Autologon with the same userid and password, one of the programs in the Startup group raises an error because it can't create a remote desktop session.

    The issue really isn't Autologon. The issue really is the manual logon. For you see, manually logging on takes time. If you really concentrate you can get it down to one or two seconds, but under more realistic circumstances, a manual logon will be significantly slower than an automatic one because it simply takes time to click and type and click. And those seconds are crucial.

    That extra time, the delay introduced by the fact that human beings type a lot more slowly than a computer can, is enough to get those services you are relying fully initialized by the time you need them. Locating and connecting to a nearby wireless access point typically takes several seconds. If you use Autologon, the system will plow ahead with trying to contact the domain controller to validate your password, but the wireless networking card hasn't found the base station, and you get an error. (Nitpickers should at this point stifle screams of cached credentials. I'm just giving an example. If you don't like this example, go find another one.) I don't know whether it will help or not, but you can try disabling Fast Logon and forcing the system to wait for the network to be fully initialized before allowing logon to occur.

    In the second case, the problem is that the remote desktop service is not yet fully started by the time the program in the Startup group tries to use it. Under such conditions, you may want to query the status of the remote desktop service; if it reports a status of SERVICE_START_PENDING, then the service is starting up but is not yet ready. You need to wait wait until the service status is SERVICE_RUNNING before you can start using the remote desktop service.

    Anyway, the point for today is that Autologon itself doesn't have problems. Rather, Autologon takes away the "seconds of rest" the computer normally experiences while it's waiting for a human being to log in, and sometimes it's those extra few seconds that you were inadvertently relying upon.

  • The Old New Thing

    Crazy Eddie: His prices were insane because it was all a criminal operation

    • 5 Comments

    If you lived in the New York metropolitan area in the 1980's, you couldn't avoid the advertisements for electronics store Crazy Eddie. What I didn't realize until now was that the retail establishment was a criminal operation from day one. Sam Antar, Crazy Eddie CFO, and nephew of company namesake Eddie Antar, talks us through the entire operation in this riveting interview. Along the way, you'll learn why it was at first advantageous to under-report revenues, then later why it became advantageous to return the unreported money back to the system.

    Unexpected skill you develop as a money launderer: You can look at a bag and immediately calculate how much cash will fit in it.

    Other Planet Money podcasts I found interesting:

  • The Old New Thing

    Why does the Start menu search box autoselect some items but not others?

    • 10 Comments

    When you open the Start menu and type into the search box, sometimes the first search result is autoselected (so you just have to hit Enter), whereas sometimes See more results is autoselected. Is there a method to this madness?

    If an item is found in the Programs and Control Panel sections, then the first such is autoselected. Otherwise, the default item is See more results. The theory is that if you are typing a program or control panel name from muscle memory and make a typo, you don't want this to result in a random file opening. (Why are programs and control panels treated differently? Because the list of programs and control panels is relatively static, permitting the development of muscle memory. On the other hand, the other sections like Files and Communications are highly dynamic, and it's unlikely that you're going to get in the habit of always seeing Budget Proposal as the first hit because in an hour's time, it might not be.)

  • The Old New Thing

    A complex family calculus

    • 16 Comments

    I spent the other night at a relative's house, and I was woken the next morning by my young niece who politely asked me to make her breakfast. (Her technique for waking me up is to come in and call my name. If the door is closed, she pounds on the bedroom door and shouts, "Wake up! Wake up!" If I fail to open the door, she opens it herself. If the door is locked, she jiggles the handle until she forces the door open. I just leave the door open now. Making the best of a bad situation.)

    Anyway, later that morning, the following conversation took place between my niece and an adult family member (which conversation I have taken the liberty of translating into English):

    "Why did you wake up Uncle Raymond?"

    I wanted cereal for breakfast.

    "Why didn't you ask Mommy?"

    Mommy was still sleeping.

  • The Old New Thing

    Can you create an information context for the display?

    • 9 Comments

    Adrian McCarthy asks, "Can you create an information context for the display? ... I can call CreateDC("DISPLAY"), but perhaps that wouldn't generalize for a multiple-monitor display with different settings on each screen. I'm trying to avoid constantly creating and destroying DCs when all I need to do is measure strings, check color depth, dpi, etc."

    I admire the effort of trying to avoid creating a whole DC when all you want is to perform some inquiries. Some inquiries are monitor-independent, like getting the DPI or measuring strings, so you can just use GetDC(NULL) to get a temporary DC. This is cheaper than a full-on CreateDC since GetDC goes through the DC cache, so you're just grabbing a DC out of the cache temporarily, doing a little computation, and then returning it to the cache (with ReleaseDC).

    If you are doing something that is monitor-specific, like getting its color depth, you can call EnumDisplayMonitors on the desktop DC to look at each monitor.

    (And just for completeness, to get the name for a specific monitor if you really do want to create an IC for it, call GetMonitorInfo with a MONITORINFOEX and look at the szDevice member.)

    Update: Original text said "DC" in the last sentence by mistake.

Page 2 of 4 (37 items) 1234