| |

VerySource

 Forgot password?
 Register
Search
View: 901|Reply: 8

anxious! The creation of a modeless dialog box, the second display error! !! !!

[Copy link]

3

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-2-11 16:30:02
| Show all posts |Read mode
I create a modeless dialog in the View class. Just started
CMyDialog * pDlg = new CMyDialog ();
Then pDlg-> Create (IDD_DIALOG);
pDlg-> ShowWindow (SW_SHOW);
No problem at all, everything works fine.
But the teacher asked later, do not use this, define a MyDialog member variable dlg in View
Then display it with dlg.
I just dlg.Create and dlg.ShowWindow
However, it can be displayed once each time, and an error will be displayed the second time.
why? What should I do? ?
Please master pointing. Thanks thank you very much
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-4-7 16:00:02
| Show all posts
The second time can not be created, because it has been created
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-4-7 16:45:01
| Show all posts
When the dialog box is closed, you need to call the function to destroy the dialog yourself.

At each create level, determine whether the variable has been associated with a dialog.
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-4-7 22:00:02
| Show all posts
Can be like this: dlg.DoModal ()
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-4-8 00:30:02
| Show all posts
Call it at the end
CWnd :: DestroyWindow
Reply

Use magic Report

2

Threads

19

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-4-20 09:15:01
| Show all posts
The second time can not be created, because it has been created

You can write code like this when creating
if (! dlg)
   dlg.Create (...)
You can't go wrong
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-4-22 20:45:01
| Show all posts
tomystonelh

if (! dlg)
   dlg.Create (...)

You are taking a closer look
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-21 18:45:01
| Show all posts
I support
CWnd::DestroyWindow



But it is placed before Create
Reply

Use magic Report

3

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-8-21 20:45:01
| Show all posts
Thank you, all of you.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list