Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Newbye dialog problem

Posted on 2006-11-26
2
Medium Priority
?
376 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

636 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