Re: DoDataExchange, GetDlgItem and Controls



I disapprove of explicitly writing an UpdateData call in the code. Since the implicit one
done during CDialog::OnInitDialog and CDialog::OnOK are not explicitly coded, I feel free
to tolerate them, as long as all I'm handling are simple edit controls and check boxes.
Nothing else.
joe
On Thu, 31 Jul 2008 12:32:04 -0400, David Wilkinson <no-reply@xxxxxxxxxxxx> wrote:

Joseph M. Newcomer wrote:
I strongly believe that DD* for data is pointless. It does the validation at the wrong
time, in the wrong way, and produces inappropriate error messages. Validation is not a
big deal to do right, and I've been doing it without DDV_ style validation for 13 years
now without feeling that I'm being burdened with anything. In some cases the validation
is very complex, involving constraint equations. I would not trust something like this to
a mechanism that is trying to be all things to all programmers.

In addition, I have no particular problem with the idea of setting string variables for
dialogs I'm launching; I use the one-and-only implicit call to UpdateData to preload the
trivial controls, and for OnOK use the one-and-only impicit call to UpdateData to capture
the controls. But I would never use it within a dialog. GetWindowText works wonders for
retrieving edit controls; SetWindowText for setting them. The problem is that the
mechanisms just don't scale well to other kinds of controls, and presume silly and
unbelievable things like you know the index of a value in a combo box (which never happens
in real life).

Joe:

You know, I did not realize that you had tolerance for setting/getting control
data using these "implicit" UpdateData() calls contained in the CDialog base
class. I thought that you disapproved of all such calls, and only tolerated the
initial UpdateData(FALSE) because it does the subclassing of the controls.

In this case I am more inclined to agree with you. Although I do it on occasion,
using UbdateData(TRUE) for intermediate validation is a rather blunt instrument.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: combo boxes
    ... arise because there is a synchronization problem between the two copies. ... I started using UpdateData because it seemed to be the "right thing". ... understand the complete set of relationships of the variables and controls. ... I don't see those until I do the next download. ...
    (microsoft.public.vc.mfc)
  • Re: Flow of called methods in MFC
    ... Amazon's used books) "MFC Internals" by Shepherd and Wingo is probably the best reference ... UpdateData is only called for a CFormView, ... OnInitialUpdate is called when the view is first created and attached to a document. ... superclass OnInitialUpdate returns all the controls are bound to their variables. ...
    (microsoft.public.vc.mfc)
  • Re: beginner: basic question on loop execution
    ... >I expect the m_result to be updated after each frame. ... The problem is that the edit control has invalidated itself, ... You should use UpdateData only when you want to transfer and validate all ... When you need to do single controls, ...
    (microsoft.public.vc.language)
  • Re: UpdateData not working
    ... But suppose I have two edit controls. ... >that this UpdateData dance never clobbers either memory variables or control values. ... Therefore, struct assignment is bad. ... Those who want to understand DDX/DDV and UpdateData ...
    (microsoft.public.vc.mfc)

Loading