DoDataExchange doesn't like pointers ?
-
If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via DDX_Control(IDC_EDIT_BOX, *pEdit); The program asserts. It works fine if I create a CEdit object on stack and pass it. Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me :( Thanks Cage
-
If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via DDX_Control(IDC_EDIT_BOX, *pEdit); The program asserts. It works fine if I create a CEdit object on stack and pass it. Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me :( Thanks Cage
cagespear wrote:
The program asserts
Why? I.e. what was the assertion message?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via DDX_Control(IDC_EDIT_BOX, *pEdit); The program asserts. It works fine if I create a CEdit object on stack and pass it. Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me :( Thanks Cage
Are you creating the
CEdit
object and callingCreate()
before or after callingCDialog::OnInitDialog()
?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Are you creating the
CEdit
object and callingCreate()
before or after callingCDialog::OnInitDialog()
?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
cagespear wrote:
No
It was not a yes/no question.
cagespear wrote:
what's the need of that if I am doing DDX_Control?
It's required. Now, where is the call to
CDialog::OnInitDialog()
in relation to where theCEdit
object is created and itsCreate()
method called?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via DDX_Control(IDC_EDIT_BOX, *pEdit); The program asserts. It works fine if I create a CEdit object on stack and pass it. Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me :( Thanks Cage
Do you want to make dynamic editbox and use of their events?
-
cagespear wrote:
No
It was not a yes/no question.
cagespear wrote:
what's the need of that if I am doing DDX_Control?
It's required. Now, where is the call to
CDialog::OnInitDialog()
in relation to where theCEdit
object is created and itsCreate()
method called?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
I don't think so david. I am pretty sure I don't need an explicit create call in my oninitdialog if I am linking the editbox with the dialog with DDX_Control call. As it turned out, it was an issue with the resource ID.Thanks for the advice though. Regards Cage
-
I don't think so david. I am pretty sure I don't need an explicit create call in my oninitdialog if I am linking the editbox with the dialog with DDX_Control call. As it turned out, it was an issue with the resource ID.Thanks for the advice though. Regards Cage
cagespear wrote:
I am pretty sure I don't need an explicit create call in my oninitdialog...
Correct. But the
CEdit
object must be created beforeCDialog::OnInitDialog()
is called. Otherwise,DDX_Control()
will throw an exception."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
cagespear wrote:
I am pretty sure I don't need an explicit create call in my oninitdialog...
Correct. But the
CEdit
object must be created beforeCDialog::OnInitDialog()
is called. Otherwise,DDX_Control()
will throw an exception."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne