Solved

Newbye dialog problem

Posted on 2006-11-26
2
320 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell based monitoring system 2 140
Excel Use VBA to get user's Mac Address for their computer 5 109
zeroMAx challenge 20 87
Use of condition with 'serial' in ansible 2 49
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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

919 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

17 Experts available now in Live!

Get 1:1 Help Now