Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.


C++
CEdit *pEditCtrl;
CToolTipCtrl *pErrorToolTip;


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

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


C++
ON_EN_CHANGE([id of edit control], OnTextChange)


C++
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.
Posted
Updated 9-Sep-13 19:19pm
v2

1 solution

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900