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.