{"id":35593,"date":"2005-05-20T09:00:18","date_gmt":"2005-05-20T09:00:18","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/05\/20\/when-is-a-window-visible-yet-not-visible\/"},"modified":"2019-07-29T17:22:11","modified_gmt":"2019-07-30T00:22:11","slug":"when-is-a-window-visible-yet-not-visible","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050520-18\/?p=35593","title":{"rendered":"When is a window visible yet not visible?"},"content":{"rendered":"<p>\nToday, a quick puzzler.\n<\/p>\n<p>\nConsider the following code fragment:\n<\/p>\n<pre>\r\n ShowWindow(hwnd, SW_SHOWNORMAL);\r\n assert(IsWindowVisible(hwnd));\r\n<\/pre>\n<p>\nWe just showed the window, certainly it is visible, right?\nYet the assertion can fire (even in the absence of multi-threading).  Why?\n<\/p>\n<p>\nAnswer below &#8211; stop reading if you want to try to solve it yourself.\n<\/p>\n<p>\nTake a look at\n<a HREF=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winuser\/nf-winuser-iswindowvisible\">\nthe <code>IsWindowVisible<\/code> function<\/a>.\n<\/p>\n<blockquote CLASS=\"q\"><p>\nIf the specified window, its parent window, its parent&#8217;s parent window,\nand so forth, have the <code>WS_VISIBLE<\/code> style,\nthe return value is nonzero. Otherwise, the return value is zero.\n<\/p><\/blockquote>\n<p>\nThe <code>WS_VISIBLE<\/code> style indicates that this window is\nvisible in its parent.  But the parent itself might not be visible,\nin which case <code>IsWindowVisible<\/code> returns <code>FALSE<\/code>.\n<\/p>\n<p>\n[Raymond is currently on vacation; this message was pre-recorded.]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, a quick puzzler. Consider the following code fragment: ShowWindow(hwnd, SW_SHOWNORMAL); assert(IsWindowVisible(hwnd)); We just showed the window, certainly it is visible, right? Yet the assertion can fire (even in the absence of multi-threading). Why? Answer below &#8211; stop reading if you want to try to solve it yourself. Take a look at the IsWindowVisible function. [&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-35593","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Today, a quick puzzler. Consider the following code fragment: ShowWindow(hwnd, SW_SHOWNORMAL); assert(IsWindowVisible(hwnd)); We just showed the window, certainly it is visible, right? Yet the assertion can fire (even in the absence of multi-threading). Why? Answer below &#8211; stop reading if you want to try to solve it yourself. Take a look at the IsWindowVisible function. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/35593","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=35593"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/35593\/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=35593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=35593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=35593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}