Save File dialog box when you close the MDI window

xiaoxiao2021-04-03  238

I have recently encountered a problem. When the X button in the upper right corner of the frame is clicked, the App will not prompt the Save File dialog box.

After investigation, you can achieve two ways, you will have to use comrades.

The first method is relatively simple

Add a savemodified () function in DOC, when you turn off the MDI framework or a single document, the system prompts you to save a document, which is overloaded with a serilize () function. And setmodifiedFlag ()

The second method is more complicated

Is a DOC's onclosedocument () function CFiledialog DLG (False, Null, "MDI_TE1", OFN_OVERWRITEPROMPT, NULL, NULL); if (DLG.Domodal () == idok) {cfile mfile; mfile.open (Dlg.getPathname () , CFILE :: MODEWRITE | CFILE :: MODECREATE); CARCHIVE AR (& Mfile, CARCHIVE :: Store); cmdi_test1doc :: serialize (ar); ar.close (); mfile.close (); return;} else {return;

Note that the premise is that it is necessary to overload the DOC's serialize () function and there is a problem. After you turn off the entire parent window, save the dialog box will come out, which is unmanaged, and also manually adds setModifiedFlag. ) And ismodified ().

I recommend a way to use, but if you want to use CFiledialog, it is better to use the second BUG.

Welcome everyone to make valuable comments.

转载请注明原文地址:https://www.9cbs.com/read-131617.html

New Post(0)