Search code examples
cwinapitabstabitem

notification code for mouse over a tab item


I have a tab control created by CreateWindowEx(NULL, WC_TABCONTROL,...). I would like to have a notification when a mouse is over a tab item. The tab control has the style TCS_TOOLTIPS and when the mouse is over a tab item for an amount TTDT_INITIAL ms (whose default value is double click time), it will display a tooltip.

But I also need a notification immediately when a mouse is over a tab item. But I don't want to modify the TTDT_INITIAL value. In fact, when a mouse is over a non-selected tab item, it will change the color to blue by default. But I can not find the notification (and its receiver) for this thing.

So I would like to know if there is a way to be notified immediately when a mouse is over a tab item (winapi only).


Solution

  • There is no notification for that particular purpose. The tabs are not their own controls, the entire TabControl as a whole is one control. What you can do is have your window procedure for the TabControl catch WM_MOUSEMOVE messages, and then call TabCtrl_HitTest() to determine which tab is currently underneath the mouse. Keep track of the current tab so you can detect when the mouse moves across a tab boundary onto a new tab.