?
Solved

Newbye dialog problem

Posted on 2006-11-26
2
Medium Priority
?
361 Views
Last Modified: 2013-11-20
Hello experts,

I have defined a dialog class which has a couple of fields I need to update at runtime from outside the class. For each of them I have created variables (CEdit and a CLabel which is sort of an extension for the CStatic). Prior to showing it with DoModal() I need to set appropriate texts to my fields.

It's obvious I do something wrong as I get assertion failed (wincore.cpp line 3940) message when trying to do that and it's probably obvious... perhaps the dialog is not created yet

This is from outside the class

CMyDialog* dlg;
dlg->testEdit.SetWindowText("one, two, three");
dlg->testLabel.SetWindowText("bla-bla");
dlg->DoModal();

Not trying to set any of the fields above issues no error and the dialog is displayed ok; Perhaps the DoModal() calls dialog initiazation code and my fields are still NULL when trying to used them; I don't know.



Thank you,
Aureliu

0
Comment
Question by:aureliuh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 400 total points
ID: 18014167
This doesn't work because controls don't exist before DoModal is called.
Add two public CString members to CMyDialog:

CString editText;
CString labelText;

Creating dialog:

CMyDialog* dlg;   // I hope you create is somewhere

dlg->editText = "one, two, three";
dlg->labelText = "bla-bla";
dlg->DoModal();

Add these lines to CMyDialog::OnInitDialog:

testEdit.SetWindowText(editText );
testLabel.SetWindowText(labelText );
0
 

Author Comment

by:aureliuh
ID: 18014200
Was I suppose to create the pointer???

Just kidding, at least I knew that, thanks for dropping a little condescendent question on the dialog pointer :))

You are perfectly right on this, I felt the dialog is not ready yet, but never thought the CStrings members will be... I come from Borland C++ and this is new to me, lots of minor things have to be learned and tested...


Thank you,
Aureliu
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question