When I close the dialog via the system menu (X box in dialog title) I want to check whether the grid has been edited. Is it possible to display a message box when there are pending changes?
Here is some sample code that shows you how to process the WM_CLOSE message of your parent dialog. m_wndGrid is the CGXRecordWnd (or CGXBrowserWnd or CGXDaoRecordWnd) object which is displayed in the dialog.
void CRecordWndSampleDialog::OnClose()
{
m_wndGrid.TransferCurrentCell();
if (m_wndGrid.IsRecordDirty())
{
int nAction = AfxMessageBox(_T("Save changes?"), MB_YESNOCANCEL);
switch (nAction)
{
case IDYES:
m_wndGrid.Update();
break;
case IDNO:
m_wndGrid.CancelRecord();
break;
case IDCANCEL:
m_wndGrid.SetFocus();
return;
}
}
CDialog::OnClose();
}