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

Tracking tooltip under MFC

300 views
Skip to first unread message

UI Guy

unread,
Feb 17, 2005, 12:31:38 AM2/17/05
to
For a static control in a dialog, I want to create a tracking tooltip,
which is on whenever the mouse is stationary in the control for >200
msec, and which moves as the mouse is moved within the control.

Using MFC, I cannot get the tracking tooltip to display at all,
although I can get normal (i e, not tracking) tooltips to work fine.

Here's a summary of what I'm doing now. The dialog is MyDialog, and the
tool is a static control with ID=IDC_Tool.

In MyDialog.h:
CToolTipCtrl toolTipCtrl;

In MyDialog::OnInitDialog:
toolTipCtrl.Create(this,TTS_ALWAYSTIP | TTF_TRACK | TTF_ABSOLUTE);
CWnd *pWnd=GetDlgItem(id);
TOOLINFO ti;
ti.cbSize = sizeof (TOOLINFO);
ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
ti.rect.left = ti.rect.top = ti.rect.bottom = ti.rect.right = 0;
ti.hwnd = pWnd->GetParent ()->GetSafeHwnd ();
ti.uId = (UINT) pWnd->GetSafeHwnd ();
ti.hinst = AfxGetInstanceHandle ();
ti.lpszText = (LPTSTR) pszText;

SendMessage (TTM_ADDTOOL, 0, (LPARAM) &ti);
SendMessage(TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);

GetDlgItem(IDC_Tool)->EnableTrackingToolTips(TRUE);
toolTipCtrl.Activate(true);

In MyDialog::OnMouseMove(UINT nFlags, CPoint point):
RECT windowRect;
GetDlgItem(IDC_Tool)->GetWindowRect(&windowRect );
if( PtInRect( &windowRect, point ))
{
::SendMessage(GetDlgItem(IDC_Tool)->m_hWnd,
TTM_TRACKPOSITION,
0,
(LPARAM)MAKELPARAM(point.x+30,point.y+30));
}
else CDialog::OnMouseMove(nFlags, point);

Ivo

unread,
Feb 17, 2005, 11:41:26 AM2/17/05
to
I had a similar problem when using tracking tooltips. Turns out I was using _WIN32_WINNT=0x501 on Win 2000. In that case the TOOLINFO structure includes an additional (undocumented) member, which Win 2000 (and probably older) doesn't recognize. Try replacing sizeof(TOOLINFO) with TTTOOLINFOA_V2_SIZE or TTTOOLINFOW_V2_SIZE.

IVO

"UI Guy" <sher...@programmer.net> wrote in message news:1108618298....@f14g2000cwb.googlegroups.com...

0 new messages