{"id":1083,"date":"2014-05-05T07:00:00","date_gmt":"2014-05-05T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2014\/05\/05\/getting-the-location-of-the-close-button-in-the-title-bar\/"},"modified":"2014-05-05T07:00:00","modified_gmt":"2014-05-05T07:00:00","slug":"getting-the-location-of-the-close-button-in-the-title-bar","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20140505-00\/?p=1083","title":{"rendered":"Getting the location of the Close button in the title bar"},"content":{"rendered":"<p>\nToday&#8217;s Little Program locates the &times; button in the corner\nof the window and, just to show that it found it,\ndisplays a balloon tip pointing at it.\n<\/p>\n<p>\nLet&#8217;s start with the program from last week,\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2014\/04\/28\/10520786.aspx\">\nthe one that displays a balloon tip<\/a>,\nthen make these changes:\n<\/p>\n<pre>\n<font COLOR=\"blue\">BOOL GetCloseButtonCenter(HWND hwnd, POINT *ppt)\n{\n TITLEBARINFOEX info = { sizeof(info) };\n if (!SendMessage(hwnd, WM_GETTITLEBARINFOEX, 0, (LPARAM)&amp;info))\n    return FALSE;\n if (info.rgstate[5] &amp; (STATE_SYSTEM_INVISIBLE |\n                            STATE_SYSTEM_OFFSCREEN |\n                            STATE_SYSTEM_UNAVAILABLE)) return FALSE;\n ppt-&gt;x = info.rgrect[5].left +\n             (info.rgrect[5].right - info.rgrect[5].left) \/ 2;\n ppt-&gt;y = info.rgrect[5].top +\n             (info.rgrect[5].bottom - info.rgrect[5].top) \/ 2;\n return TRUE;\n}<\/font>\n  case TEXT(' '):\n    if (<font COLOR=\"blue\">GetCloseButtonCenter(hwnd, &amp;pt)<\/font>) {\n      SendMessage(g_hwndTT, TTM_TRACKPOSITION, 0, MAKELPARAM(pt.x, pt.y));\n<\/pre>\n<p>\nInstead of positioning the balloon at the cursor position,\nwe put it at the center of the Close button.\nWe use the\n<code>WM_GET&shy;TITLE&shy;BAR&shy;INFO&shy;EX<\/code> message\nto obtain information about the window title bar,\nspecifically checking information about the Close button.\nAfter verifying that it is visible and on-screen and enabled,\nwe calculate its center point and return success.\n<\/p>\n<p>\nThe <code>WM_GET&shy;TITLE&shy;BAR&shy;INFO&shy;EX<\/code> message\nis new for Windows Vista.\nNext time, we&#8217;ll cook up a method that works on Windows&nbsp;2000\nand Windows&nbsp;XP.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s Little Program locates the &times; button in the corner of the window and, just to show that it found it, displays a balloon tip pointing at it. Let&#8217;s start with the program from last week, the one that displays a balloon tip, then make these changes: BOOL GetCloseButtonCenter(HWND hwnd, POINT *ppt) { TITLEBARINFOEX info [&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-1083","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Today&#8217;s Little Program locates the &times; button in the corner of the window and, just to show that it found it, displays a balloon tip pointing at it. Let&#8217;s start with the program from last week, the one that displays a balloon tip, then make these changes: BOOL GetCloseButtonCenter(HWND hwnd, POINT *ppt) { TITLEBARINFOEX info [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1083","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=1083"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1083\/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=1083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=1083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=1083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}