Click to See Complete Forum and Search --> : I Hate DDX!!!


Paul Burns
May 20th, 1999, 10:09 PM
Why is it that when doing DDX thru UpdateData it doesn't generate any control notification messages?

For example, i have a combo box on a form and when the user changes the selection it should cause changes to other controls (e.g. disable this edit box, enable that one, etc.) which i do thru the CBN_SELCHANGE message handler.

But... when i do DDX to set the combo box selection it does not generate a CBN_SELCHANGE message. WHY?!?!?!?! And how do i get around this piece of MFC stupidity?

Martin Speiser
May 21st, 1999, 06:25 AM
Hi Paul,

that's not the fault of the MFC, it's pure Windows. You never get notifications from any control that something is changing if you are doing it with a window message instead of the user. The thought behind this behaviour is that you as the programmer know when something is changing, so there's no need for a notification.

I developed several years under OS/2, and this system behaves as you expect it. I found it annoying, because I set the default values during WM_INITDLG. So I got the notification during initialization, and checked whether the input is correct. But if the value of the control depends on other controls, which aren't set at this time, it's a bad design. I don't remember how many times I declared a variabe called bInit :-(

Martin

Martin

Paul Burns
May 24th, 1999, 08:02 PM
ok, thanks. i suppose it does make sense when you think about it, but it becomes a coding nightmare when using a CFormView as i've then got several functions - e.g. Record Move, Record New, Record Delete - which cause the control values to change programmatically.

Dan Haddix
May 24th, 1999, 11:55 PM
Look into using PostMessage or SendMessage these will both call your default handlers just as if the user had done something. There is one minor diffrence between the two.

PostMessage puts a message into the windows message que and returns imediatly.
SendMessage on the other hand activates the message map, calles the function directly and does not return until it is finished.

Steve Dwire
May 25th, 1999, 08:11 AM
>You never get notifications from any control that something is changing if you are doing it with a window message instead of the user.

WARNING: This is not entirely true. There are a few that actually do give notifications. For example, If I change the text of a combobox programmatically, I will *NOT* get a CBN_EDITCHANGE message. If I change the text of an edit control programmatically, however, I *WILL* get an EN_CHANGE message! This inconsistency in Windows has caused me more than one headache.