我在一个ActiveX控件上用ToolTip,当鼠标移到指定区域的时候就显示,离开的时候就消失,可以不知道怎么回事,当移到指定区域的时候不能显示,
代码如下:在View类中OnInitiaUpdate函数里面
EnableToolTips(TRUE);
m_ToolTip.Create(this);
m_ToolTip.Activate(TRUE);
m_ToolTip.AddTool(this);
m_ToolTip.SetDelayTime(1000,200);
然后再
BOOL CSplWindowView::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(m_ToolTip.m_hWnd!=NULL)
m_ToolTip.RelayEvent(pMsg);
return CView::PreTranslateMessage(pMsg);
}
最后再OnMouseMove中!
if(m_bHasPointLayer)
{
CString strResult;
strResult=GetDesFieldInfo(x-5,y-5,x+5,y+5);
if(!(strResult.IsEmpty()))
m_ToolTip.UpdateTipText(strResult,this);
}高手指点哈!谢谢!!
代码如下:在View类中OnInitiaUpdate函数里面
EnableToolTips(TRUE);
m_ToolTip.Create(this);
m_ToolTip.Activate(TRUE);
m_ToolTip.AddTool(this);
m_ToolTip.SetDelayTime(1000,200);
然后再
BOOL CSplWindowView::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(m_ToolTip.m_hWnd!=NULL)
m_ToolTip.RelayEvent(pMsg);
return CView::PreTranslateMessage(pMsg);
}
最后再OnMouseMove中!
if(m_bHasPointLayer)
{
CString strResult;
strResult=GetDesFieldInfo(x-5,y-5,x+5,y+5);
if(!(strResult.IsEmpty()))
m_ToolTip.UpdateTipText(strResult,this);
}高手指点哈!谢谢!!
解决方案 »
- 内存映射文件的一个问题
- error C2061: syntax error : identifier 'LPVOID'<--错误如何解决?
- 菜鸟求救,初学VC写个程序编译没错却运行没结果
- 文件传输
- 请问nExitCode(通出代码)是什么东西?
- 请问如何取得窗口中AcitveX控件的IUnknown接口?
- 哪位对wininet系列函数熟悉?InternetSetFilePointer怎么用?
- 如何让指定的窗口处于window桌面最顶层??
- 怎样才能向一个文件中插入一个汉字?
- 文档/视结构保存文本的问题
- 求助:我的 makefile 和 sources 文件应该怎么写?谢谢!
- 新人提问:关于IOCP例子中一句代码的理解?
这个Tip是在控件上面显示!!!!第三方控件!!!
1.EnableToolTips(TRUE);
如:
void CTestView::OnInitialUpdate()
{
CMyFormView::OnInitialUpdate();
EnableToolTips(TRUE);
}
2.处理TTN_NEEDTEXT通知消息。
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, memberFxn )添加到消息映射处
处理函数是:
BOOL CMyClass::memberFxn( UINT id, NMHDR * pTTTStruct, LRESULT * pResult );
实现体:
BOOL CMyFormView::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
UINT nID =pNMHDR->idFrom;
if (pTTT->uFlags & TTF_IDISHWND)
{
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
if(nID)
{
pTTT->lpszText = MAKEINTRESOURCE(nID);
pTTT->hinst = AfxGetResourceHandle();
return(TRUE);
}
}
return(FALSE);
}
这样应该就可以了。我是拷贝MSDN的。你可以查看CToolTip那里有说明的。希望对你有帮助。
我在一个acitvex上做了一个tooltip,如果这个acitvex放在一个xp风格的容器里面,tooltip显示完全正常,如果容器没有xp风格,则弹不出来tooltip!
[email protected]
{
CString strResult;
strResult=GetDesFieldInfo(x-5,y-5,x+5,y+5);
if(!(strResult.IsEmpty()))
{
m_ToolTip.UpdateTipText(strResult,this);
m_ToolTip.Activate(TRUE);
}
else
{
m_ToolTip.Activate(FALSE);
}
}