{"id":1133,"date":"2014-04-28T07:00:00","date_gmt":"2014-04-28T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2014\/04\/28\/showing-a-balloon-tip-at-a-specific-position-then-removing-it\/"},"modified":"2014-04-28T07:00:00","modified_gmt":"2014-04-28T07:00:00","slug":"showing-a-balloon-tip-at-a-specific-position-then-removing-it","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20140428-00\/?p=1133","title":{"rendered":"Showing a balloon tip at a specific position, then removing it"},"content":{"rendered":"<p>\nToday&#8217;s Little Program shows a balloon tip at a specific position,\nthen manually removes it.\n<\/p>\n<p>\nStart with our\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2003\/07\/23\/54576.aspx\">\nscratch program<\/a>\nand make these changes:<\/p>\n<pre>\n<font COLOR=\"blue\">#pragma comment(linker, \\\n    \"\\\"<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2007\/05\/31\/2995284.aspx\">\/manifestdependency<\/a>:type='Win32' \"\\\n    \"name='Microsoft.Windows.Common-Controls' \"\\\n    \"version='6.0.0.0' \"\\\n    \"processorArchitecture='*' \"\\\n    \"publicKeyToken='6595b64144ccf1df' \"\\\n    \"language='*'\\\"\")\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2003\/10\/16\/55344.aspx\">HWND g_hwndTT;<\/a>\nTOOLINFO g_ti;<\/font>\nBOOL\nOnCreate(HWND hwnd, LPCREATESTRUCT lpcs)\n{\n  <font COLOR=\"blue\">g_hwndTT = CreateWindow(TOOLTIPS_CLASS, nullptr,\n            WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,\n            0, 0, 0, 0, hwnd, nullptr, g_hinst, nullptr);\n  g_ti.uFlags = TTF_TRACK;\n  g_ti.hwnd = hwnd;\n  g_ti.lpszText = TEXT(\"Hi there\");\n  SendMessage(g_hwndTT, TTM_ADDTOOL, 0, (LPARAM)&amp;g_ti);<\/font>\n  return TRUE;\n}\n<font COLOR=\"blue\">void OnChar(HWND hwnd, TCHAR ch, int cRepeat)\n{\n  POINT pt;\n  switch (ch) {\n  case TEXT(' '):\n    if (GetCursorPos(&amp;pt)) {\n      SendMessage(g_hwndTT, TTM_TRACKPOSITION, 0, MAKELPARAM(pt.x, pt.y));\n      SendMessage(g_hwndTT, TTM_TRACKACTIVATE, TRUE, (LPARAM)&amp;g_ti);\n    }\n    break;\n  case 27: \/\/ ESCAPE\n    SendMessage(g_hwndTT, TTM_TRACKACTIVATE, FALSE, 0);\n    break;\n  }\n}\n  HANDLE_MESSAGE(hwnd, WM_CHAR, OnChar);<\/font>\n<\/pre>\n<p>\nWhen our main window is created, we also create a balloon-style\ntooltip and add a tracking tool.\nNormally, the tooltip control appears and disappears automatically,\nat a position of the tooltip&#8217;s choosing.\nTracking tooltips are managed manually,\nso you can specify exactly when and where they appear,\nand you also manually remove them from the screen.\nAt startup, we add the tool but do not show the balloon tooltip yet.\n<\/p>\n<p>\nWhen the user presses the space bar,\nwe get the current cursor position and tell the tracking tooltip\nto appear at exactly that location,\nthen we activate tracking mode.\nThe result:\nThe balloon tip appears, and the tip of the balloon points directly\nat the mouse cursor.\n<\/p>\n<p>\nWhen the user presses the <kbd>ESC<\/kbd> key,\nwe deactivate tracking mode, which removes the tooltip from the\nscreen.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s Little Program shows a balloon tip at a specific position, then manually removes it. Start with our scratch program and make these changes: #pragma comment(linker, \\ &#8220;\\&#8221;\/manifestdependency:type=&#8217;Win32&#8242; &#8220;\\ &#8220;name=&#8217;Microsoft.Windows.Common-Controls&#8217; &#8220;\\ &#8220;version=&#8217;6.0.0.0&#8242; &#8220;\\ &#8220;processorArchitecture=&#8217;*&#8217; &#8220;\\ &#8220;publicKeyToken=&#8217;6595b64144ccf1df&#8217; &#8220;\\ &#8220;language=&#8217;*&#8217;\\&#8221;&#8221;) HWND g_hwndTT; TOOLINFO g_ti; BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpcs) { g_hwndTT = CreateWindow(TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_ALWAYSTIP [&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-1133","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 shows a balloon tip at a specific position, then manually removes it. Start with our scratch program and make these changes: #pragma comment(linker, \\ &#8220;\\&#8221;\/manifestdependency:type=&#8217;Win32&#8242; &#8220;\\ &#8220;name=&#8217;Microsoft.Windows.Common-Controls&#8217; &#8220;\\ &#8220;version=&#8217;6.0.0.0&#8242; &#8220;\\ &#8220;processorArchitecture=&#8217;*&#8217; &#8220;\\ &#8220;publicKeyToken=&#8217;6595b64144ccf1df&#8217; &#8220;\\ &#8220;language=&#8217;*&#8217;\\&#8221;&#8221;) HWND g_hwndTT; TOOLINFO g_ti; BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpcs) { g_hwndTT = CreateWindow(TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_ALWAYSTIP [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1133","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=1133"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1133\/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=1133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=1133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=1133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}