Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tooltip bug in VC++ 5.0 w/SP2 (and a fix for it!)

4 views
Skip to first unread message

Keith Murray

unread,
Nov 9, 1997, 3:00:00 AM11/9/97
to

Hello all,

If you have a CDialogBar toolbar in your app and are expecting tooltips to
work, then you're in for a suprise.

This worked just great in VC++ 5.0 until I applied SP2. Suddenly the
tooltips on my CDialogBar toolbars wouldn't appear! So I started diffing
the MFC source files that changed and stepping through the tooltip code and
I discovered that they MFC developers changed to a new structure in every
essential place but one in WINCORE.CPP:

int CWnd::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
// find child window which hits the point
// (don't use WindowFromPoint, because it ignores disabled windows)
HWND hWndChild = _AfxChildWindowFromPoint(m_hWnd, point);
if (hWndChild != NULL)
{
// return positive hit if control ID isn't -1
int nHit = _AfxGetDlgCtrlID(hWndChild);

// hits against child windows always center the tip
if (pTI != NULL && pTI->cbSize >= sizeof(TOOLINFO))
/*

sizeof(TOOLINFO) should be sizeof(AfxOldTOOLINFO)

*/
{
// setup the TOOLINFO structure
pTI->hwnd = m_hWnd;
pTI->uId = (UINT)hWndChild;
pTI->uFlags |= TTF_IDISHWND;
pTI->lpszText = LPSTR_TEXTCALLBACK;

// set TTF_NOTBUTTON and TTF_CENTERTIP if it isn't a button
if (!(::SendMessage(hWndChild, WM_GETDLGCODE, 0, 0) & DLGC_BUTTON))
pTI->uFlags |= TTF_NOTBUTTON|TTF_CENTERTIP;
}
return nHit;
}
return -1; // not found
}

There are a few other toolbar files that were changed to reference this
AfxOldTOOLINFO structure in SP2. Someone simply forgot to update
WINCORE.CPP.

I've include a class definition for CFixedDialogBar that fixes this tooltip
problem. Just use this class instead of the regular CDialogBar class and
you're off and running.

Enjoy
Keith
Tripod Data Systems, Inc.
http://www.tdsway.com

begin 600 FixedDialogBar.cpp
<encoded_portion_removed>
end

begin 600 FixedDialogBar.h
<encoded_portion_removed>
end


0 new messages