CMFCToolTipCtrl doen't enter OnPaint when I use it in my self-draw CTreeCtrl
-
Non-modal ActiveX Control, a self-draw CMyTreeCtrl is shown on it. Now, I create a CMFCToolTipCtrl in my CMyTreeCtrl and I want to dynamically change the text color of Tooltip. I use SetParams in the ToolTip callback function and set new color/text . However, I can't get new color when the tooltip displayed. After I debug and found that it can't enter CMFCToolTipCtrl onPaint. If I use invalidate, then the whole ActiveX Control will flash rapidly. I inherited CMFCToolTipCtrl and found that WM_PAINT cannot be received in PreTranslateMessage. It can only receive WM_TIMER. Any other functions in afxtooltipctrl.h are not entered when the tooltip is shown. And CMyTreeCtrl can receive WM_PAINT. Could you help me find the reasion? Thanks a lot.
-
Non-modal ActiveX Control, a self-draw CMyTreeCtrl is shown on it. Now, I create a CMFCToolTipCtrl in my CMyTreeCtrl and I want to dynamically change the text color of Tooltip. I use SetParams in the ToolTip callback function and set new color/text . However, I can't get new color when the tooltip displayed. After I debug and found that it can't enter CMFCToolTipCtrl onPaint. If I use invalidate, then the whole ActiveX Control will flash rapidly. I inherited CMFCToolTipCtrl and found that WM_PAINT cannot be received in PreTranslateMessage. It can only receive WM_TIMER. Any other functions in afxtooltipctrl.h are not entered when the tooltip is shown. And CMyTreeCtrl can receive WM_PAINT. Could you help me find the reasion? Thanks a lot.
Hi, Are you creating the CMFCToolTipCtrl with the TTF_SUBCLASS flag[^]? If so then you should be able to capture the NM_CUSTOMDRAW message[^] and check for the
CDDS_PREPAINT
draw stage. You can use SetTextColor[^] to change the text color from there. Best Wishes, -David Delaune -
Non-modal ActiveX Control, a self-draw CMyTreeCtrl is shown on it. Now, I create a CMFCToolTipCtrl in my CMyTreeCtrl and I want to dynamically change the text color of Tooltip. I use SetParams in the ToolTip callback function and set new color/text . However, I can't get new color when the tooltip displayed. After I debug and found that it can't enter CMFCToolTipCtrl onPaint. If I use invalidate, then the whole ActiveX Control will flash rapidly. I inherited CMFCToolTipCtrl and found that WM_PAINT cannot be received in PreTranslateMessage. It can only receive WM_TIMER. Any other functions in afxtooltipctrl.h are not entered when the tooltip is shown. And CMyTreeCtrl can receive WM_PAINT. Could you help me find the reasion? Thanks a lot.
Member 14882671 wrote:
I use SetParams in the ToolTip callback function and set new color/text . However, I can't get new color when the tooltip displayed. After I debug and found that it can't enter CMFCToolTipCtrl onPaint. If I use invalidate, then the whole ActiveX Control will flash rapidly. I inherited CMFCToolTipCtrl and found that WM_PAINT cannot be received
There are virtual methods you could use to customize CMFCToolTipCtrl: [CMFCToolTipCtrl Class | Microsoft Docs](https://docs.microsoft.com/en-us/cpp/mfc/reference/cmfctooltipctrl-class?view=msvc-160#onfillbackground) and some other OnDraw... methods.