Tooltip text in CFormView
-
Hi I am trying to display tool tip text on icons placed on CFormView. I am using these functions: ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText) BOOL CDashboardView :: OnToolTipText (UINT id, NMHDR *pNMHDR, LRESULT *pResult) { BOOL result = TRUE; /* Operation result */ CString strTipText; /* tool tip text */ UINT nID = -1; /* Identifier */ TOOLTIPTEXTA* pTTTA = NULL; TOOLTIPTEXTW* pTTTW = NULL; CPoint point; /* current cursor point */ pTTTA = (TOOLTIPTEXTA*)pNMHDR; pTTTW = (TOOLTIPTEXTW*)pNMHDR; nID = pNMHDR->idFrom; if (nID != 0 ) { // Identify button rect, copy text for (long ii = 0; ii < m_arrLineupBtnRect.GetSize(); ii++) { GetCursorPos (&point); ScreenToClient (&point); if (m_arrLineupBtnRect[ii].PtInRect(point)) { strTipText = m_sButtLineups[ii].m_strToolTip; } } // Copy tool tip text if (pNMHDR->code == TTN_NEEDTEXTA) { lstrcpyn(pTTTA->szText, strTipText, strTipText.GetLength()); } else { _mbstowcsz(pTTTW->szText, strTipText,strTipText.GetLength()); } *pResult = 0; } return result; } My problem is that the tool tip text has about 280characters. The program crashes at the line lstrcpyn(pTTTA->szText, strTipText, strTipText.GetLength()); It works fine for about 80 characters in tool tip text. Is there any limit for the tool tip text. Thanks Madhavi
-
Hi I am trying to display tool tip text on icons placed on CFormView. I am using these functions: ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText) BOOL CDashboardView :: OnToolTipText (UINT id, NMHDR *pNMHDR, LRESULT *pResult) { BOOL result = TRUE; /* Operation result */ CString strTipText; /* tool tip text */ UINT nID = -1; /* Identifier */ TOOLTIPTEXTA* pTTTA = NULL; TOOLTIPTEXTW* pTTTW = NULL; CPoint point; /* current cursor point */ pTTTA = (TOOLTIPTEXTA*)pNMHDR; pTTTW = (TOOLTIPTEXTW*)pNMHDR; nID = pNMHDR->idFrom; if (nID != 0 ) { // Identify button rect, copy text for (long ii = 0; ii < m_arrLineupBtnRect.GetSize(); ii++) { GetCursorPos (&point); ScreenToClient (&point); if (m_arrLineupBtnRect[ii].PtInRect(point)) { strTipText = m_sButtLineups[ii].m_strToolTip; } } // Copy tool tip text if (pNMHDR->code == TTN_NEEDTEXTA) { lstrcpyn(pTTTA->szText, strTipText, strTipText.GetLength()); } else { _mbstowcsz(pTTTW->szText, strTipText,strTipText.GetLength()); } *pResult = 0; } return result; } My problem is that the tool tip text has about 280characters. The program crashes at the line lstrcpyn(pTTTA->szText, strTipText, strTipText.GetLength()); It works fine for about 80 characters in tool tip text. Is there any limit for the tool tip text. Thanks Madhavi
I searched codeproject and found two articles World's Easiest Way to Create Multi-Line Tooltips[^] but this articles is for VB.NET it calculates length of tooltip and then split to lines,but other articles is with C++ CPPToolTip v2.1[^] I guess maybe it will be helpful for you.:)
WhiteSky