goodvibration
goodvibration

Reputation: 6206

Tooltip is displayed for dialog box but not for child window

I'm working on an MFC project (old technology, I know).

In my dialog-box class (derived from CDialog) I have:

CToolTipCtrl m_cToolTipCtrl;
CWnd         m_cImageWindow;

In the class OnInitDialog function I do:

m_cToolTipCtrl.Create(this);
m_cImageWindow.CreateEx(...);
m_cToolTipCtrl.AddTool(this,_T("Parent"));
m_cToolTipCtrl.AddTool(&m_cImageWindow,_T("Child"));

In the class PreTranslateMessage function I do:

m_cToolTipCtrl.RelayEvent(pMsg);

When I run the project, the "Parent" tooltip is displayed whenever I hover within the parent window, but the "Child" tooltip is not displayed whenever I hover within the child window.

I have originally tried this without the "Parent" tooltip and it didn't work, so it is obviously not a matter of the "Parent" tooltip masking the "Child" tooltip.

I think that events are relayed only to the parent window, but I'm not really sure how to tackle this problem.

Putting a breakpoint in the PreTranslateMessage function is useless, since it stops eminently on every event that the application receives. How can I investigate this problem?

Upvotes: 2

Views: 730

Answers (1)

goodvibration
goodvibration

Reputation: 6206

Found the answer:

Simply add the SS_NOTIFY flag to the child window style when creating it.

For example:

m_cImageWindow.CreateEx(0,WC_STATIC,NULL,WS_CHILD|SS_NOTIFY,{0,0,0,0},this,0);

Upvotes: 3

Related Questions