[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Newbye dialog problem

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
aureliuh
Asked:
aureliuh
1 Solution
 
AlexFMCommented:
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
 
aureliuhAuthor Commented:
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now