Well, I actually did think that it was doing its job, but I was unsure of
how to not make it pop up a second message box. Apparently though from what
you have said, I cannot without subclassing it. Thanks for the info and I
will give that a try.
"Joseph M. Newcomer" <firstname.lastname@example.org> wrote in message
Yep. That's what is supposed to happen. "Clearing" the data is a
"change", so of course
it will pop up a message box.
First, you should not be popping up message boxes in EN_CHANGE handlers.
This leads to
all kinds of confusion. If you need a MessageBox, do a PostMessage to
cause it to happen
at another time. During the EN_CHANGE, you are in an intermediate state
and popping up a
messagebox could quite possibly have serious consequences.
When I need to change the contents of a CEdit without generating a
notification, I do it
I subclass the edit control, making CNoNotifyEdit
I add a reflected =EN_CHANGE handler to it.
I hand-edit the prototype to change it from void to BOOL, and likewise in
I change the macro from ON_EN_CHANGE_REFLECT to ON_EN_CHANGE_REFLECT_EX.
Initialize the notify BOOL in the constructor...
notify = TRUE;
The changed message map entry would be
Then add the method that suppresses the notification
void CNoNotifyEdit::SetWindowTextNoNotify(LPCTSTR s)
if(old == s)
return; // do nothing, already set
BOOL previous = notify;
notify = FALSE;
notify = previous;
The reflected handler is trivial
On Thu, 17 Aug 2006 11:12:28 -0700, "Z.K." <email@example.com> wrote:
If I use OnEnChangeEditData and popup a messagebox, it works okay, but
I also try to clear the datat that was entered in the editbox, I get
messageboxes. How do I prevent this and why does this happen?
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
MessageBox("The File to be printed has not been selected,\n Select a file
first!", "File Not Selected", MB_ICONSTOP | MB_OK);
Joseph M. Newcomer [MVP]
MVP Tips: http://www.flounder.com/mvp_tips.htm