2

After I searched how to color the tooltip text or background I found these functions:

  • SetTipTextColor()
  • SetTipBkColor()

But none of them worked with me !! Is there another way to do it or is my code missing something? Please let me know :)

Here is the code I have tried in OnInitDialog():

CToolTipCtrl tp;
tp.Create(this);
tp.AddTool(&m_Button1, L"Hello, World!", &rect, 1);
tp.SetTipBkColor(RGB(125, 125, 125));
tp.SetTipTextColor(RGB(200, 0, 0));
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • [Manipulating the Tool Tip Control](https://learn.microsoft.com/en-us/cpp/mfc/manipulating-the-tool-tip-control?view=vs-2019) – RonTLV Jul 14 '19 at 11:11
  • i saw this before but it's not what i asked about – Ibrahim T Eslim Jul 14 '19 at 11:19
  • You don't show the context of your `tp` variable. Have you have it a member variable? This is implied in this example: https://vcpptips.wordpress.com/tag/settipbkcolor/ – Andrew Truckle Jul 14 '19 at 14:46
  • i change it typically as the example but it still doesn't work !! – Ibrahim T Eslim Jul 14 '19 at 15:30
  • 1
    From [`TTM_SETTIPTEXTCOLOR`](https://learn.microsoft.com/en-us/windows/win32/controls/ttm-settiptextcolor): "When visual styles are enabled, this message has no effect." Same for `TTM_SETTIPBKCOLOR`. Use [NM_CUSTOMDRAW (tooltip)](https://learn.microsoft.com/en-us/windows/win32/controls/nm-customdraw-tooltip). – zett42 Jul 14 '19 at 16:50
  • Possible duplicate of [Custom Tooltip Formatting](https://stackoverflow.com/questions/56583767/custom-tooltip-formatting) – zett42 Jul 14 '19 at 16:53
  • Just a suggestion, create your own colorizable tooltip control by deriving from `CToolTipCtrl`, inside the class add a handler like `ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)` to the message table and draw the tooltip according to the colors you have set. – zett42 Jul 14 '19 at 16:59
  • so you mean i can't color it using CToolTipCtrl and i have to use another tooltip control (CustomDraw) ?! – Ibrahim T Eslim Jul 14 '19 at 18:28
  • Yes, `SetTipBkColor()` and `SetTipTextColor()` don't work anymore (propably since WinXP introduced visual styles). You can handle `NM_CUSTOMDRAW` either in the parent dialog of the tooltip control or in a class derived from `CToolTipCtrl` (using message reflection). – zett42 Jul 14 '19 at 18:43
  • but we can't change the visual style to make it works or those methods `SetTipBkColor()` and `SetTipTextColor()` won't work for ever ?! or we can't change anything in Visual Styles primarily !؟ – Ibrahim T Eslim Jul 14 '19 at 21:09
  • You can try [`SetWindowTheme(hwnd, L" ", L" ");`](https://learn.microsoft.com/en-us/windows/win32/controls/cookbook-overview#turning-off-visual-styles) but the control will propably look very ugly. – zett42 Jul 15 '19 at 07:10

0 Answers0