Solved

Newbye dialog problem

Posted on 2006-11-26
2
309 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
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 100 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now