Why did the Windows 95 Start button have a secret shortcut for closing it?

Raymond Chen

Raymond

Windows 95 had a strange feature where, if you put focus
on the Start button and then hit
Alt+-
(That’s Alt and the hyphen key),
you got a system menu for the Start button which let you close it,
and then the Start button vanished.

Programmerman


wondered why this existed
.

This was not a feature; it was just a bug.
The person who first wrote up the code for the Start button
accidentally turned on the WS_SYS­MENU style.
If you turn this style on for a child window,
Windows assigns your child window a system menu.
System menus for child windows may sound strange,
but they are actually quite normal if you are an MDI application.
And the standard hotkey for calling up the system menu of a child window
is
Alt+-.

The Start button was not an MDI application, but since the
WS_SYS­MENU style was set, Windows treated it
like one,
and when you pressed the hotkey, you got the system menu
which let you close the window.
(You could also move it, which was also kind of weird.)

Let’s add a button with an accidental system menu to our

scratch program
:

BOOL
OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
    g_hwndChild = CreateWindow(
        TEXT("Button"),
        TEXT("Start"),
        WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU |
        BS_PUSHBUTTON | BS_CENTER | BS_VCENTER,
        0, 0, 0, 0, hwnd, (HMENU)1, g_hinst, 0);
    return TRUE;
}

Run this program, put focus on the button, and hit
Alt+-.
Hey look, a child window system menu.

To fix this bug, remove the WS_SYS­MENU style.
That’s how the Explorer folks fixed it.

Raymond Chen
Raymond Chen

Follow Raymond