{"id":35703,"date":"2005-05-05T08:58:04","date_gmt":"2005-05-05T08:58:04","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/05\/05\/how-do-i-cover-the-taskbar-with-a-fullscreen-window\/"},"modified":"2005-05-05T08:58:04","modified_gmt":"2005-05-05T08:58:04","slug":"how-do-i-cover-the-taskbar-with-a-fullscreen-window","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050505-04\/?p=35703","title":{"rendered":"How do I cover the taskbar with a fullscreen window?"},"content":{"rendered":"<p>\nFor some reason,\n<a HREF=\"http:\/\/groups.google.com\/groups?selm=jko6s0pgvb9mnehtrgkd0louoe284jqojf@4ax.com\">\npeople think too hard<\/a>.\nIf you want to create\na fullscreen window that covers the taskbar, just create a fullscreen\nwindow and the taskbar will automatically get out of the way.\nDon&#8217;t go around hunting for the taskbar and poking it; let it do its thing.\n<\/p>\n<p>\nAs always, start with\n<a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2003\/07\/23\/54576.aspx\">\nthe scratch program<\/a> and add the following:\n<\/p>\n<pre>\nHWND CreateFullscreenWindow(HWND hwnd)\n{\n HMONITOR hmon = MonitorFromWindow(hwnd,\n                                   MONITOR_DEFAULTTONEAREST);\n MONITORINFO mi = { sizeof(mi) };\n if (!GetMonitorInfo(hmon, &amp;mi)) return NULL;\n return CreateWindow(TEXT(\"static\"),\n       TEXT(\"something interesting might go here\"),\n       WS_POPUP | WS_VISIBLE,\n       mi.rcMonitor.left,\n       mi.rcMonitor.top,\n       mi.rcMonitor.right - mi.rcMonitor.left,\n       mi.rcMonitor.bottom - mi.rcMonitor.top,\n       hwnd, NULL, g_hinst, 0);\n}\nvoid OnChar(HWND hwnd, TCHAR ch, int cRepeat)\n{\n if (ch == TEXT(' ')) {\n  CreateFullscreenWindow(hwnd);\n }\n}\n    HANDLE_MSG(hwnd, WM_CHAR, OnChar);\n<\/pre>\n<p>\nNote that this sample program doesn&#8217;t worry about destroying that\nfullscreen window or preventing the user from creating more than one.\nIt&#8217;s just a sample.\nThe point is seeing how the <code>CreateFullScreenWindow<\/code> function\nis written.\n<\/p>\n<p>\nWe use\n<a HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/gdi\/monitor_2m5z.asp\">\nthe <code>MonitorFromWindow<\/code> function<\/a>\nto figure out which monitor we should go fullscreen to.\nNote that in a multiple monitor system, this might not be the same\nmonitor that the taskbar is on.  Fortunately, we don&#8217;t have to worry\nabout that; the taskbar figures it out.\n<\/p>\n<p>\nI&#8217;ve seen people hunt for the taskbar window and then do\na <code>ShowWindow(hwndTaskbar, SW_HIDE)<\/code> on it.\nThis is nuts for many reasons.\n<\/p>\n<p>\nFirst is a mental exercise you should always use when evaluating\ntricks like this: &#8220;What if two programs tried this trick?&#8221;\nNow you have two programs both of which think they are in charge\nof hiding and showing the taskbar, neither of which is coordinating\nwith the other.  The result is a mess.  One program hides\nthe taskbar, then the other does, then the first decides it&#8217;s finished\nso it unhides the taskbar, but the second program wasn&#8217;t finished yet\nand gets a visible taskbar when it thought it should be hidden.\nThings only go downhill from there.\n<\/p>\n<p>\nSecond, what if your program crashes before it gets a chance\nto unhide the taskbar?\nThe taskbar is now permanently hidden\nand the user has to log off and back on to get their taskbar back.\nThat&#8217;s not very nice.\n<\/p>\n<p>\nThird, what if there is no taskbar at all?\nIt is common in Terminal Server scenarios to\n<a HREF=\"http:\/\/www.microsoft.com\/technet\/prodtechnol\/windowsserver2003\/library\/ServerHelp\/1a7b1894-e095-4cbc-9a9d-a8ae14e2a1bd.mspx\">\nrun programs by themselves without Explorer<\/a>\n[<a HREF=\"http:\/\/web.archive.org\/web\/20030713202609\/http:\/\/www.microsoft.com\/windowsxp\/home\/using\/productdoc\/en\/mstsc_start_program.asp\">archived<\/a>].\nIn this configuration, there is no Explorer, no taskbar.\nOr maybe you&#8217;re running on a future version of Windows\nthat doesn&#8217;t have a taskbar,\nit having been replaced by some other mechanism.\nWhat will your program do now?\n<\/p>\n<p>\nDon&#8217;t do any of this messing with the taskbar.\nJust create your fullscreen window and let the taskbar do its thing\nautomatically.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For some reason, people think too hard. If you want to create a fullscreen window that covers the taskbar, just create a fullscreen window and the taskbar will automatically get out of the way. Don&#8217;t go around hunting for the taskbar and poking it; let it do its thing. As always, start with the scratch [&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-35703","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>For some reason, people think too hard. If you want to create a fullscreen window that covers the taskbar, just create a fullscreen window and the taskbar will automatically get out of the way. Don&#8217;t go around hunting for the taskbar and poking it; let it do its thing. As always, start with the scratch [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/35703","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=35703"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/35703\/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=35703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=35703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=35703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}