void TMDIReport::FileSave(void) // Запись отчета { if (FileName=="") FileSaveAs(); else { RichBox->Lines->SaveToFile(FileName); RichBox->Modified=false; Caption=FileName; } }
void TMDIhtml::FileSave(void) // Запись отчета { if (FileName=="") FileSaveAs(); else { Memo1->Lines->SaveToFile(FileName); //RichBox->Lines->SaveToFile(FileName); Modified=false; //Caption=FileName; } }
LRESULT CXRecvDlg::OnChildFire(WPARAM wparam,LPARAM lparam) { m_staticRefuse.ShowWindow(SW_HIDE); m_staticSave.ShowWindow(SW_HIDE); m_staticSaveAs.ShowWindow(SW_HIDE); switch ((int)wparam) { case IDC_STATIC_SAVEAS: { char *szFilePath = FileSaveAs(); if (szFilePath) // return NULL { SetTimer(55, 100, NULL); m_staticCancel.ShowWindow(SW_SHOW); delete szFilePath; } else { m_staticRefuse.ShowWindow(SW_SHOW); m_staticSave.ShowWindow(SW_SHOW); m_staticSaveAs.ShowWindow(SW_SHOW); } return 1; } case IDC_STATIC_SAVE: { // m_staticCancel.ShowWindow(SW_SHOW); // SetTimer(55, 100, NULL); return 1; } case IDC_STATIC_REFUSE: { m_staticRefuse.ShowWindow(SW_HIDE); m_staticSave.ShowWindow(SW_HIDE); m_staticSaveAs.ShowWindow(SW_HIDE); SetDlgItemText(IDC_STATIC10, "文件已拒收..."); SendRefuseMsg(); SetTimer(88, 1000, NULL); return 1; } case IDC_STATIC_CANCEL: { // m_staticCancel.ShowWindow(SW_HIDE); // m_bRunning = FALSE; return 1; } } return 0; }
/*! 上書き保存 @return 保存が行われたor保存不要のため何も行わなかったときにtrueを返す @date 2004.06.05 genta ビューモードのチェックをCEditDocから上書き保存処理に移動 @date 2006.12.30 ryoji CEditView::Command_FILESAVE()から処理本体を切り出し @date 2008.03.20 kobake 戻り値の仕様を定義 */ bool CDocFileOperation::FileSave() { //ファイル名が指定されていない場合は「名前を付けて保存」のフローへ遷移 if( !m_pcDocRef->m_cDocFile.GetFilePathClass().IsValidPath() ){ return FileSaveAs(); } //セーブ情報 SSaveInfo sSaveInfo; m_pcDocRef->GetSaveInfo(&sSaveInfo); sSaveInfo.cEol = EOL_NONE; //改行コード無変換 sSaveInfo.bOverwriteMode = true; //上書き要求 //上書き処理 return m_pcDocRef->m_cDocFileOperation.DoSaveFlow(&sSaveInfo); }
/************************************************************************** * * Name : FileSave(mp2) * * Description: Processes the File menu's Save item * * Concepts: Called whenever SAVE from the FILE menu is selected * * Routine opens the file for output, calls the * application's save routine, and closes the file. * * API's : DosOpen * DosClose * * Parameters : mp2 = second message parameter * * Return : [none] * *************************************************************************/ VOID FileSave(MPARAM mp2) { HFILE hf; ULONG ulAction; /* * If the file currently is untitled, we will need to get a file * name from the user before we can open the file. Getting a * file name is normally done during the FileSaveAs operation * so we will treat this save as a SaveAs and call FileSaveAs(). * If the file is titled, then we save the file. * * NOTE: This routine will be called by FileSaveAs(), but only * after a valid file name has been obtained. So, FileSaveAs() * will not be called again from this routine. */ if(szFullPath[0] == '\0') { FileSaveAs(mp2); return; } /* open the file */ if( DosOpen(szFullPath, /* file name of current document */ &hf, /* file handle of output file */ &ulAction, 0L, FILE_NORMAL, FILE_OPEN | FILE_CREATE, OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE, (PEAOP2)NULL)) { MessageBox(hwndMain, IDMSG_CANNOTOPENOUTPUTFILE, MB_OK | MB_ERROR, FALSE); return; } WriteFileToDisk(hf); DosClose(hf); /* This routine currently doesn't use the mp2 parameter but *\ * it is referenced here to prevent an 'Unreferenced Parameter' \* warning at compile time. */ mp2; } /* End of FileSave */
//--------------------------------------------------------------------------- void TMDIChild::FileSave(void) // Запись исходных данных { if (FileName=="") FileSaveAs(); else { Caption=FileName; // Дальше идет код сохранения данных формы TFileStream *a=new TFileStream(FileName,fmCreate|fmOpenWrite); DiskStream *S=new DiskStream(a); S->Write("LIW"); S->Write(SaveVer); // Номер версии сохранения, должен увеличиваться с добавлением новых данных int nSegment=UpDown->Position; // Количество участков S->Write(nSegment); S->Write(SortamentBox->ItemIndex); S->Write(HminEdit->Text.ToDouble()); S->Write(HmaxEdit->Text.ToDouble()); S->Write(dHmaxEdit->Text.ToDouble()); // Данные о местности S->Write(q20Edit->Text.ToDouble()); S->Write(pEdit->Text.ToDouble()); S->Write(F0Edit->Text.ToDouble()); S->Write(GammaEdit->Text.ToDouble()); S->Write(MEdit->Text.ToDouble()); S->Write(ZSEdit->Text.ToDouble()); S->Write(TkEdit->Text.ToDouble()); S->Write(TlEdit->Text.ToDouble()); S->Write(FEEdit->Text.ToDouble()); for(int i=0;i<nSegment+1;i++) { S->Write(GeodezicCells->Cells[1][i+1]); S->Write(GeodezicCells->Cells[2][i+1]); } for(int i=0;i<nSegment;i++) { S->Write(SegmentCells->Cells[1][i+1]); S->Write(SegmentCells->Cells[2][i+1]); S->Write(SegmentCells->Cells[3][i+1]); S->Write(SegmentCells->Cells[4][i+1]); S->Write(SegmentCells->Cells[5][i+1]); S->Write(SegmentCells->Cells[6][i+1]); } S->Write(ComboType->ItemIndex); delete S; delete a; } }
void CRepositoryBrowser::ShowContextMenu(CPoint point, TShadowFilesTreeList &selectedLeafs, eSelectionType selType) { CIconMenu popupMenu; popupMenu.CreatePopupMenu(); bool bAddSeparator = false; if (selectedLeafs.size() == 1) { popupMenu.AppendMenuIcon(eCmd_Open, IDS_REPOBROWSE_OPEN, IDI_OPEN); popupMenu.SetDefaultItem(eCmd_Open, FALSE); if (selType == ONLY_FILES || selType == ONLY_FILESSUBMODULES) { popupMenu.AppendMenuIcon(eCmd_OpenWith, IDS_LOG_POPUP_OPENWITH, IDI_OPEN); popupMenu.AppendMenuIcon(eCmd_OpenWithAlternativeEditor, IDS_LOG_POPUP_VIEWREV); } popupMenu.AppendMenu(MF_SEPARATOR); if (m_bHasWC && (selType == ONLY_FILES || selType == ONLY_FILESSUBMODULES)) { popupMenu.AppendMenuIcon(eCmd_CompareWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF); bAddSeparator = true; } if (bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; CString temp; temp.LoadString(IDS_MENULOG); popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG); if (selType == ONLY_FILES) { if (m_bHasWC) popupMenu.AppendMenuIcon(eCmd_Blame, IDS_LOG_POPUP_BLAME, IDI_BLAME); popupMenu.AppendMenu(MF_SEPARATOR); temp.LoadString(IDS_LOG_POPUP_SAVE); popupMenu.AppendMenuIcon(eCmd_SaveAs, temp, IDI_SAVEAS); } bAddSeparator = true; } if (!selectedLeafs.empty() && selType == ONLY_FILES && m_bHasWC) { popupMenu.AppendMenuIcon(eCmd_Revert, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT); bAddSeparator = true; } if (bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if (!selectedLeafs.empty()) { popupMenu.AppendMenuIcon(eCmd_CopyPath, IDS_STATUSLIST_CONTEXT_COPY, IDI_COPYCLIP); popupMenu.AppendMenuIcon(eCmd_CopyHash, IDS_COPY_COMMIT_HASH, IDI_COPYCLIP); } eCmd cmd = (eCmd)popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_RETURNCMD, point.x, point.y, this, 0); switch(cmd) { case eCmd_ViewLog: { CString sCmd; sCmd.Format(_T("/command:log /path:\"%s\\%s\""), g_Git.m_CurrentDir, selectedLeafs.at(0)->GetFullName()); if (selectedLeafs.at(0)->m_bSubmodule) sCmd += _T(" /submodule"); CAppUtils::RunTortoiseGitProc(sCmd); } break; case eCmd_Blame: { CAppUtils::LaunchTortoiseBlame(g_Git.m_CurrentDir + _T("\\") + selectedLeafs.at(0)->GetFullName(), m_sRevision); } break; case eCmd_Open: if (!selectedLeafs.at(0)->m_bSubmodule && selectedLeafs.at(0)->m_bFolder) { FillListCtrlForTreeNode(selectedLeafs.at(0)->m_hTree); m_RepoTree.SelectItem(selectedLeafs.at(0)->m_hTree); return; } OpenFile(selectedLeafs.at(0)->GetFullName(), OPEN, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_OpenWith: OpenFile(selectedLeafs.at(0)->GetFullName(), OPEN_WITH, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_OpenWithAlternativeEditor: OpenFile(selectedLeafs.at(0)->GetFullName(), ALTERNATIVEEDITOR, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_CompareWC: { CTGitPath file(selectedLeafs.at(0)->GetFullName()); CGitDiff::Diff(&file, &file, GIT_REV_ZERO, m_sRevision); } break; case eCmd_Revert: { int count = 0; for (TShadowFilesTreeList::iterator itShadowTree = selectedLeafs.begin(); itShadowTree != selectedLeafs.end(); ++itShadowTree) { if (RevertItemToVersion((*itShadowTree)->GetFullName())) ++count; else break; } CString msg; msg.Format(IDS_STATUSLIST_FILESREVERTED, count, m_sRevision); MessageBox(msg, _T("TortoiseGit"), MB_OK); } break; case eCmd_SaveAs: FileSaveAs(selectedLeafs.at(0)->GetFullName()); break; case eCmd_CopyPath: { CString sClipboard; for (TShadowFilesTreeList::iterator itShadowTree = selectedLeafs.begin(); itShadowTree != selectedLeafs.end(); ++itShadowTree) { sClipboard += (*itShadowTree)->m_sName + _T("\r\n"); } CStringUtils::WriteAsciiStringToClipboard(sClipboard); } break; case eCmd_CopyHash: { CopyHashToClipboard(selectedLeafs); } break; } }
void CRepositoryBrowser::ShowContextMenu(CPoint point, TShadowFilesTreeList &selectedLeafs, eSelectionType selType) { CIconMenu popupMenu; popupMenu.CreatePopupMenu(); bool bAddSeparator = false; if (selectedLeafs.size() == 1) { popupMenu.AppendMenuIcon(eCmd_Open, IDS_REPOBROWSE_OPEN, IDI_OPEN); popupMenu.SetDefaultItem(eCmd_Open, FALSE); if (selType == ONLY_FILES || selType == ONLY_FILESSUBMODULES) { popupMenu.AppendMenuIcon(eCmd_OpenWith, IDS_LOG_POPUP_OPENWITH, IDI_OPEN); popupMenu.AppendMenuIcon(eCmd_OpenWithAlternativeEditor, IDS_LOG_POPUP_VIEWREV); } popupMenu.AppendMenu(MF_SEPARATOR); if (m_bHasWC && (selType == ONLY_FILES || selType == ONLY_FILESSUBMODULES)) { popupMenu.AppendMenuIcon(eCmd_CompareWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF); bAddSeparator = true; } if (bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; CString temp; temp.LoadString(IDS_MENULOG); popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG); if (selectedLeafs[0]->m_bSubmodule) { temp.LoadString(IDS_MENULOGSUBMODULE); popupMenu.AppendMenuIcon(eCmd_ViewLogSubmodule, temp, IDI_LOG); } if (selType == ONLY_FILES) { if (m_bHasWC) popupMenu.AppendMenuIcon(eCmd_Blame, IDS_LOG_POPUP_BLAME, IDI_BLAME); popupMenu.AppendMenu(MF_SEPARATOR); temp.LoadString(IDS_LOG_POPUP_SAVE); popupMenu.AppendMenuIcon(eCmd_SaveAs, temp, IDI_SAVEAS); } bAddSeparator = true; } if (!selectedLeafs.empty() && selType == ONLY_FILES && m_bHasWC) { popupMenu.AppendMenuIcon(eCmd_Revert, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT); bAddSeparator = true; } if (bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if (selectedLeafs.size() == 1 && selType == ONLY_FILES) { popupMenu.AppendMenuIcon(eCmd_PrepareDiff, IDS_PREPAREDIFF, IDI_DIFF); if (!m_sMarkForDiffFilename.IsEmpty()) { CString diffWith; if (selectedLeafs.at(0)->GetFullName() == m_sMarkForDiffFilename) diffWith = m_sMarkForDiffVersion; else { PathCompactPathEx(diffWith.GetBuffer(40), m_sMarkForDiffFilename, 39, 0); diffWith.ReleaseBuffer(); diffWith += _T(":") + m_sMarkForDiffVersion.ToString().Left(g_Git.GetShortHASHLength()); } CString menuEntry; menuEntry.Format(IDS_MENUDIFFNOW, (LPCTSTR)diffWith); popupMenu.AppendMenuIcon(eCmd_PrepareDiff_Compare, menuEntry, IDI_DIFF); } popupMenu.AppendMenu(MF_SEPARATOR); } if (!selectedLeafs.empty()) { popupMenu.AppendMenuIcon(eCmd_CopyPath, IDS_STATUSLIST_CONTEXT_COPY, IDI_COPYCLIP); popupMenu.AppendMenuIcon(eCmd_CopyHash, IDS_COPY_COMMIT_HASH, IDI_COPYCLIP); } eCmd cmd = (eCmd)popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_RETURNCMD, point.x, point.y, this, 0); switch(cmd) { case eCmd_ViewLog: case eCmd_ViewLogSubmodule: { CString sCmd; sCmd.Format(_T("/command:log /path:\"%s\\%s\""), (LPCTSTR)g_Git.m_CurrentDir, (LPCTSTR)selectedLeafs.at(0)->GetFullName()); if (cmd == eCmd_ViewLog && selectedLeafs.at(0)->m_bSubmodule) sCmd += _T(" /submodule"); CAppUtils::RunTortoiseGitProc(sCmd); } break; case eCmd_Blame: { CAppUtils::LaunchTortoiseBlame(g_Git.CombinePath(selectedLeafs.at(0)->GetFullName()), m_sRevision); } break; case eCmd_Open: if (!selectedLeafs.at(0)->m_bSubmodule && selectedLeafs.at(0)->m_bFolder) { FillListCtrlForTreeNode(selectedLeafs.at(0)->m_hTree); m_RepoTree.SelectItem(selectedLeafs.at(0)->m_hTree); return; } OpenFile(selectedLeafs.at(0)->GetFullName(), OPEN, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_OpenWith: OpenFile(selectedLeafs.at(0)->GetFullName(), OPEN_WITH, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_OpenWithAlternativeEditor: OpenFile(selectedLeafs.at(0)->GetFullName(), ALTERNATIVEEDITOR, selectedLeafs.at(0)->m_bSubmodule, selectedLeafs.at(0)->m_hash); break; case eCmd_CompareWC: { CTGitPath file(selectedLeafs.at(0)->GetFullName()); CGitDiff::Diff(&file, &file, GIT_REV_ZERO, m_sRevision); } break; case eCmd_Revert: { int count = 0; for (TShadowFilesTreeList::iterator itShadowTree = selectedLeafs.begin(); itShadowTree != selectedLeafs.end(); ++itShadowTree) { if (RevertItemToVersion((*itShadowTree)->GetFullName())) ++count; else break; } CString msg; msg.Format(IDS_STATUSLIST_FILESREVERTED, count, (LPCTSTR)m_sRevision); MessageBox(msg, _T("TortoiseGit"), MB_OK); } break; case eCmd_SaveAs: FileSaveAs(selectedLeafs.at(0)->GetFullName()); break; case eCmd_CopyPath: { CString sClipboard; for (TShadowFilesTreeList::iterator itShadowTree = selectedLeafs.begin(); itShadowTree != selectedLeafs.end(); ++itShadowTree) { sClipboard += (*itShadowTree)->m_sName + _T("\r\n"); } CStringUtils::WriteAsciiStringToClipboard(sClipboard); } break; case eCmd_CopyHash: { CopyHashToClipboard(selectedLeafs); } break; case eCmd_PrepareDiff: m_sMarkForDiffFilename = selectedLeafs.at(0)->GetFullName(); if (g_Git.GetHash(m_sMarkForDiffVersion, m_sRevision)) { m_sMarkForDiffFilename.Empty(); MessageBox(g_Git.GetGitLastErr(_T("Could not get SHA-1 for ") + m_sRevision), _T("TortoiseGit"), MB_ICONERROR); } break; case eCmd_PrepareDiff_Compare: { CTGitPath savedFile(m_sMarkForDiffFilename); CTGitPath selectedFile(selectedLeafs.at(0)->GetFullName()); CGitHash currentHash; if (g_Git.GetHash(currentHash, m_sRevision)) { MessageBox(g_Git.GetGitLastErr(_T("Could not get SHA-1 for ") + m_sRevision), _T("TortoiseGit"), MB_ICONERROR); return; } CGitDiff::Diff(&selectedFile, &savedFile, currentHash, m_sMarkForDiffVersion); } break; } }