subclassing RichEditCtrl and EN_SELCHANGE

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi

I'm subclassing RichEditCtrl and I have to write custom EN_SELCHANGE handler
in my class (CValidatingEdit). The problem is that class wizard doesn't show
EN_SELCHANGE in messages list. I tried using OnNotify/OnChildNotify but it
doesn't help.

void CValidatingEdit::PreSubclassWindow()
{
SetEventMask(GetEventMask() | ENM_CHANGE | ENM_SELCHANGE);

CRichEditCtrl::PreSubclassWindow();
}

BOOL CValidatingEdit::OnChildNotify(UINT message, WPARAM wParam, LPARAM
lParam, LRESULT* pLResult)
{
if (message == EN_SELCHANGE)
MessageBox("EN_SELCHANGE");
return CRichEditCtrl::OnChildNotify(message, wParam, lParam, pLResult);
}

BOOL CValidatingEdit::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT*
pResult)
{
NMHDR *pNMHDR = (NMHDR*)lParam;
if (pNMHDR->code == EN_SELCHANGE)
MessageBox("EN_SELCHANGE");
return CRichEditCtrl::OnNotify(wParam, lParam, pResult);
}


Of course I can handle this event in the dialog (I mean handling this event
in dialog for control instance), but of course I want to put whole code in
my custom class. Thanks in advance for any help.

Marian


.



Relevant Pages