I have implemented tool tips seemingly successfully in an app which is MFC based and uses CPropertyPage. However after adding a button to open a dialog box called IDC_USERMSG
which contains a single CEdit control on one of the CPropety pages an Assert is thrown when the IDC_USERMSG
dialog is dismissed.
_AFXWIN_INLINE CWnd* CWnd::GetParent() const
{
ASSERT(::IsWindow(m_hWnd)); // Asserts here.
return CWnd::FromHandle(::GetParent(m_hWnd));
}
I belive this is because the IDC_USERMSG dialog no longer exsists at this stage because it has been closed.
Button/Tooltips implimented as follows.
BEGIN_MESSAGE_MAP(CUserData, CPropertyPage)
// Displays dialog when button pressed
ON_BN_CLICKED(IDC_USERMSG, &CUserData::OnBnClickedUsermsgbtn)
END_MESSAGE_MAP()
BOOL CUserData::OnInitDialog()
{
EnableToolTips(TRUE);
static CString ToolTip;
CTTCtrl.Create(this); // CToolTipCtrl CTTCtrl is a global
CTTCtrl.SetDelayTime(TTDT_AUTOPOP, 8000);
CTTCtrl.SetMaxTipWidth(ToolTipWidth);
ToolTip.LoadStringW(TT_REN);
CTTCtrl.AddTool( GetDlgItem( IDC_TT_REN), ToolTip );
return 0;
}
BOOL CUserData::PreTranslateMessage(MSG* pMsg)
{
CTTCtrl.RelayEvent( pMsg );
CDialog::PreTranslateMessage(pMsg);
// think I need some sort of filter here.
return CDialog::PreTranslateMessage(pMsg);
}
Call Stack
mfc90ud.dll!CWnd::GetParent() Line 297 + 0x2d bytes C++
mfc90ud.dll!CWnd::FilterToolTipMessage(tagMSG * pMsg=0x00155570) Line 392 + 0x8 bytes C++
mfc90ud.dll!CWnd::_FilterToolTipMessage(tagMSG * pMsg=0x00155570, CWnd * pWnd=0x0012fa78) Line 374 C++
mfc90ud.dll!CWnd::PreTranslateMessage(tagMSG * pMsg=0x00155570) Line 1070 C++
mfc90ud.dll!CDialog::PreTranslateMessage(tagMSG * pMsg=0x00155570) Line 56 + 0xc bytes C++
MyApp.exe!CUserData::PreTranslateMessage(tagMSG * pMsg=0x00155570) Line 495 C++