{"id":25023,"date":"2007-09-21T10:00:00","date_gmt":"2007-09-21T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2007\/09\/21\/whats-the-bs_pushlike-button-style-for\/"},"modified":"2007-09-21T10:00:00","modified_gmt":"2007-09-21T10:00:00","slug":"whats-the-bs_pushlike-button-style-for","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20070921-00\/?p=25023","title":{"rendered":"What&#039;s the BS_PUSHLIKE button style for?"},"content":{"rendered":"<p>\nOne of the lesser-known button styles is <code>BS_PUSHLIKE<\/code>.\n<\/p>\n<blockquote CLASS=\"q\"><p>\nMakes a button (such as a check box, three-state check box, or radio button)\nlook and act like a push button.\nThe button looks raised when it isn&#8217;t pushed or checked,\nand sunken when it is pushed or checked.\n<\/p><\/blockquote>\n<p>\nIn other words, you add this style to a check box or radio button\nto make it <i>look like<\/i> a push button even though it will continue\nto <i>act like<\/i> a check box or radio button.\n<\/p>\n<table BORDER=\"1\" RULES=\"all\" STYLE=\"border-collapse: collapse\" CELLPADDING=\"3\">\n<tr>\n<th><\/td>\n<th VALIGN=\"baseline\">Check box<\/th>\n<th VALIGN=\"baseline\">Check box<br \/>push-like<\/th>\n<th VALIGN=\"baseline\">Radio button<\/th>\n<th VALIGN=\"baseline\">Radio button<br \/>push-like<\/th>\n<\/tr>\n<tr STYLE=\"height: 2em\">\n<th>Unselected<\/th>\n<td BGCOLOR=\"#C0C0C0\">Label<\/td>\n<td BGCOLOR=\"#C0C0C0\"><span STYLE=\"border: outset;padding: .25ex 1ex .25ex 1ex\">Label<\/span><\/td>\n<td BGCOLOR=\"#C0C0C0\">Label<\/td>\n<td BGCOLOR=\"#C0C0C0\"><span STYLE=\"border: outset;padding: .25ex 1ex .25ex 1ex\">Label<\/span><\/td>\n<\/tr>\n<tr STYLE=\"height: 2em\">\n<th>Selected<\/th>\n<td BGCOLOR=\"#C0C0C0\">Label<\/td>\n<td BGCOLOR=\"#C0C0C0\"><span STYLE=\"border: inset;padding: .25ex 1ex .25ex 1ex\">Label<\/span><\/td>\n<td BGCOLOR=\"#C0C0C0\">Label<\/td>\n<td BGCOLOR=\"#C0C0C0\"><span STYLE=\"border: inset;padding: .25ex 1ex .25ex 1ex\">Label<\/span><\/td>\n<\/tr>\n<\/table>\n<p>\nAside from the appearance, the other checkbox and\nradio button behaviors are preserved.\nEach time you click an automatic check box, it toggles\nbetween unselected and selected; it&#8217;s just that instead\nof hiding and showing the check-mark, it pops the button out\nand pushes the button in.\nSimilarly, the automatic radio button becomes selected when\nyou click on it and becomes deselected when you select another\nradio button in the group.\nAll that changed is the visuals.\n<\/p>\n<p>\nLet&#8217;s illustrate this with a quick sample program.\nFirst, we&#8217;ll use traditional check boxes and radio buttons.\n<\/p>\n<pre>\n1 DIALOG 64, 64, 100, 70\nSTYLE WS_CAPTION | WS_SYSMENU\nCAPTION \"Demo\"\nFONT 8, \"MS Shell Dlg\"\nBEGIN\n    AUTORADIOBUTTON \"Search &amp;forward\", 100, 4, 9,\n              75, 14, WS_GROUP | WS_TABSTOP\n    AUTORADIOBUTTON \"Search &amp;backward\", 101, 4, 27,\n              75, 14\n    AUTOCHECKBOX \"&amp;Ignore case\", 102, 4, 45,\n              75, 14, WS_TABSTOP\nEND\nINT_PTR CALLBACK DlgProc(\n    HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n switch (uMsg) {\n  case WM_INITDIALOG: return TRUE;\n  case WM_CLOSE: EndDialog(hdlg, 1); break;\n }\n return FALSE;\n}\nint WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,\n                   LPSTR lpCmdLine, int nShowCmd)\n{\n  DialogBox(hinst, MAKEINTRESOURCE(1), 0, DlgProc);\n  return 0;\n}\n<\/pre>\n<p>\nWhen you run this program, you get two radio buttons and\na check box, and there&#8217;s nothing special about them at all.\nBut add the <code>BS_PUSHLIKE<\/code> style&#8230;\n<\/p>\n<pre>\n1 DIALOG 64, 64, 100, 70\nSTYLE WS_CAPTION | WS_SYSMENU\nCAPTION \"Demo\"\nFONT 8, \"MS Shell Dlg\"\nBEGIN\n    AUTORADIOBUTTON \"Search &amp;forward\", 100, 4, 9,\n              75, 14, WS_GROUP | WS_TABSTOP <font COLOR=\"blue\">| BS_PUSHLIKE<\/font>\n    AUTORADIOBUTTON \"Search &amp;backward\", 101, 4, 27,\n              75, 14<font COLOR=\"blue\">, BS_PUSHLIKE<\/font>\n    AUTOCHECKBOX \"&amp;Ignore case\", 102, 4, 45,\n              75, 14, WS_TABSTOP <font COLOR=\"blue\">| BS_PUSHLIKE<\/font>\nEND\n<\/pre>\n<p>\nand now the radio buttons and check box look like push buttons.\nBut if you click on them, they still behave like two radio buttons\nand a check box.\nif you select &#8220;Search forward&#8221;, then &#8220;Search backward&#8221; automatically\nde-selects itself, and vice versa.\nEach time you click on &#8220;Ignore case&#8221;, it toggles between pushed-in\nand popped-out.\n<\/p>\n<p>\nThe visuals are kind of confusing, however, if you have\n<a HREF=\"http:\/\/windowssdk.msdn.microsoft.com\/en-us\/library\/ms649781.aspx\">\nenabled Windows&nbsp;XP visual styles<\/a>,\nfor when you hover over a button, the theme engine will draw\nthe button in its &#8220;hover&#8221; appearance, which causes it to pop out\neven though the button really is pushed in.\nYou have to move the mouse away from the button to see that it\nreally is pushed in.\nPersonally, I consider this a bug.\nThe situation in Windows&nbsp;Vista is only slightly better;\nit&#8217;s still pretty bad.\n<\/p>\n<p>\nPush-like buttons are not used much since they duplicate the\nsemantics of radio buttons and check boxes while presenting\na deceptive visual appearance.\nSince they look like push buttons, users naturally expect them\nto behave like push buttons, and then when they don&#8217;t,\nthings get confusing.\nThe only case I can think of off the top of my head where\npush-like buttons actually match with user expectations is\nin toolbars, where\nthere is a long-standing convention of using push-like buttons\nin toolbars instead of radio buttons and check boxes.\n(Fortunately, toolbars manage their own buttons and don&#8217;t\nsuffer from the confusing hover-appearance behavior I discussed above.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the lesser-known button styles is BS_PUSHLIKE. Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn&#8217;t pushed or checked, and sunken when it is pushed or checked. In other words, you add this style to [&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-25023","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>One of the lesser-known button styles is BS_PUSHLIKE. Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn&#8217;t pushed or checked, and sunken when it is pushed or checked. In other words, you add this style to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/25023","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=25023"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/25023\/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=25023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=25023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=25023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}