{"id":8323,"date":"2012-02-13T07:00:00","date_gmt":"2012-02-13T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2012\/02\/13\/why-did-the-windows-95-start-button-have-a-secret-shortcut-for-closing-it\/"},"modified":"2025-02-05T10:27:24","modified_gmt":"2025-02-05T18:27:24","slug":"20120213-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20120213-00\/?p=8323","title":{"rendered":"Why did the Windows 95 Start button have a secret shortcut for closing it?"},"content":{"rendered":"<p>Windows\u00a095 had a strange feature where, if you put focus on the Start button and then hit <kbd>Alt<\/kbd>+<kbd>-<\/kbd> (That&#8217;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. <a href=\"http:\/\/blogs.msdn.com\/members\/Programmerman\/\"> Programmerman<\/a> <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2010\/07\/20\/10040074.aspx#10040393\"> wondered why this existed<\/a>.<\/p>\n<p>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 <code>WS_<wbr \/>SYS\u00adMENU<\/code> 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 <kbd>Alt<\/kbd>+<kbd>-<\/kbd>.<\/p>\n<p>The Start button was not an MDI application, but since the <code>WS_<wbr \/>SYS\u00adMENU<\/code> 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.)<\/p>\n<p>Let&#8217;s add a button with an accidental system menu to our <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2003\/07\/23\/54576.aspx\"> scratch program<\/a>:<\/p>\n<pre>BOOL\r\nOnCreate(HWND hwnd, LPCREATESTRUCT lpcs)\r\n{\r\n    <span style=\"border: solid 1px currentcolor; border-bottom: none;\">g_hwndChild = CreateWindow(                               <\/span>\r\n    <span style=\"border: 1px currentcolor; border-style: none solid;\">    TEXT(\"Button\"),                                       <\/span>\r\n    <span style=\"border: 1px currentcolor; border-style: none solid;\">    TEXT(\"Start\"),                                        <\/span>\r\n    <span style=\"border: 1px currentcolor; border-style: none solid;\">    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU |<\/span>\r\n    <span style=\"border: 1px currentcolor; border-style: none solid;\">    BS_PUSHBUTTON | BS_CENTER | BS_VCENTER,               <\/span>\r\n    <span style=\"border: solid 1px currentcolor; border-top: none;\">    0, 0, 0, 0, hwnd, (HMENU)1, g_hinst, 0);              <\/span>\r\n    return TRUE;\r\n}\r\n<\/pre>\n<p>Run this program, put focus on the button, and hit <kbd>Alt<\/kbd>+<kbd>-<\/kbd>. Hey look, a child window system menu.<\/p>\n<p>To fix this bug, remove the <code>WS_<wbr \/>SYS\u00adMENU<\/code> style. That&#8217;s how the Explorer folks fixed it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unintentional consequences.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[2],"class_list":["post-8323","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>Unintentional consequences.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/8323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=8323"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/8323\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=8323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=8323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=8323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}