Discussion:
non-modal dialog: where init controls with text or so?
(too old to reply)
Guido Franzke
2007-07-25 14:47:45 UTC
Permalink
Hello NG,

I have a non-modal dialog (created with Create) in which I want to
initialize some controls (e.g. CEditCtrl with text).
In modal dialogs I do it in OnInitDialog(). But where in my non-modal
dialog?

Thanks for help,
Guido Franzke
AliR (VC++ MVP)
2007-07-25 14:57:23 UTC
Permalink
Same place, OnInitDialog.

AliR.
Post by Guido Franzke
Hello NG,
I have a non-modal dialog (created with Create) in which I want to
initialize some controls (e.g. CEditCtrl with text).
In modal dialogs I do it in OnInitDialog(). But where in my non-modal
dialog?
Thanks for help,
Guido Franzke
Guido Franzke
2007-07-25 16:05:13 UTC
Permalink
Well, I thought, OnInitDialog is only for modal dialogs with DoModal.
Ok, so I implemented OnInitDialog after my Create. Seems to be ok. But my
comboboxes now have each value twice???
What's wrong?
Post by AliR (VC++ MVP)
Same place, OnInitDialog.
AliR.
AliR (VC++ MVP)
2007-07-25 16:32:57 UTC
Permalink
What do you mean by each value twice?

AliR.
Post by Guido Franzke
Well, I thought, OnInitDialog is only for modal dialogs with DoModal.
Ok, so I implemented OnInitDialog after my Create. Seems to be ok. But my
comboboxes now have each value twice???
What's wrong?
Post by AliR (VC++ MVP)
Same place, OnInitDialog.
AliR.
Guido Franzke
2007-07-25 16:45:19 UTC
Permalink
Well, in my resource editor, I have added a combobox using data (e.g.
"First", "Second", "Third").
After showing the non-modal dialog the combobox has all values twice:
"First","First","Second","Second","Third","Third".
This does not appear, if I don't call OnInitInstance.
I think it's in the line CDialog::OnInitInstance, but if I delete this line,
the programme crashes.
AliR (VC++ MVP)
2007-07-25 18:34:51 UTC
Permalink
I am sorry Guido, but you have to be a little more persice with your
descriptions.

There is no CDialog::OnInitInstance(), and if you are talking about
OnInitDialog, you should not call that function directly. MFC framework
will call that method in response to WM_INITDIALOG message.

Can you post your dialog code here?

AliR.
Post by Guido Franzke
Well, in my resource editor, I have added a combobox using data (e.g.
"First", "Second", "Third").
"First","First","Second","Second","Third","Third".
This does not appear, if I don't call OnInitInstance.
I think it's in the line CDialog::OnInitInstance, but if I delete this line,
the programme crashes.
Guido Franzke
2007-07-26 11:06:09 UTC
Permalink
Thank you AliR.
I thought the framework would not call OnInitDialog. My fault. I don't call
OnInitDialog after Create explizitly, and it funktions well.
Thanks for your help,
Guido

Loading...