Article ID: 156067
Article Last Modified on 11/21/2006
pTI->lpszText= MAKEINTRESOURCE(SomeId); pTI->hinst=AfxGetInstanceHandle();where pTI is a pointer to the TOOLINFO struct, will cause the problem. Setting the TOOLINFO struct members in this manner allows the programmer to specify a resource that the tooltip uses to get the text for the tooltip.
if (tiHit.lpszText != LPSTR_TEXTCALLBACK)
free(tiHit.lpszText);
Because lpszText is not set to LPSTR_TEXTCALLBACK, the free function is
called. However, a resource ID, rather than a string, was specified in the
OnToolHitTest() function, and therefore the assertion occurs.
pTI->lpszText = (char *)malloc(200, sizeof(char));
if (::LoadString(AfxGetInstanceHandle(),pTI->uId, pTI->lpszText,200)==0)
{
ASSERT(FALSE); //String resource doesn't exist
}
MFC frees the allocated buffer after it has added the tool (that is, after
it has sent the TTM_ADDTOOL message).
Additional query words: kbVC400bug tool tip
Keywords: kbbug kbfix kbnoupdate kbtooltip kbuidesign kbvc500fix KB156067