{"id":22113,"date":"2008-06-02T10:00:00","date_gmt":"2008-06-02T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2008\/06\/02\/why-are-accelerators-for-hidden-controls-still-active\/"},"modified":"2008-06-02T10:00:00","modified_gmt":"2008-06-02T10:00:00","slug":"why-are-accelerators-for-hidden-controls-still-active","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20080602-00\/?p=22113","title":{"rendered":"Why are accelerators for hidden controls still active?"},"content":{"rendered":"<p>\nIn the suggestion box, Serge Wautier asked\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/pages\/407234.aspx#513265\">\nwhy accelerators for hidden controls remain active<\/a>.\nHe&#8217;s apparently rather insistent because he\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/09\/19\/762058.aspx#762297\">\nasked the question again a few months later<\/a>.\nAsking the same question multiple times reduces the likelihood\nthat I&#8217;ll answer it.\nConsider yourself lucky that I wrote this answer before I noticed\nthe duplicate; otherwise I would probably have skipped it.\n<\/p>\n<p>\nWhy are accelerators for hidden controls still active?\nVery simple: Keyboard accessibility.\n<\/p>\n<p>\nThe dialog manager considers controls which indicate\nthat they want characters\n(<code>DLGC_WANTCHARS<\/code>)\nto have no keyboard accelerator.\nThere are a lot of controls that fall into this category,\nincluding such popular ones as edit controls,\ncombo boxes, and list boxes.\nThe traditional way of giving these &#8220;no accelerator&#8221; controls\nan accelerator is to stick a static control on front of it\nwith the desired accelerator:\n<\/p>\n<pre>\n    LTEXT           \"Ca&amp;pacity:\",IDC_STATIC,7,6,31,9\n    COMBOBOX        IDC_CAPACITY,7,40,150,300,\n                    CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n<\/pre>\n<p>\nBut what if you don&#8217;t want a label to appear in front of\nthe control?\nFor example, the General property page of a file\nbegins with an unlabeled edit control that contains the name\nof the file.\nYou might have a dialog that contains a list view that you don&#8217;t\nwant to label because its meaning is implied by other controls\non the page or by the page layout.\n<\/p>\n<p>\nThe answer is to hide the label control but leave it enabled.\nThis keeps the accelerator active,\nallowing the user to press the accelerator to put focus\non the edit control or list view or whatever,\nbut removes the actual accelerator indicator from the screen.\n<\/p>\n<p>\nThis means that if you want to take a control off the dialog\nbecause you don&#8217;t want the user to invoke it at all,\nmerely hiding it won&#8217;t be enough, since the accelerator is\nstill active.\nIn addition to hiding the control, you also have to disable it.\n(Alternatively, you could destroy the control.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the suggestion box, Serge Wautier asked why accelerators for hidden controls remain active. He&#8217;s apparently rather insistent because he asked the question again a few months later. Asking the same question multiple times reduces the likelihood that I&#8217;ll answer it. Consider yourself lucky that I wrote this answer before I noticed the duplicate; otherwise [&hellip;]<\/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":[25],"class_list":["post-22113","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>In the suggestion box, Serge Wautier asked why accelerators for hidden controls remain active. He&#8217;s apparently rather insistent because he asked the question again a few months later. Asking the same question multiple times reduces the likelihood that I&#8217;ll answer it. Consider yourself lucky that I wrote this answer before I noticed the duplicate; otherwise [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/22113","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=22113"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/22113\/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=22113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=22113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=22113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}