To help you, we coded a simple MDI application. The view window in the MDI child frame window draws a small red rectangle. You can see a balloon tip over it. Please download the sample project from here. The source code is very simple. We added the following members to the CTestView
view class:
CExtPopupMenuTipWnd m_wndCoolTip;
CRect m_rcToolRect;
The
m_rcToolRect
member specifies location of the red rectangle. It is initialized in the constructor:
CTestView::CTestView()
: m_rcToolRect( 50, 50, 100, 100 )
{
// TODO: add construction code here
}
The
CTestView::OnDraw()
virtual method draws the red rectangle:
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->FillSolidRect( &m_rcToolRect, RGB(255,0,0) );
}
Finally, we have added the WM_MOUSEMOVE message handler to make cool tip window working:
void CTestView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if( m_rcToolRect.PtInRect( point ) )
{
if( m_wndCoolTip.GetSafeHwnd() == NULL
|| (m_wndCoolTip.GetStyle()&WS_VISIBLE) == 0
)
{
CRect rcTrack = m_rcToolRect;
ClientToScreen( &rcTrack );
m_wndCoolTip.SetText( "cooltip" );
m_wndCoolTip.Show( this, rcTrack );
}
}
else
m_wndCoolTip.Hide();
CView::OnMouseMove(nFlags, point);
}