CToolTipCtrl和CEdit [英] CToolTipCtrl and CEdit

查看:92
本文介绍了CToolTipCtrl和CEdit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在对话框中有一个编辑控件,只能接受指定的特定字符。如果用户正在键入我未指定的任何其他字符,我需要在气球工具提示中显示警告,而不是在消息框中显示(类似于ES_NUMBER,但不完全相同)。我尝试了以下代码,但它不能正常工作。





 CEdit * pEditCtrl; 
CToolTipCtrl * pErrorToolTip;





创建编辑控件后,工具提示创建如下,



 pErrorToolTip =  new  CToolTipCtrl; 
pErrorToolTip->创建(,TTS_BALLOON);
pErrorToolTip-> AddTool(pEditCtrl,_T( [警告信息])) ;
pErrorToolTip-> SetTitle(TTI_INFO,_T( [警告标题])) ;





 ON_EN_CHANGE(,OnTextChange)





 OnTextChange()
{
...
...
if ([未指定字符输入])
{
pErrorToolTip->激活( true );
pErrorToolTip-> Popup();
}
else
{
pErrorToolTip->激活( false );
pErrorToolTip-> Pop();
}

}





在寻找一些片段后,我找到并添加了PreTranslateMessage( ),但只有在悬停编辑控件时弹出工具提示,我不需要发生这种情况。它应该只在用户输入的未指定字符上弹出。



请帮帮我。

解决方案

< blockquote>我自己找到了解决方案。 CEdt​​提供 ShowBalloonTip [ ^ ]和 HideBalloonTip [ ^ ]对我帮助很大。


I have an edit control in the dialog which can accept only the particular characters specified me. If the user is typing any other characters which are not specified by me, I need to display a warning, not in a message box, in a balloon tool tip(as similar to ES_NUMBER, but not exactly). I tried the following code but it does not works fine.


CEdit *pEditCtrl;
CToolTipCtrl *pErrorToolTip;



after the edit control created, Tool Tip is created as follows,

pErrorToolTip = new CToolTipCtrl;
pErrorToolTip->Create(this, TTS_BALLOON);
pErrorToolTip->AddTool(pEditCtrl, _T("[warning message]"));
pErrorToolTip->SetTitle(TTI_INFO, _T("[warning title]"));



ON_EN_CHANGE([id of edit control], OnTextChange)



OnTextChange()
{
...
...
if ( [unspecified characters entered] )
{
pErrorToolTip->Activate(true);
pErrorToolTip->Popup();
}
else
{
pErrorToolTip->Activate(false);
pErrorToolTip->Pop();
}

}



After looking for some snippets, I found and added the PreTranslateMessage(), but the tooltip pops-up only while hovering the edit control, I don't need that to be happened. It should pop-up only on unspecified characters entered by user.

Please help me with this.

解决方案

I found the solution myself. CEdt provides ShowBalloonTip[^] and HideBalloonTip[^] which helped me much.


这篇关于CToolTipCtrl和CEdit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆