[MFC] :: Sensible way to handle CEdit changes?

Started by
0 comments, last by Ra 15 years, 9 months ago
I'm having some trouble working with a CEdit in an application that supports multi-select. The idea is that the user can select an object, and as they type in the edit box it changes the associated object property. Whenever the user selects a new object, the edit boxes update to display the values for that object. However, whenever the user multi-selects several different objects, I clear the edit boxes for the properties that aren't identical across all the selected objects (which is fairly standard practice). The problem is that setting the window text via code invokes the edit callback, which inadvertently erases all the properties by confusing the application into thinking the user cleared the edit boxes! Obviously the most direct solution would be to add some flag that I set whenever the code is changing the text boxes and early-out from the callback that modifies objects when I detect this flag. However I can't help but have a nagging feeling in the back of my head that tells me there needs to be a more sensible way of detecting whether the text was changed by the user or through code. On the other hand, maybe this is the only way of solving this problems. So far only edit boxes exhibit this behavior, since it appears you can change the state of many other controls without invoking the callbacks.
Advertisement
The only sensible solution I can think of is dirty flags. Mark a flag whenever the user modifies the data but not when it's modified from code.
Ra

This topic is closed to new replies.

Advertisement