{"id":92702,"date":"2015-12-24T07:00:00","date_gmt":"2015-12-24T22:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=92702"},"modified":"2019-03-13T12:23:11","modified_gmt":"2019-03-13T19:23:11","slug":"20151224-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20151224-00\/?p=92702","title":{"rendered":"Why does my in-place tooltip dismiss itself as soon as it appears?"},"content":{"rendered":"<p>One subtlety in the use of <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2006\/06\/26\/647365.aspx\">in-place tooltips<\/a> is that you should create the tooltip with the <code>WS_EX_TRANSPARENT<\/code> extended style. <\/p>\n<p>This style <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2010\/12\/30\/10110077.aspx\">makes the window invisible to hit-testing<\/a>, which is a good thing here. The code that decides when to show and hide an in-place tooltip goes like this: <\/p>\n<pre>\nPOINT ptCursor;\nGetCursorPos();\nHWND hwnd = WindowFromPoint(ptCursor);\nif (hwnd == the_thing_that_needs_a_tooltip) {\n show_the_tooltip();\n} else {\n hide_the_tooltip();\n}\n<\/pre>\n<p>If the mouse enters the thing that needs a tooltip, then we show the tooltip. If the mouse leaves the thing that needs a tooltip, then we hide the tooltip. <\/p>\n<p>Now let&#8217;s see what happens if you forget the extended style. <\/p>\n<ul>\n<li>What window is the mouse currently over? &rarr; The item that needs an in-place tooltip. \n<li>Is that the thing that needs a tooltip? &rarr; Yes: Show the tooltip. \n<li>What window is the mouse currently over? &rarr; The tooltip window. \n<li>Is that the thing that needs a tooltip? &rarr; No: Hide the tooltip. \n<li>What window is the mouse currently over? &rarr; The item that needs an in-place tooltip. \n<li>Is that the thing that needs a tooltip? &rarr; Yes: Show the tooltip. \n<li>What window is the mouse currently over? &rarr; The tooltip window. \n<li>Is that the thing that needs a tooltip? &rarr; No: Hide the tooltip. \n<li>&#8230; <\/ul>\n<p>Oops, the tooltip keeps flashing in and out. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Because it&#8217;s detecting itself.<\/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-92702","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Because it&#8217;s detecting itself.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/92702","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=92702"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/92702\/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=92702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=92702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=92702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}