In this example, when the Close event fires, the code evaluates the ImageModified property to see if changes were made to the image. If the value of the ImageModified property is True, the code prompts the user to save the image.
void CImgEdit1Dlg::OnCloseEditctrl1()
{
// This code could be used at the time a user attempts to open
// a new file or clear a previously displayed image in order
// to prompt for changes to be saved if the image has been modified.
int iSaveImg;
if(ImgEdit1.GetImageModified())
{
iSaveImg = AfxMessageBox("Do you want to save changes?", MB_YESNOCANCEL);
switch (iSaveImg)
{
case IDYES:
// Save the changes
VARIANT evt; V_VT(&evt) = VT_ERROR; // set to default for save at zoom
ImgEdit1.Save(evt);
break;
// Drop down to the Open file code
case IDNO:
// Don't save file, just drop down to the Open
// file code
break;
case IDCANCEL:
// User pressed cancel
// Don't open a file, don't save changes
return;
}
}
// Open a new file at this point
}