Board index » Visual Studio » mouse exit window - don't know how to turn off tooltip

mouse exit window - don't know how to turn off tooltip

Visual Studio170
I have a window (a CView) in which I want to display a tooltip (for

x,y etc) when the mouse pointer is within the client area.



I have created it in OnInitialUpdate



void CTP3ProfileView::OnInitialUpdate()

{

/* Create a tooltip window for general use */

unsigned int uid = 0;

_tcscpy(m_tooltiptext,_T(""));



m_tooltips = CreateWindowEx(WS_EX_TOPMOST,

TOOLTIPS_CLASS,

NULL,

TTS_NOPREFIX | TTS_ALWAYSTIP,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

this->GetSafeHwnd(),

NULL,

NULL,

NULL);



// INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE

m_tooltipinfo.cbSize = sizeof(TOOLINFO);

m_tooltipinfo.uFlags = TTF_TRACK | TTF_TRANSPARENT;

m_tooltipinfo.hwnd = this->GetSafeHwnd();

m_tooltipinfo.hinst = NULL;

m_tooltipinfo.uId = uid;

m_tooltipinfo.lpszText = m_tooltiptext;

// ToolTip control will cover the whole window

m_tooltipinfo.rect.left = 0;

m_tooltipinfo.rect.top = 0;

m_tooltipinfo.rect.right = 0;

m_tooltipinfo.rect.bottom = 0;



::SendMessage(m_tooltips,TTM_SETMAXTIPWIDTH, 0, SHRT_MAX);

::SendMessage(m_tooltips,TTM_SETDELAYTIME, TTDT_AUTOPOP,

SHRT_MAX);

::SendMessage(m_tooltips,TTM_SETDELAYTIME, TTDT_INITIAL, 200);

::SendMessage(m_tooltips,TTM_SETDELAYTIME, TTDT_RESHOW, 200);

::SendMessage(m_tooltips,TTM_ADDTOOL,0,(LPARAM)(LPTOOLINFO)&m_tooltipinfo);

}





Ok So far so good.



Then in OnMouseMove(), I activate it



void CTP3ProfileView::OnMouseMove(UINT nFlags, CPoint point)

{

_stprintf(m_tooltiptext, "something", ...);



::SendMessage(m_tooltips,TTM_TRACKACTIVATE,true,(LPARAM)(LPTOOLINFO)&m_tooltipinfo);

::SendMessage(m_tooltips,TTM_UPDATETIPTEXT,0,(LPARAM)(LPTOOLINFO)&m_tooltipinfo);



POINT p = point;

ClientToScreen(&p);

::SendMessage(m_tooltips,TTM_TRACKPOSITION,0,(LPARAM)(DWORD)MAKELONG(p.x+10,p.y+10));



CView::OnMouseMove(nFlags, point);

}





The problem is that when the mouse is going to the frame etc, the

tooltip is still in the last shown position, of course, because I

don't know how/when to tell it to turn off. I'm probably doing this

the wrong way. Any tips will be appreciated.


-
 

Re:mouse exit window - don't know how to turn off tooltip

Quote
The problem is that when the mouse is going to the frame etc, the

tooltip is still in the last shown position, of course, because I

don't know how/when to tell it to turn off.



Can you make use of (_)TrackMouseEvent perhaps?



Dave

--

MVP VC++ FAQ: www.mvps.org/vcfaq">www.mvps.org/vcfaq

-