Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have created one project of Modal and Modeless Dialog in MFC.

Modeless Dialog having property that it will get closed after 15 second, for closing Modelss dialog i am using DestroyWindow().

Now Problem is with Modal Dialog,
1)If we open Modeless Dialog(which will automatically gets close after 15 second).

2)Before closing Modeless Dialog if we open Modal Dialog then after 15 second both Modal & Modeless Dialogs are getting closed and Application geting crashed.

3)I think DestroyWindow() is closing both Dialog.

Please Help me....How to solve this problem.
Posted
Updated 25-Feb-17 8:31am
Comments
Sergey Alexandrovich Kryukov 15-Feb-13 15:46pm    
Please don't post your comments or clarifications as "solution". This is the abuse which can cause abuse reports. Such reports, in case of heavy abuse, can lead to revocation of CodeProject account.
—SA

1 solution

If you calling DestroyWindow from a thread other than GUI thread, it will create access violation.
Please ensure DestroyWindow is called from GUI thread.
One option is to Post WM_CLOSE Message to your dialog(Using PostMessage),
and close all other dialogs from ModelLessDlg::OnClose().
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900