Click here to Skip to main content
15,892,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: overload operator... a begginner info Pin
Remi Morin30-Oct-01 10:26
Remi Morin30-Oct-01 10:26 
GeneralRe: overload operator... a begginner info Pin
Tomasz Sowinski30-Oct-01 10:39
Tomasz Sowinski30-Oct-01 10:39 
GeneralRe: overload operator... a begginner info Pin
Michael Dunn30-Oct-01 17:21
sitebuilderMichael Dunn30-Oct-01 17:21 
GeneralTaskbar and Systray Pin
30-Oct-01 7:49
suss30-Oct-01 7:49 
GeneralRe: Taskbar and Systray Pin
Michael P Butler30-Oct-01 8:47
Michael P Butler30-Oct-01 8:47 
GeneralRe: Taskbar and Systray Pin
Ravi Bhavnani30-Oct-01 8:51
professionalRavi Bhavnani30-Oct-01 8:51 
GeneralXML File Properties and ATL Pin
30-Oct-01 7:40
suss30-Oct-01 7:40 
GeneralTooltips for ActiveX control on a CFormView Pin
Craig Miller30-Oct-01 7:25
Craig Miller30-Oct-01 7:25 
Hi,

I have a graphics ActiveX control sitting on a CFormView derived class in an SDI application. I recently found an article about tooltips from April '97 in MSJ searching through MSDN. I've implemented that solution and it seems to work except for a few little problems that I was wondering if someone has seen before.

When I get the tooltip that is over a particular area of the image (hotspot) the tooltip shows up right under the mouse. It also shows up at the bottom of the CFormView window, so I now get two tooltips and I can't figure out how to get rid of the one along the bottom of the window.

Following is the code that I'm using, any help in this matter is greatly appreciated.

Thanks,

Craig

void CImageViewer::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();

	if (m_ToolTip.Create(&m_lead, TTS_ALWAYSTIP) && 
		m_ToolTip.AddTool(&m_lead))
	{
		m_ToolTip.SendMessage(TTM_SETMAXTIPWIDTH, 0, SHRT_MAX);
		m_ToolTip.SendMessage(TTM_SETDELAYTIME, TTDT_AUTOPOP, SHRT_MAX);
		m_ToolTip.SendMessage(TTM_SETDELAYTIME, TTDT_INITIAL, 200);
		m_ToolTip.SendMessage(TTM_SETDELAYTIME, TTDT_RESHOW, 200);
	}
	else
	{
		TRACE("Error in creating ToolTip");
	}
}
BOOL CImageViewer::PreTranslateMessage(MSG* pMsg) 
{
	if (::IsWindow(m_ToolTip.m_hWnd) && pMsg->hwnd == m_lead.m_hWnd)
	{
	     switch(pMsg->message)
	     {
	     case WM_LBUTTONDOWN:	
	     case WM_MOUSEMOVE:
	     case WM_LBUTTONUP:	
	     case WM_RBUTTONDOWN:
	     case WM_MBUTTONDOWN:	
	     case WM_RBUTTONUP:
	     case WM_MBUTTONUP:
		{
			if(vecRects.size() > 0)
			{
				CPoint pt(pMsg->pt);
				ScreenToClient(&pt);
			
				float zoom = m_lead.GetPaintZoomFactor();
			
				float ix, iy;
				int xscroll, yscroll;
				xscroll = m_lead.GetScrollPos(SB_VERT);
				yscroll = m_lead.GetScrollPos(SB_HORZ);
				float newzoom = zoom / 100;
				ix = (pt.x + xscroll) * newzoom;
				iy = (pt.y + yscroll) * newzoom;
			
				pMsg->pt.y = iy;
				pMsg->pt.x = ix;
				
				m_lead.SetAutoRepaint(TRUE);
			
				m_ToolTip.RelayEvent(pMsg);
			
			}
			m_ToolTip.RelayEvent(pMsg);
		        break;
		     }
	     default:
		break;
	    }
        }
	
	return CFormView::PreTranslateMessage(pMsg);
}

BOOL CImageViewer::OnToolTipNeedText(UINT id, NMHDR * pNMHDR, LRESULT * pResult)
{
	BOOL bHandledNotify = FALSE;

	CPoint CursorPos;
	VERIFY(::GetCursorPos(&CursorPos));
	ScreenToClient(&CursorPos);

	CRect ClientRect;
	GetClientRect(ClientRect);

	// Make certain that the cursor is in the client rect, because the
	// mainframe also wants these messages to provide tooltips for the
	// toolbar.
	if (ClientRect.PtInRect(CursorPos))
	{
		TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
		m_pRectHit = HitTest(CursorPos);

		if (m_pRectHit)
		{
			// Adjust the text by filling in TOOLTIPTEXT
			CString strTip;
			strTip.Format("%s %s", m_pRectHit->szPartNumber.c_str(), 
				m_pRectHit->szDescription.c_str());
			ASSERT(strTip.GetLength() < sizeof(pTTT->szText));
			::strcpy(pTTT->szText, strTip);

			bHandledNotify = TRUE;
		}
		else
		{
			pTTT->szText[0] = 0;
		}
	}
	return bHandledNotify;
}

void CImageViewer::OnMouseMoveLeadctrl(short Button, short Shift, long x, long y) 
{
	if (::IsWindow(m_ToolTip.m_hWnd))
	{
		CPoint point(x, y);
		const CRects* pRectHit = HitTest(point);

		if (!pRectHit || pRectHit != m_pRectHit)
		{
			// Use Activate() to hide the tooltip.
			m_ToolTip.Activate(FALSE);		
		}

		if (pRectHit)
		{
			m_ToolTip.Activate(TRUE);
			m_pRectHit = pRectHit;
		}
	}
}

GeneralSmallest and common Font ( for printing) Pin
Braulio Dez30-Oct-01 6:21
Braulio Dez30-Oct-01 6:21 
GeneralRe: Smallest and common Font ( for printing) Pin
Roger Allen30-Oct-01 6:34
Roger Allen30-Oct-01 6:34 
GeneralAccessing history using CHtmlView (WebBrowser ActiveX control) Pin
JRP30-Oct-01 6:16
JRP30-Oct-01 6:16 
GeneralRe: Accessing history using CHtmlView (WebBrowser ActiveX control) Pin
JRP30-Oct-01 8:00
JRP30-Oct-01 8:00 
GeneralCommand Line Operation of VC++ Pin
Chris Meech30-Oct-01 6:13
Chris Meech30-Oct-01 6:13 
GeneralRe: Command Line Operation of VC++ Pin
Tomasz Sowinski30-Oct-01 9:59
Tomasz Sowinski30-Oct-01 9:59 
GeneralRe: Command Line Operation of VC++ Pin
Chris Meech30-Oct-01 10:28
Chris Meech30-Oct-01 10:28 
GeneralBrowse Pin
meirav30-Oct-01 6:12
meirav30-Oct-01 6:12 
GeneralRe: Browse Pin
Oscar Vazquez30-Oct-01 8:49
Oscar Vazquez30-Oct-01 8:49 
Generalvisible/invisible Pin
meirav30-Oct-01 6:08
meirav30-Oct-01 6:08 
GeneralRe: visible/invisible Pin
Chris Meech30-Oct-01 6:17
Chris Meech30-Oct-01 6:17 
GeneralRe: visible/invisible Pin
Michael P Butler30-Oct-01 6:48
Michael P Butler30-Oct-01 6:48 
GeneralRe: visible/invisible Pin
Chris Meech30-Oct-01 7:23
Chris Meech30-Oct-01 7:23 
QuestionClipping needed for better (GDI) performance? Pin
30-Oct-01 5:31
suss30-Oct-01 5:31 
QuestionLock std::ifstream? Pin
Derek Price30-Oct-01 5:02
Derek Price30-Oct-01 5:02 
AnswerRe: Lock std::ifstream? Pin
Todd Smith30-Oct-01 5:50
Todd Smith30-Oct-01 5:50 
GeneralRe: Lock std::ifstream? Pin
Derek Price30-Oct-01 5:54
Derek Price30-Oct-01 5:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.