{"id":30723,"date":"2006-06-27T10:00:22","date_gmt":"2006-06-27T10:00:22","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2006\/06\/27\/using-custom-draw-in-tooltips-to-adjust-the-font\/"},"modified":"2006-06-27T10:00:22","modified_gmt":"2006-06-27T10:00:22","slug":"using-custom-draw-in-tooltips-to-adjust-the-font","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20060627-22\/?p=30723","title":{"rendered":"Using custom-draw in tooltips to adjust the font"},"content":{"rendered":"<p>\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/06\/26\/647365.aspx\">\nLast time, we looked at in-place tooltips<\/a>.\nIn that example, we finessed the font problem by\nsimply setting the destination font into the tooltip control.\nWe got away with that since we had only one tool.\nBut if you have multiple tools with different fonts,\nthen you can&#8217;t set a font into the tooltip control and\nexpect it to work for every tool.\nThat&#8217;s where custom draw comes in.\n<\/p>\n<p>\nStart with the program from last time, but this time,\nwe&#8217;ll set the font via custom-draw instead of setting it\nglobally.\n<\/p>\n<pre>\nBOOL\nOnCreate(HWND hwnd, LPCREATESTRUCT lpcs)\n{\n ...\n <font COLOR=\"blue\"><strike>\/\/ SetWindowFont(g_hwndTT, g_hfTT, FALSE);<\/strike><\/font>\n ...\n}\n<font COLOR=\"blue\">LRESULT\nOnTooltipCustomDraw(HWND hwnd, NMHDR *pnm)\n{\n LPNMTTCUSTOMDRAW pcd = (LPNMTTCUSTOMDRAW)pnm;\n if (pcd-&gt;nmcd.dwDrawStage == CDDS_PREPAINT) {\n  SelectFont(pcd-&gt;nmcd.hdc, g_hfTT);\n  return CDRF_NEWFONT;\n }\n return 0;\n}<\/font>\nLRESULT\nOnNotify(HWND hwnd, int idFrom, NMHDR *pnm)\n{\n if (pnm-&gt;hwndFrom == g_hwndTT) {\n  switch (pnm-&gt;code) {\n  <font COLOR=\"blue\">case NM_CUSTOMDRAW:\n   return OnTooltipCustomDraw(hwnd, pnm);<\/font>\n  case TTN_SHOW:\n   return OnTooltipShow(hwnd, pnm);\n  }\n }\n return 0;\n}\n<\/pre>\n<p>\nOf course, doing this is overkill in our case where we have\nonly one tool,\nso you&#8217;ll have to imagine that the tooltip is managing\nmultiple tool regions, each with a different font.\nWhen we get the <code>NM_CUSTOMDRAW<\/code> notification,\nwe respond to the <code>CDDS_PREPAINT<\/code> stage by\nchanging the font and returning the <code>CDRF_NEWFONT<\/code>\nflag (which is necessary when changing the font).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last time, we looked at in-place tooltips. In that example, we finessed the font problem by simply setting the destination font into the tooltip control. We got away with that since we had only one tool. But if you have multiple tools with different fonts, then you can&#8217;t set a font into the tooltip control [&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-30723","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Last time, we looked at in-place tooltips. In that example, we finessed the font problem by simply setting the destination font into the tooltip control. We got away with that since we had only one tool. But if you have multiple tools with different fonts, then you can&#8217;t set a font into the tooltip control [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/30723","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=30723"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/30723\/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=30723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=30723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=30723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}