2

I am working in plain old native C on Windows. No other platforms, no C++. (Yes, I'm a dinosaur.)

I am trying to find an example of what I think of as an "owner draw tooltip control" but that does not appear to exist. At least not for the standard Windows tooltip control. I have tried to search for a library or source that implements a custom tooltip control, but all I can find is things that extend controls in .NET (or in other environments that are not where I am working.)

My hope is to support markdown (or something like it) for the text in the tooltip window. Mostly, I want to clearly differentiate the title from the content, and have some limited formatting of the content (bold, italics, color, and columns, mostly.)

I don't expect a full solution here, I am just hoping that someone else has already found a solution and can point me to where they found it. Please?

Steve Valliere
  • 1,119
  • 7
  • 12
  • 2
    You are looking for a "custom drawn" tooltip, not owner drawn. As it stands your questions is probably too broad; but check this page (it's in C as an added bonus): https://www.stevenengelhardt.com/2007/08/29/custom-drawn-win32-tooltips/ – TheNextman Jun 13 '19 at 15:56
  • And there is the [official documentation](https://learn.microsoft.com/en-us/windows/desktop/controls/nm-customdraw-tooltip). – zett42 Jun 13 '19 at 19:17
  • @TheNextman, you should post your comment as an answer and I will accept and vote for it. That's exactly what I was looking for. Early in my searching I hit something that made me believe that I found only change the overall font colors, but not draw the entire tip myself. Thanks for the mental re-adjustment! – Steve Valliere Jun 13 '19 at 19:30

1 Answers1

4

Tooltips cannot be owner drawn, but they can be "custom drawn".

Custom drawn Win32 controls allow you to override the built-in drawing by receiving and responding to the NM_CUSTOMDRAW notification. You can read about custom draw here.

You can refer to the specific documentation on the tooltip control, see:

NM_CUSTOMDRAW (tooltip) notification code

Finally, here is a good tutorial demonstrating the whole thing in C.

TheNextman
  • 12,428
  • 2
  • 36
  • 75
  • 1
    It never occurred to me to allow the original tip to draw itself using the same foreground/background (effectively drawing invisibly) and then drawing what I want right over that, but that's how the example works. Thanks! – Steve Valliere Jun 14 '19 at 10:50