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


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.

Comments (23)
  1. Tud says:

    Aww, you should have left it there. In fact you should have added a secret key combination that let you close and move any window element.

    It sounds like I'm joking (and yes, I am), but check out this (aka Opera kill button):

    javascript:var b=new Array();var c=1;var o=((document.onkeydown==null)||(o==2))?0:1;document.onkeydown=ck;z=document.getElementsByTagName('*');for(i=0;i<z.length;i++){if(z[i].tagName.search(/(HTML|BODY)/i)==-1){z[i].onclick=function(e){t=this;if(window.event) e=window.event;if((t==e.target)||(window.event)) t.parentNode.removeChild(t);if(window.opera) e.stopPropagation();return false;};z[i].onmouseover=function(){if(!c)return;c=0;t=this;b[t]=t.style.backgroundColor;t.style.background='#FF9999';};void(z[i].onmouseout=function(){t=this;t.style.backgroundColor=b[t];c=1;});}}function ck(e){k=window.event?window.event.keyCode:e.keyCode;if((k==27)||o){o=2;document.onkeydown=null;for(i=0;i<z.length;i++){if(z[i].tagName.search(/(HTML|BODY)/i)==-1){z[i].onclick=null;z[i].onmouseover=null;z[i].onmouseout=null;z[i].style.backgroundColor=b[t];}}}}if(o==1) ck(1);

  2. Jerk says:

    One of my favorite things to do when I was younger was go to stores and close the start menu button on all the demo computers.

  3. Doh says:

    That makes sense! But to be honest: I always suspected a very different cause: it seemed logical at the time that the Start button was a 'special' button in the list of buttons used for the various open windows, and that this functionality was a case where they forgot the special casing. After all, hard-coding the button at index 0 seemed to make sense! In later versions that fixed it (perhaps at the upgrade to IE4 and active desktop that brought in taskbar toolbars?) the logical conclusion was that they removed the hack and made the start button a first class citizen.

  4. Paul says:

    @Jerk that's awesome! When I was laid off from one of my early computer jobs, I changed the "Bad command or file name" message in COMMAND.COM to something similar but even more confusing, then deleted some common commands. I never got to see the result of that, but I imagine it was funny.

  5. Leo Davidson says:

    From what I've read about Windows 8 recently, there will soon be lots of people wishing for an accidental bug/feature which does the opposite. :)

    (i.e. A hidden way to get the Start button to re-appear.)

  6. Sven says:

    Hmm, I don't think I ever knew that.

    I do know there's a hidden way to shut down explorer (other than killing the process), by holding ctrl-shift and right clicking on the shutdown button in the start menu (not sure when that was introduced… Vista maybe?). That's an actual feature, though, and it does come in handy on a few rare occasions. :)

  7. Hmm, I don't think I ever knew that.

    I do know there's a hidden way to shut down explorer (other than killing the process), by holding ctrl-shift and right clicking on the shutdown button in the start menu (not sure when that was introduced… Vista maybe?). That's an actual feature, though, and it does come in handy on a few rare occasions. :)

  8. Anonymous Coward says:

    It's a wee bit surprising that closing the start menu didn't crash the task bar when you dragged it around and resized it.

  9. Joshua says:

    @Anonymous Coward: It was probably just fine. If I recall correctly, the start button was always in the same place relative to the task bar's window, so explorer would never have to do anything with the window handle from outside so it never noticed.

  10. xpclient says:

    Are there any MDI aps in Windows or Office any more to test the Alt + hyphen shortcut? They are almost extinct. Works on the XP clipbrd.exe.

  11. Gabe says:

    I just tried out Alt+- with a non-maximized child window in Excel 2010 and still got the menu.

  12. Scott H. says:

    I remember there was a similar thing you could do in early Win95 versions that allowed you to Move the Start Button all over the place. Might be this very thing but choosing Move instead of Close. Sadly I don't have a Win95 box around to try it on, only Win98.

  13. Spire says:

    Sven Groot: I don't know know long that trick has been around, but here's an undocumented way to cleanly shut down Explorer that's been around since Windows 95.

    1. Click the taskbar to give it keyboard focus.
    2. Press Alt+F4. The "Shut Down Windows" dialog box will come up.

    3. Press Ctrl+Alt+Shift+Esc (or hold down Ctrl+Alt+Shift and click "Cancel").

    Unlike the trick described in the article, this is an actual feature, not a bug. I believe it's intended to be used by shell-extension developers.

    (To get Explorer back, press Ctrl+Shift+Esc to start Task Manager, then use "File" | "New Task (Run)" to start "explorer".)

  14. Ian Ellison-Taylor says:

    Blush

  15. Engywuck says:

    What's surprising is that no third-party depended on this functionality and therefore made it necessary for this bug to become a feature. Were the programmers lazy in these days? ;-)

  16. Neil says:

    Wow, it actually got documented in KB article 180501.

    I always thought there was some other taskbar bug in Windows 95 but maybe I got it confused with this one.

  17. est says:

    can you tell us more about Alt+X shortcut in RichEdit controls? (e.g. in Wordpad)

    [You must be new here. -Raymond]
  18. jack says:

    Windows 95 is old, nobody use it anymore.

  19. David Walker says:

    @Paul:  You sound childish and vindictive.  I wonder if that's why they fired you.

  20. reader says:

    Gandma, tell me the story about entering NULCON into Run's command line that caused BSOD all 9x family Windows-es…

  21. lifesleeper says:

    they replaced windows 95 with newer systems? how come i didn't know about this?

  22. BrotherLaz says:

    "One of my favorite things to do when I was younger was go to stores and close the start menu button on all the demo computers" — Same here, but at the local library. I was like 11 at the time. The next day all of the computers were "out of order" and stayed that way for a week. Oops. I grew up though. :-)

  23. Yuhong Bao says:

    "Gandma, tell me the story about entering NULCON into Run's command line that caused BSOD all 9x family Windows-es…"

    Yea: technet.microsoft.com/…/ms00-017

Comments are closed.