|
-
August 24th, 2001, 09:47 AM
#1
Modelless Dialog trouble
I am trying to create and use some modelless dialogs in my dialog based project. I can't seem to get it to work although I am following MSDN exactly (as far as I know). This is what I am doing to try to get a modelless dialog to appear:
CTestDlg testdlg;
testdlg.Create(IDD_TESTDLG, NULL);
testdlg.ShowWindow(SW_SHOW);
But it doesnt show up. It looks as if it pops up and immediately closes before I can really see it.
Please help.
-
August 24th, 2001, 10:05 AM
#2
Re: Modelless Dialog trouble
you must use a pointer
CTestDlg *testdlg;
testdlg=new(CTestDlg);
testdlg->Create(IDD_TESTDLG, NULL);
testdlg->ShowWindow(SW_SHOW);
because when you exit from the function that call Create() and ShowWindow() the object testdlg is destroied.
If you don't want use a pointer you must declare CTestDlg testdlg; as public variable
-
August 24th, 2001, 10:06 AM
#3
Re: Modelless Dialog trouble
hi,
u cannot create Dialog like that. U should be use pointer.
CTestDlg *testdlg; //put it into class
{
testdlg=new CTestDlg;
testdlg->Create(IDD_TESTDLG, NULL);
testdlg->ShowWindow(SW_SHOW);
}
Regards,
soundar
-
August 24th, 2001, 10:10 AM
#4
Re: Modelless Dialog trouble
Ahha. That makes sense. I should have known. Thanks alot.
-
August 24th, 2001, 10:10 AM
#5
Re: Modelless Dialog trouble
Thank you. That was very helpful.
-
August 24th, 2001, 03:55 PM
#6
Re: Modelless Dialog trouble
Hi;
There's nothing wrong with doing that, but *I think* you'll have a memory leak since you are using the 'new' command. It probably won't cause any major problems, but, nonetheless. You should probably declare a variable m_MyModlessDlg as part of the calling class, that way you can properly destroy the Modeless Dialog.
Scott.
-
August 24th, 2001, 04:12 PM
#7
Re: Modelless Dialog trouble
Now that you mention it, you are probably right about the memory leak thing. I will go about it your way. Thanks for the help. I appreciate it.
-
August 24th, 2001, 05:03 PM
#8
Re: Modelless Dialog trouble
Or (and some disagree), you could override OnNcDestroy() and call:
delete this;
Just a thought so the dialog will manage it's own deletion.
Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|