{"id":3643,"date":"2013-08-01T07:00:00","date_gmt":"2013-08-01T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2013\/08\/01\/the-case-of-the-auto-hide-taskbar\/"},"modified":"2013-08-01T07:00:00","modified_gmt":"2013-08-01T07:00:00","slug":"the-case-of-the-auto-hide-taskbar","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20130801-00\/?p=3643","title":{"rendered":"The case of the auto-hide taskbar"},"content":{"rendered":"<p>\nA customer reported that their taskbar would sometimes\nspontaneously go into auto-hide mode.\nWhat made this particularly insidious was that they\nhad deployed a group policy to\nprevent users from changing the auto-hide state\n(because they never wanted the taskbar to auto-hide),\nso when the taskbar went into auto-hide mode,\nthere was no way to get it out of that mode!\n<\/p>\n<p>\nThe customer&#8217;s first investigation was to find out\nwhere the auto-hide state was recorded.\nA little bit of registry spelunking\n(because as far as these people are concerned,\n<i>everything<\/i> is in the registry)\nshowed that a single bit in the\n<code>StuckRects2<\/code> registry value controlled\nthe auto-hide setting.\nThey used\n<a HREF=\"http:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb896645.aspx\">\nProcess Monitor<\/a>\nand observed that it was Explorer that was updating the value.\nThat was as far as they could troubleshoot the problem\nand came to the Windows team for further guidance.\n<\/p>\n<p>\nIt turns out that watching the registry value get updated\ndoesn&#8217;t tell you anything interesting.\nExplorer always writes that value when you log off,\nand the value written is the taskbar&#8217;s current auto-hide state.\nThe real culprit is the person who <i>changed<\/i> the taskbar&#8217;s state,\ncausing Explorer to save the updated state at logoff.\nAnd that culprit is somebody who called\n<code>SHApp&shy;Bar&shy;Message<\/code> with the\n<code>ABM_SETSTATE<\/code> parameter,\nin order to turn on the <code>ABS_AUTOHIDE<\/code> bit.\n<\/p>\n<p>\nI warned you many years ago that\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2005\/05\/06\/415158.aspx\">\nthe auto-hide and always-on-top\nstates are user settings<\/a>,\nand programs should modify them only under the instructions of the user.\n<\/p>\n<p>\nThe support technician was able to put together an\ninstrumented version of the\n<code>SHApp&shy;Bar&shy;Message<\/code> function\nthat logged any attempt to put the taskbar into auto-hide mode.\n(This step took a little while because the first attempt wasn&#8217;t\nquite right and ended up not working.)\n<\/p>\n<p>\nA few days later, the support technician reported back:\nThe culprit was found with his hand in the cookie jar!\nOne of the applications the customer was using was indeed calling\n<code>SHApp&shy;Bar&shy;Message<\/code> with the\n<code>ABM_SETSTATE<\/code> parameter,\nand passing the\n<code>ABS_AUTOHIDE<\/code> flag to make the taskbar auto-hide,\nand the application never called the function again to restore\nit back to normal.\nResult:\nTaskbar goes to auto-hide and stays there.\n<\/p>\n<p>\nMind you, even if the application remember to set the auto-hide flag\nback to its original value, that still wouldn&#8217;t have been the correct\nsolution.\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2005\/06\/07\/426294.aspx\">\nSuppose two programs did this<\/a>.\n<\/p>\n<pre>\nbool fWasTaskbarAutoHide;\nOnStartup()\n{\n    fWasTaskbarAutoHide = GetTaskbarAutoHideState();\n    SetTaskbarAutoHide(true);\n}\nOnExit()\n{\n    SetTaskbarAutoHide(fWasTaskbarAutoHide);\n}\n<\/pre>\n<p>\nThe user first runs the other program, which remembers that the taskbar\nis not auto-hide, then sets it to auto-hide.\nNow the user runs your program, which remembers that the taskbar is\nauto-hide, and then sets the taskbar (redundantly) to auto-hide.\nThe user exits the first program, which sets the taskbar to normal.\nNow the taskbar is in normal state even though the your program wants\nit to be auto-hide.\nFinally, your program exits, and it &#8220;restores&#8221; the taskbar to auto-hide.\n<\/p>\n<p>\nThis is just\nanother case of\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2008\/12\/11\/9193695.aspx\">\nusing a global setting to solve a local problem<\/a>.\nThe local solution is to\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2005\/05\/05\/414910.aspx\">\ncreate a fullscreen window<\/a>,\nand the taskbar will get out of the way automatically.\n<\/p>\n<p>\nThe customer went to the online support forum for the program that was\nsetting the taskbar to auto-hide and forgetting to restore it.\nAnd, how about that,\nthere was a thread in that forum called something like\n&#8220;After I run Program&nbsp;X, my taskbar gets set to auto-hide.&#8221;\n<\/p>\n<p>\n<b>Bonus reading<\/b>:\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2012\/07\/05\/10326972.aspx\">\nHow your taskbar auto-hide settings can keep getting overwritten<\/a>.\nIt seems this problem happens a lot.\nThis is the sort of problem you get when you decide to\nexpose a user setting programmatically:\nApplications start messing with the setting when they shouldn&#8217;t.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer reported that their taskbar would sometimes spontaneously go into auto-hide mode. What made this particularly insidious was that they had deployed a group policy to prevent users from changing the auto-hide state (because they never wanted the taskbar to auto-hide), so when the taskbar went into auto-hide mode, there was no way 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":[26],"class_list":["post-3643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>A customer reported that their taskbar would sometimes spontaneously go into auto-hide mode. What made this particularly insidious was that they had deployed a group policy to prevent users from changing the auto-hide state (because they never wanted the taskbar to auto-hide), so when the taskbar went into auto-hide mode, there was no way to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/3643","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=3643"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/3643\/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=3643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=3643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=3643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}