bool LuaScriptEditorView::QueryClose() { if (!GetModify()) return true; CWindow wndMain(GetParent()); CString cszText; cszText.Format(_T("Save changes to %s ?"), m_cszFileTitle.GetString()); int iRet = AtlMessageBox(wndMain, cszText.GetString(), IDR_MAINFRAME, MB_YESNOCANCEL | MB_ICONQUESTION); if (iRet == IDCANCEL) return false; else if (iRet == IDYES && !DoFileSaveAs()) return false; return true; }
fnSaveAs() { /* Entry point for the "Save As..." command */ extern int vfCloseFilesInDialog; extern int vfOutOfMemory; extern HANDLE vhReservedSpace; if (!CanReadEveryFile((**((**hpdocdod)[docCur].hszFile)))) return; vfCloseFilesInDialog = TRUE; /* Close all files on removable media so changing disks is safe */ CloseEveryRfn( TRUE ); /* Free the reserved block, to give us memory for the save dialog box and for CmdXfSave */ if (vhReservedSpace != NULL) { LocalFree(vhReservedSpace); vhReservedSpace = NULL; } PreloadSaveSegs(); /* Advance loading of code to avoid disk swaps */ DoFileSaveAs(); if ((vhReservedSpace = LocalAlloc( LHND, cbReserve )) == NULL) { /* Either we were unable to bring up the save dialog box, or we were unable to re-establish our block of reserved space. */ #if WINVER >= 0x300 WinFailure(); #else Error(IDPMTNoMemory); #endif } UpdateInvalid(); /* Assure screen gets updated */ vfCloseFilesInDialog = FALSE; }
LRESULT MainFrame::OnFileOpen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CFileDialog dlg(TRUE, NULL, _T(""), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, g_pszLuaScriptingFilter); int iRet = dlg.DoModal(m_hWnd); if (iRet == IDOK) { bool bRet = m_view.QueryClose(); if (!bRet) { if (!DoFileSaveAs()) return 0; } if (DoFileOpen(dlg.m_ofn.lpstrFile, dlg.m_ofn.lpstrFileTitle)) { m_mru.AddToList(dlg.m_ofn.lpstrFile); m_mru.WriteToRegistry(c_pszSettingsRegkey); } } return 0; }
bool MainFrame::DoFileSave() { if (!m_view.GetFilePath().IsEmpty()) { if (m_view.Save(m_view.GetFilePath())) { m_mru.AddToList(m_view.GetFilePath()); m_mru.WriteToRegistry(c_pszSettingsRegkey); UpdateTitle(); } else { AtlMessageBox(m_hWnd, _T("Error writing file!\n"), IDR_MAINFRAME, MB_OK | MB_ICONERROR); return false; } } else { return DoFileSaveAs(); } return true; }
LRESULT MainFrame::OnFileSaveAs(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { DoFileSaveAs(); return 0; }