Creation of the Mode dialog:
1. Add dialog box resources, assume its resource named IDD_DIALOG1
2. Create a class for the dialog, assume that its class name ctestdlg
3. Add the header file reference to the CTESTDLG class in the stdafx.h file, #include "testdlg.h"
4. Add a member variable in the header file that references the CTESTDLG class: public: ctestdlg DLG;
5. Show no mode dialog: DLG.CREATE (IDD_DIALOG1, THIS); DLG.SHOWINDOW (SW_SHOW);
This way, a non-mode dialog is created. Then, I set a timer that automatically turned off after 5 seconds. This is very common, usually in an event as a drive, multi-threaded application is more common. For example, in network communication, one operation may take more time, in order to let users know what the program is doing, there is such a prompt dialog. Automatically turn off after the operation is completed. This time-free dialog is now driven by timer.
The shutdown of the modeless dialog:
SetTimer (1,5000, null); // Enable timer
Respond to the WM_TIMER message, write the following code in the ONTIMER:
IF (Nidevent == 1) {DLG.POStMessage (WM_CLOSE); / / Send a shutdown message to the dialog box killtimer (1);}
All this seems to be so normal, compiled, and implemented! I almost thought that I was right ... The result, when the dialog is turned off, I want to show it for the second time, I am unusually reported. what happened? The original mode dialog is that you can use the WM_Close message to close, but no mode dialog box is not! The Mode dialog box must be shut down with the DestroyWindow method. Change the code to the following ...
IF (nidevent == 1) {DLG.DESTROYWINDOW (); // This is no problem with KillTimer (1);