From: RB on
Hi Goran, thanks for the reply

>Why should it? rString was given it's value in your first

See insert below and follow up at end.

>>GetDlgItemText, and was not touched since.
>> GetDlgItemText( IDC_EditBox, rString);
>> //rString now equals {"444"} from initial user input to editbox
>> SetWindowText(_T("555"));
>> GetWindowText(rString2);
>> //rString2 now equals {"555"} from the SetWindowText
>> GetDlgItemText( IDC_EditBox, rString);

Well before Joe helped me to realize how to SetWindowText using
MFC control attachment to the EditBox (instead of the Form) I did
not realize the EditBox was not being changed with SetWindowText call.

>> //rString still equals {"444"} however rString remains unchanged?
>> //rString2 still equals {"555"}
>> // Shouldn't rString have changed to 555 ?

>You must clear in your head how variables behave. You seem to
>think that, because you called GetDlgItemText once using rString,
>rString should change every time you call SetWindowText (or
>something along these lines). That is seriously delusional.
>You need to understand much, much more about programming in general.
>Please do that first, before asking e.g. MFC-specific questions.
>Goran.

Well I agree I need to learn much more about programming in general.
Which is what I am attempting to do. If I have wasted your time then
I apologize. But I use small programming routines in my work as a
civil engineering cad technician. So I read books and get much help
at news groups since I am admittedly not a professional programmer.
I have made it to the top of my department in cad which now being made
aware that I am seriously delusional makes that quite a feat. It has been
my experience for some time that the only stupid thing is the question you
never asked because you felt it was stupid.
But seriously thank you for the reply, any criticism helps me but I
do not want to waste anyone's time.


From: Joseph M. Newcomer on
There is argument as to whether or not it is the "best" way (there are those who think I'm
completely off-base with this philosophy!) but it is the way I do it.
joe

On Sun, 9 May 2010 22:47:32 -0400, "RB" <NoMail(a)NoSpam> wrote:

>> Joseph M. Newcomer wrote:
>> A control is bound to a Control variable using the DDX_Control call; note that
>> I said I avoid DDX *except* for the DDX_Control calls. I never, ever use any
>> DDX control that returns a value!
>> ****
>> Overall, I consider the whole DDX-value and DDV mechanisms to be kludges
>> that do not adequately address the real problems of building robust, smooth,
>> usable interfaces.
>> ****
>---------
>Hey Joe thanks for replying again. I think I have gotten much of what you
>have given me. Basically don't use DDX variables for direct assignment
>but it is ok for DDX_Control calls. In other words if I
>// From my View header file
> //{{AFX_DATA(CMyAppView)
> enum { IDD = IDD_MyApp_FORM };
> CEdit m_EditBox;
> //}}AFX_DATA
>
>//From my View cpp file
>void CMyAppView::DoDataExchange(CDataExchange* pDX)
>{
> CFormView::DoDataExchange(pDX);
> //{{AFX_DATA_MAP(CMyAppView)
> DDX_Control(pDX, IDC_EditBox, m_EditBox);
> //}}AFX_DATA_MAP
>}
>
>//Then inside the pertinant handler
> CString rString;
> m_EditBox.GetWindowText(rString);
> m_EditBox.SetWindowText(_T("555"));
> // This is the best way to Set and Get the EditBox's contents, Correct?
>
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Goran on
On May 10, 3:35 pm, "RB" <NoMail(a)NoSpam> wrote:
> Hi  Goran, thanks for the reply
>
> >Why should it? rString was given it's value in your first
>
> See insert below and follow up at end.
>
> >>GetDlgItemText, and was not touched since.
> >> GetDlgItemText( IDC_EditBox, rString);
> >> //rString now equals {"444"} from initial user input to editbox
> >> SetWindowText(_T("555"));
> >> GetWindowText(rString2);
> >> //rString2 now equals {"555"} from the SetWindowText
> >> GetDlgItemText( IDC_EditBox, rString);
>
> Well before Joe helped me to realize how to SetWindowText using
> MFC control attachment to the EditBox (instead of the Form) I did
> not realize the EditBox was not being changed with SetWindowText call.
>
> >> //rString still equals {"444"} however rString remains unchanged?
> >> //rString2 still equals {"555"}
> >> // Shouldn't rString have changed to 555 ?
> >You must clear in your head how variables behave. You seem to
> >think that, because you called GetDlgItemText once using rString,
> >rString  should change every time you call SetWindowText (or
> >something along these lines). That is seriously delusional.
> >You need to understand much, much more about programming in general.
> >Please do that first, before asking e.g. MFC-specific questions.
> >Goran.
>
> Well I agree I need to learn much more about programming in general.
> Which is what I am attempting to do. If I have wasted your time then
> I apologize.

No problem.

> But I use small programming routines in my work as a
> civil engineering cad technician. So I read books and get much help
> at news groups since I am admittedly not a professional programmer.

If that is the case, did you consider using some other language and
framework? Seriously, MFC is not for the faint of heart, and there are
much easier ways to get some results with some simple programming. If
you want to stay within Visual Studio, try e.g. VB.NET, it indeed is
leaps and bounds easier.

Goran.
From: Oliver Regenfelder on
Hello Joseph,

I have a question regarding control variables and their binding to
controls.

Joseph M. Newcomer wrote:
> A control is bound to a Control variable using the DDX_Control call; note that I said I
> avoid DDX *except* for the DDX_Control calls. I never, ever use any DDX control that
> returns a value!

The DDX_Control calls are placed in the DoDataExchange Method, which is
called everytime on UpdateData. But it seems to me from the
described/observed that it only takes one call to bind the control
variable to the windows control itself and from there on any methods
of the control variable work on the control ''instantaneuously''
(meaning no more need for an UpdateData call). Am I right with this
observation?

A second question (in case I am right on the first one). If controls
and control variables are bound on the first call to DDX_Control, then
why is that binding call placed in a method that potentially gets
called several times, and not somewhere in a fixed dialog initialization
method?

Best regards,

Oliver
From: RB on
>> But I use small programming routines in my work as a
>> civil engineering cad technician. So I read books and get much help
>> at news groups since I am admittedly not a professional programmer.

>>If that is the case, did you consider using some other language and
>>framework? Seriously, MFC is not for the faint of heart, and there are
>>much easier ways to get some results with some simple programming. If
>>you want to stay within Visual Studio, try e.g. VB.NET, it indeed is
>>leaps and bounds easier. Goran.

You know that is an excellent summation ! And it is one that I have struggled
with from both while first contemplating MFC and during my MFC aspirations.
And I must admit that subconsciously I have thought many times over the past
few months "exactly" what you just said. I originally started out writing win32
console apps (in C ) and then wrote some win32 gui apps but then I liked what
"appeared" to be an easy way to create user input interfaces fast with MFC
and additionally the built in printing abilities. Currently I am struggling with
hard to reach easy. I think my problem is that my app requirements have
reached a level beyond my programming competence and I will have to return
to the books I first read years ago. I will have to practice the more advanced
concepts I have not seen since my first reading long ago.
But again I thank you for your input because all of you guys come across as
dedicated and motivated professionals and the input helps direct people like me
tremendously.
RB