{"id":34713,"date":"2005-08-04T10:00:10","date_gmt":"2005-08-04T10:00:10","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/08\/04\/double-clicking-radio-buttons\/"},"modified":"2005-08-04T10:00:10","modified_gmt":"2005-08-04T10:00:10","slug":"double-clicking-radio-buttons","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050804-10\/?p=34713","title":{"rendered":"Double-clicking radio buttons"},"content":{"rendered":"<p><P>\nA subtlety that adds a level of polish to your dialogs\nis supporting double-clicked radio buttons as an abbreviation\nfor &#8220;select + OK&#8221;.\n(Or &#8220;select + Next&#8221; or\n&#8220;select + Finish&#8221; if the page is part of a wizard.)\n<\/P>\n<P>\nConsider the following dialog template and associated\ndialog procedure:\n<\/P>\n<PRE>\n1 DIALOGEX DISCARDABLE  32, 32, 200, 76\nSTYLE DS_MODALFRAME |  WS_POPUP |\n      WS_VISIBLE | WS_CAPTION | WS_SYSMENU\nCAPTION &#8220;Sample&#8221;\nFONT 8, &#8220;MS Shell Dlg&#8221;\nBEGIN\n LTEXT &#8220;A mumbler is needed.&#8221;,-1,7,8,100,10\n AUTORADIOBUTTON &#8220;Do not &amp;obtain a mumber now&#8221;,\n                 100,17,24,180,10\n AUTORADIOBUTTON &#8220;Obtain a mumbler auto&amp;matically&#8221;,\n                 101,17,34,180,10\n AUTORADIOBUTTON &#8220;&amp;Enter mumbler manually&#8221;,\n                 102,17,44,180,10\n DEFPUSHBUTTON &#8220;OK&#8221;,IDOK,92,58,50,14\n PUSHBUTTON &#8220;Cancel&#8221;,IDCANCEL,146,58,50,14\nEND<\/p>\n<p>INT_PTR CALLBACK DlgProc(HWND hdlg, UINT uMsg,\n                         WPARAM wParam, LPARAM lParam)\n{\n switch (uMsg) {\n case WM_INITDIALOG:\n  CheckRadioButton(hdlg, 100, 102, 100);\n  return TRUE;\n case WM_COMMAND:\n  switch (GET_WM_COMMAND_ID(wParam, lParam)) {\n  case IDOK:\n   for (int i = 100; i &lt;= 102; i++) {\n    if (IsDlgButtonChecked(hdlg, i)) EndDialog(hdlg, i);\n   }\n   break;\n  case IDCANCEL:\n   EndDialog(hdlg, -1);\n   break;\n  }\n }\n return FALSE;\n}\n<\/PRE>\n<P>\nThis is pretty standard unexciting dialog box that asks the user\nto select an option from a list.  Notice that double-clicking\nthe radio button doesn&#8217;t do anything special.  We can fix that.\n<\/P>\n<PRE>\n1 DIALOGEX DISCARDABLE  32, 32, 200, 76\nSTYLE DS_MODALFRAME |  WS_POPUP |\n      WS_VISIBLE | WS_CAPTION | WS_SYSMENU\nCAPTION &#8220;Sample&#8221;\nFONT 8, &#8220;MS Shell Dlg&#8221;\nBEGIN\n LTEXT &#8220;A mumbler is needed.&#8221;,-1,7,8,100,10\n AUTORADIOBUTTON &#8220;Do not &amp;obtain a mumber now&#8221;,\n                 100,17,24,180,10<FONT COLOR=\"blue\">,BS_NOTIFY<\/FONT>\n AUTORADIOBUTTON &#8220;Obtain a mumbler auto&amp;matically&#8221;,\n                 101,17,34,180,10<FONT COLOR=\"blue\">,BS_NOTIFY<\/FONT>\n AUTORADIOBUTTON &#8220;&amp;Enter mumbler manually&#8221;,\n                 102,17,44,180,10<FONT COLOR=\"blue\">,BS_NOTIFY<\/FONT>\n DEFPUSHBUTTON &#8220;OK&#8221;,IDOK,92,58,50,14\n PUSHBUTTON &#8220;Cancel&#8221;,IDCANCEL,146,58,50,14\nEND<\/p>\n<p>INT_PTR CALLBACK DlgProc(HWND hdlg, UINT uMsg,\n                         WPARAM wParam, LPARAM lParam)\n{\n switch (uMsg) {\n case WM_INITDIALOG:\n  CheckRadioButton(hdlg, 100, 102, 100);\n  return TRUE;\n case WM_COMMAND:\n  switch (GET_WM_COMMAND_ID(wParam, lParam)) {\n  case IDOK:\n   for (int i = 100; i &lt;= 102; i++) {\n    if (IsDlgButtonChecked(hdlg, i)) EndDialog(hdlg, i);\n   }\n   break;\n  case IDCANCEL:\n   EndDialog(hdlg, -1);\n   break;\n<FONT COLOR=\"blue\">  case 100:\n  case 101:\n  case 102:\n   if (GET_WM_COMMAND_CMD(wParam, lParam) == BN_DBLCLK) {\n    EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam));\n   }\n   break;<\/FONT>\n  }\n }\n return FALSE;\n}\n<\/PRE>\n<P>\nWe added the <CODE>BS_NOTIFY<\/CODE> style to the radio buttons,\nwhich enables the extended notifications (everything other than\n<CODE>BN_CLICKED<\/CODE>).  When we receive a <CODE>WM_COMMAND<\/CODE>\nmessage for a radio button specifying that the operation was\n<CODE>BN_DBLCLK<\/CODE>, we automatically click the OK button.\n(For a wizard, we would automatically click the Next or\nFinish button, as appropriate.)\n<\/P>\n<P>\nNote that double-click as a shortcut for select-and-OK\nshould be used only for dialogs or wizard pages where the\nonly relevant controls are radio buttons (and the OK and Cancel\nbuttons).\nIf there are controls on the page other than the radio button,\nthen you have to wait for the OK because the user might want\nto manipulate those other controls too.\n<\/P>\n<P>\nThis &#8220;double-click means select-and-OK&#8221; shortcut can also be\nused if the only thing on the dialog is a list box or list view\nfrom with the user is being asked to select one item.\nIf the user double-clicks an item from the list,\ntreat it as select-and-OK.\n<\/P>\n<P>\nThe dialog boxes in Explorer are rather inconsistent in their\nsupport for double-clicked radio buttons.\nThe Office and Money teams do a much better job.\n<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A subtlety that adds a level of polish to your dialogs is supporting double-clicked radio buttons as an abbreviation for &#8220;select + OK&#8221;. (Or &#8220;select + Next&#8221; or &#8220;select + Finish&#8221; if the page is part of a wizard.) Consider the following dialog template and associated dialog procedure: 1 DIALOGEX DISCARDABLE 32, 32, 200, 76 [&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-34713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A subtlety that adds a level of polish to your dialogs is supporting double-clicked radio buttons as an abbreviation for &#8220;select + OK&#8221;. (Or &#8220;select + Next&#8221; or &#8220;select + Finish&#8221; if the page is part of a wizard.) Consider the following dialog template and associated dialog procedure: 1 DIALOGEX DISCARDABLE 32, 32, 200, 76 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/34713","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=34713"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/34713\/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=34713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=34713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=34713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}