int CFileFilter::DoPromptFilePath(CString &fpath, BOOL bOpen) { int ii; CString fdir, ftitle, fltr; // get dir from fpath or profile if(!GetFileDir(fpath, fdir)) { CString flast= ::AfxGetApp()->GetProfileString("Last File", mDlgName, NULL); GetFileDir(flast, fdir); } if(mCurrID<0) mCurrID= AfxGetApp()->GetProfileInt("Last Filter", mDlgName, 0); // setup filters for(ii=0; ii<mFilterSize; ii++) fltr += mFilters[ii]; DWORD dwFlags; if(bOpen) // loading file: no init name { dwFlags= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; } else // storing file: init name is fpath's title { dwFlags= OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; GetFileTitle(fpath, ftitle); } CFileDialog fdlg(bOpen, NULL, ftitle, dwFlags, fltr, NULL); fdlg.m_ofn.lpstrInitialDir= fdir; fdlg.m_ofn.nFilterIndex= mCurrID+1; fdlg.m_ofn.lpstrTitle= mDlgName; if(fdlg.DoModal() == IDOK) { fpath= fdlg.GetPathName(); GetFileDir(fpath, fdir); mCurrID= fdlg.m_ofn.nFilterIndex-1; CString fext; // no extension given, make one up if(!GetFileExt(fpath, fext) && mCurrID >= 0) { fext= GetFilterExt(mCurrID); // unless the filter's extension is invalid if(fext.IsEmpty() || fext.FindOneOf("*?") >= 0) { fpath.Empty(); return FF_BAD; } fpath += "." + fext; } ::AfxGetApp()->WriteProfileString("Last File", mDlgName, fpath); ::AfxGetApp()->WriteProfileInt("Last Filter", mDlgName, mCurrID); return GetFilterID(fext, true); } fpath.Empty(); return FF_CANCEL; }
void CxpGbaDlg::OnFileBrowse() { CString str; str.LoadString(IDS_FLTR_GBA); CFileDialog fdlg(TRUE, NULL, NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, str); if(mDstDir == "") { char str[MAX_PATH]; GetCurrentDirectory(MAX_PATH, str); mDstDir= str; //::GetRootDir(mDstDir); } fdlg.m_ofn.lpstrInitialDir= mDstDir; fdlg.m_ofn.lpstrTitle= "Get File Path"; if(fdlg.DoModal() == IDOK) { SetDstPath(fdlg.GetPathName()); UpdateRiff(); UpdateData(FALSE); } }
void CStaffSetDlg::OnBnClickedBnSetphoto() { // TODO: 在此添加控件通知处理程序代码 POSITION pos=m_ListCtr_Staff.GetFirstSelectedItemPosition(); int index=m_ListCtr_Staff.GetNextSelectedItem(pos); if (index<0) { AfxMessageBox(_T("请选择一名员工")); return; } CString m_strPhotoPath; CFileDialog fdlg(TRUE, 0, 0, 4|2, m_strPicFilter); if(IDOK == fdlg.DoModal()) { m_strPhotoPath = fdlg.GetPathName(); } SLZStaff staffinfo=m_List_StaffInfo.GetAt(m_List_StaffInfo.FindIndex(index)); staffinfo.SetStaffPhoto(m_strPhotoPath); m_ListCtr_Staff.SetItemState(index,LVIS_FOCUSED,LVIS_FOCUSED); ShowPhoto(m_strPhotoPath); if(staffinfo.GetStaffPhoto()!="") m_ListCtr_Staff.SetItemText(index,4,_T("已配置")); else m_ListCtr_Staff.SetItemText(index,4,_T("未配置")); m_List_StaffInfo.GetAt(m_List_StaffInfo.FindIndex(index))=staffinfo; // SetModified(); }
void CFtpFileDlg::OnBnClickedCancel2() { UpdateData(TRUE); m_BtnQuery.EnableWindow(FALSE); m_EditFtp.EnableWindow(FALSE); m_EditName.EnableWindow(FALSE); m_EditPwd.EnableWindow(FALSE); CString strSourceName,strDesName; CFileDialog fdlg(TRUE); if (fdlg.DoModal()==IDOK){ strSourceName = fdlg.GetPathName(); strDesName = fdlg.GetFileName(); if (PutFile(strSourceName,strDesName)){ AfxMessageBox("上传成功!",MB_OK|MB_ICONINFORMATION); } else{ AfxMessageBox("上传失败!",MB_OK|MB_ICONSTOP); } } else{ AfxMessageBox("请选择文件!",MB_OK|MB_ICONSTOP); } m_BtnUpLoad.EnableWindow(TRUE); m_BtnQuery.EnableWindow(TRUE); m_EditFtp.EnableWindow(TRUE); m_EditName.EnableWindow(TRUE); m_EditPwd.EnableWindow(TRUE); }
void ManagerFrame::OnExportClicked(wxCommandEvent& event) { size_t sel = (size_t)m_replayDV->GetSelection().GetID() - 1; ReplayProvider* provider = static_cast<ReplayDataModel*>(m_replayDV->GetModel())->GetProvider(); Replay::Ptr replay = provider->replay[sel]; wxFileDialog fdlg( this, _("Export replay"), wxStandardPaths::Get().GetDocumentsDir(), replay->GetExportFileName(), "*.zip", wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if (fdlg.ShowModal() == wxID_OK) { replay->Export(fdlg.GetPath()); wxMessageDialog msgDlg(this, _("Export has finished"), _("Information"), wxICON_INFORMATION | wxOK | wxCANCEL | wxCENTER); msgDlg.SetOKCancelLabels(_("Open Folder"), _("Close")); if (msgDlg.ShowModal() == wxID_OK) { wxFileName fn(fdlg.GetPath()); wxLaunchDefaultApplication(fn.GetPath()); } } }
void CFtpFileDlg::OnBnClickedCancel3() { UpdateData(TRUE); int nSel = m_ListFile.GetCurSel(); CString strSourceName; m_ListFile.GetText(nSel,strSourceName); if (strSourceName.GetAt(0)!='['){ CString strDesName; CFileDialog fdlg(FALSE); if (fdlg.DoModal()==IDOK){ strDesName= fdlg.GetPathName(); if (GetFile(strSourceName,strDesName)){ AfxMessageBox("下载成功!",MB_OK|MB_ICONINFORMATION); } else{ AfxMessageBox("下载失败!",MB_OK|MB_ICONSTOP); } } else{ AfxMessageBox("请写入文件名!",MB_OK|MB_ICONSTOP); } } else{ AfxMessageBox("不能下载目录,请重新选择!",MB_OK|MB_ICONSTOP); } m_BtnDownLoad.EnableWindow(TRUE); m_BtnUpLoad.EnableWindow(TRUE); m_BtnQuery.EnableWindow(TRUE); m_EditFtp.EnableWindow(TRUE); m_EditName.EnableWindow(TRUE); m_EditPwd.EnableWindow(TRUE); }
void CSourcesListBox::ExportPlaylist (wxCommandEvent& WXUNUSED(event) ) { //get the current list of files, //build a playlist //offer option to save it. wxFileDialog fdlg (g_MusikFrame, _("Select the path and filename for your playlist"), wxT(""), wxT(""), wxT("Winamp Playlist (.m3u)|*.m3u"), #if !wxCHECK_VERSION(2,8,0) wxSAVE #else wxFD_SAVE #endif ); if ( fdlg.ShowModal() != wxID_OK ) return; //Test for file exist wxTextFile f(fdlg.GetPath()); if (f.Exists()) { if ( wxMessageBox( _( "A playlist with this name already exists, would you like to replace it?" ), MUSIKAPPNAME_VERSION, wxYES_NO | wxICON_QUESTION ) == wxNO ) return; } f.Create(); const MusikSongIdArray &songs = g_PlaylistBox->PlaylistCtrl().Playlist(); for (size_t n =0; n< songs.GetCount();n++) { const wxFileName &name = songs[n].Song()->MetaData.Filename; f.AddLine(name.GetFullPath()); } f.Write(); }
void CxpGbaDlg::OnTilesetBrowse() { CString str; const int NFILTERS=5; FREE_IMAGE_FORMAT iFilters[NFILTERS]= { FIF_BMP, FIF_GIF, FIF_PCX, FIF_PNG, FIF_TARGA }; // Get full list int fif_count; char buffy[1024]; fif_count= fiFillOfnFilter(buffy, FIF_MODE_EXP_8BPP, iFilters, 5); CFileDialog fdlg(TRUE, NULL, NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, buffy); if(mDstDir == "") { char str[MAX_PATH]; GetCurrentDirectory(MAX_PATH, str); mDstDir= str; //::GetRootDir(mDstDir); } fdlg.m_ofn.lpstrInitialDir= mDstDir; fdlg.m_ofn.lpstrTitle= "Get Tileset Path"; if(fdlg.DoModal() == IDOK) { mTilesetPath= fdlg.GetPathName(); UpdateData(FALSE); } }
//以mfc的方式打开文件 // "Chart Files (*.xlc)|*.xlc|Worksheet Files (*.xls)|*.xls| //Data Files (*.xlc;*.xls)|*.xlc; *.xls|All Files (*.*)|*.*||" //说明:文件的类型说明和扩展名间用'|'分隔,同种类型的文件扩展名间用';'分隔,每种文件类型间用'|'分隔,末尾用'||'指明。 bool CVideo::OpenVideo() { CString str_path; CFileDialog fdlg(true, 0, 0, 6UL, L"video file(*.rmvb;*.mp4;)|*.rmvb;*.mp4"); fdlg.DoModal(); str_path = fdlg.GetPathName(); if (str_path == L"") { m_strVideoPath = ""; return true; } string video_path; video_path = CvtChar::WideByte2MultiByte(str_path); m_videoCapture.open(video_path); if (!m_videoCapture.isOpened()) { return false; } //初始化 m_strVideoPath = video_path; m_strVideoFormat = CvtChar::WideByte2MultiByte(fdlg.GetFileExt()); m_strVideoName = CvtChar::WideByte2MultiByte(fdlg.GetFileTitle()); m_nFrameHeight = m_videoCapture.get(CV_CAP_PROP_FRAME_HEIGHT); m_nFrameWidth = m_videoCapture.get(CV_CAP_PROP_FRAME_WIDTH); m_nFrames = m_videoCapture.get(CV_CAP_PROP_FRAME_COUNT); m_nVideofps = m_videoCapture.get(CV_CAP_PROP_FPS); m_nCurFrame = 0; return true; }
void QuickOpenFunctionDialog::gotoFile( QString name ) { FunctionModel *fmodel; FunctionList funcList; FunctionDom fdom; for( FunctionList::ConstIterator it = m_functionDefList.begin() ; it!=m_functionDefList.end() ; ++it ){ fdom = *it; fmodel = fdom.data(); if( fmodel->name() == name ){ funcList.append( fdom ); } } if( funcList.count() == 1 ){ fdom = funcList.first(); fmodel = fdom.data(); QString fileNameStr = fmodel->fileName(); int startline, startcol; fmodel->getStartPosition( &startline, &startcol ); m_part->partController()->editDocument( KURL( fileNameStr), startline, startcol ); selectClassViewItem( ItemDom(&(*fmodel)) ); }else if( funcList.count() > 1 ){ QString fileStr; QuickOpenFunctionChooseForm fdlg( this, name.ascii() ); for( FunctionList::Iterator it = funcList.begin() ; it!=funcList.end() ; ++it ){ fmodel = (*it).data(); fdlg.argBox->insertItem( m_part->languageSupport()->formatModelItem(fmodel) + (fmodel->scope().isEmpty() ? "" : " (in " + fmodel->scope().join("::") + ")")); fileStr = KURL( fmodel->fileName() ).fileName(); KURL full_url( fmodel->fileName() ); KURL base_url( part()->project()->projectDirectory()+"/" ); fdlg.setRelativePath(fdlg.fileBox->count(), KURL::relativeURL( base_url, full_url )); fdlg.fileBox->insertItem(fileStr); } if( fdlg.exec() ){ int id = fdlg.argBox->currentItem(); if( id>-1 && id < (int) funcList.count() ){ FunctionModel *model = funcList[id].data(); int line, col; model->getStartPosition( &line, &col ); selectClassViewItem( ItemDom(&(*model)) ); QString fileNameStr = model->fileName(); m_part->partController()->editDocument( KURL(fileNameStr), line ); } } } else{ KMessageBox::error( this, i18n("Error: cannot find matching name function.") ); } accept(); }
void CDlgData::OnReadFile() { CFileDialog fdlg(true,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"Hex Data Files(*.hex)|*.hex|All Files(*.*)|*.*||",NULL); if(fdlg.DoModal()==IDOK) { CString m_strDesFile=fdlg.GetPathName(); m_strDesFile.TrimRight(); ImportFromFile(m_strDesFile); } }
void BinImg::OnBinImg() { CFileDialog fdlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,_T("BMP Files (*.bmp)|*.bmp")); if(!fdlg.DoModal()) return; CString str; str=fdlg.GetPathName(); char strPath[256]={0}; memcpy(strPath,str,str.GetLength()); strcpy(gstrPath,strPath); ShowBMP(IDC_BINIMG,strPath); }
void CTemplateFileListDialog::OnTflAdd() { CFileDialog fdlg(TRUE, "WWTpl", "*.WWTpl", OFN_HIDEREADONLY, "Code Template Files (*.WWTpl)|*.WWTpl||", NULL); fdlg.m_ofn.lpstrTitle = "Find Template Files"; if(fdlg.DoModal() == IDCANCEL) return; if (g_wwhizTemplateManager->Add(fdlg.GetPathName()) != -1) { Refresh(); } }
void CbaltoshopView::OnFileSaveAs() { // TODO: 여기에 명령 처리기 코드를 추가합니다. m_SaveImg = m_ConvertImg; CFileDialog fdlg(true); fdlg.DoModal(); if(m_SaveImg.WriteBMP(fdlg.GetPathName())) m_SavePath = fdlg.GetPathName(); else AfxMessageBox(TEXT("저장 실패")); }
void CbaltoshopView::OnFileOpen() { // TODO: 여기에 명령 처리기 코드를 추가합니다. CFileDialog fdlg(true); fdlg.DoModal(); m_SavePath = fdlg.GetPathName(); m_SaveImg.LoadBMP(fdlg.GetPathName()); m_ConvertImg = m_SaveImg; Invalidate(); }
void CDlgData::OnSaveFile() { CFileDialog fdlg(false,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"Hex Data Files(*.hex)|*.hex|All Files(*.*)|*.*||",NULL); if(fdlg.DoModal()==IDOK) { CString m_strDesFile=fdlg.GetPathName(); m_strDesFile.TrimRight(); if (m_strDesFile.Right(4).Compare(".hex")!=0) { m_strDesFile+=".hex"; } ExportToFile(m_strDesFile); } }
void CTestOutlineTextDlg::OnBnClickedBtnImagebrowse() { TCHAR szFilter[] = _T("All Files (*.*)||"); CFileDialog fdlg( TRUE, NULL, NULL, OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, AfxGetMainWnd() ); if( IDOK == fdlg.DoModal( ) ) { CString szBuf = fdlg.GetPathName(); m_pScrollView->SetImage(szBuf); } }
void CPropShowTime::OnBnClickedBnFont() { // TODO: 在此添加控件通知处理程序代码 LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); CFont* pFont = m_ed_example.GetFont(); if(pFont != NULL) pFont->GetLogFont(&lf); CFontDialog fdlg(&lf); LOGFONT lplf; if(IDOK==fdlg.DoModal()) { fdlg.GetCurrentFont(&lplf); m_textFont.DeleteObject(); m_textFont.CreateFontIndirect(&lplf); m_ed_example.SetFont(&m_textFont,TRUE);//改变标题编辑框的字体和颜色 } }
void CTestOutlineTextDlg::OnBnClickedBtnSaveReflectivePng() { TCHAR szFilter[] = _T("PNG Image files (*.png)||"); CFileDialog fdlg( FALSE, NULL, NULL, OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, AfxGetMainWnd() ); if( IDOK == fdlg.DoModal( ) ) { CString szBuf = fdlg.GetPathName(); if(szBuf.Find(_T(".png"))==-1 && szBuf.Find(_T(".PNG"))==-1 && szBuf.Find(_T(".Png"))==-1) { szBuf += _T(".png"); } if(m_pScrollView->IsEnablePngRendering()&&m_pScrollView->IsEnableReflection()) m_pScrollView->SaveRefPngImage(szBuf); } }
void CEditImage::OnLoad() { // TODO: Add your control notification handler code here if (!m_transWnd) return; CString filename; static char BASED_CODE szFilter[] = "Picture Files (*.bmp; *.jpg; *.gif)|*.bmp; *.jpg; *.gif||"; static char szTitle[]="Load Picture"; CFileDialog fdlg(TRUE,"*.bmp; *.jpg; *.gif","*.bmp; *.jpg; *.gif",OFN_LONGNAMES | OFN_FILEMUSTEXIST ,szFilter,this); fdlg.m_ofn.lpstrTitle=szTitle; if(fdlg.DoModal() == IDOK) { filename = fdlg.GetPathName(); m_transWnd->ReloadPic(filename); m_transWnd->Invalidate(); } }
void CFlashInterface::OnButtonchoose() { static char BASED_CODE szFilter[] = "Windows Bitamp Files (*.bmp)|*.bmp||"; char szTitle[] = "Select bitmap to display when SWF is loading" ; CFileDialog fdlg(FALSE,"*.bmp","*.bmp",OFN_LONGNAMES,szFilter,this); fdlg.m_ofn.lpstrTitle=szTitle; CString m_newfile; if (fdlg.DoModal() == IDOK) { m_newfile = fdlg.GetPathName(); ((CEdit *)GetDlgItem(IDC_PRELOADBITMAP))->SetWindowText(m_newfile); } else { return; } }
void CSourcesListBox::ImportPlaylist (wxCommandEvent& WXUNUSED(event) ) { //get the current list of files, //build a playlist //offer option to save it. wxFileDialog fdlg (g_MusikFrame, _("Select the path and filename for your playlist"), wxT(""), wxT(""), wxT("Winamp Playlist (.m3u)|*.m3u"), #if !wxCHECK_VERSION(2,8,0) wxOPEN #else wxFD_OPEN #endif ); if ( fdlg.ShowModal() != wxID_OK ) return; wxBusyCursor bc; wxArrayString arrFiles; ImportM3U(fdlg.GetPath(),arrFiles); g_MusikFrame->AutoUpdate(arrFiles,MUSIK_UpdateFlags::WaitUntilDone|MUSIK_UpdateFlags::Quiet|MUSIK_UpdateFlags::NoPurge); MusikSongIdArray songids; wxGetApp().Library.GetFilelistSongs(arrFiles,songids); NewPlaylist(wxFileName::FileName(fdlg.GetPath()).GetName(),songids,MUSIK_SOURCES_PLAYLIST_STANDARD); return; }
void vdr_pi::OnToolbarToolCallback(int id) { if ( id == m_tb_item_id_play ) { if ( IsRunning() ) // Timer started? { Stop(); // Stop timer m_istream.Close(); if ( m_pvdrcontrol ) { m_pauimgr->DetachPane( m_pvdrcontrol ); m_pvdrcontrol->Close(); m_pvdrcontrol->Destroy(); m_pvdrcontrol = NULL; } SetToolbarItemState( id, false ); } else { wxFileDialog fdlg( GetOCPNCanvasWindow(), _("Choose a file"), wxT(""), m_ifilename, wxT("*.*"), wxFD_OPEN|wxFD_FILE_MUST_EXIST ); if ( fdlg.ShowModal() != wxID_OK) { SetToolbarItemState( id, false ); return; } m_ifilename.Clear(); m_ifilename = fdlg.GetPath(); m_istream.Open( m_ifilename ); Start( m_interval, wxTIMER_CONTINUOUS ); // start timer if (! m_pvdrcontrol ) { m_pvdrcontrol = new VDRControl( GetOCPNCanvasWindow(), wxID_ANY, this, 1000/m_interval, m_istream.GetLineCount() ); wxAuiPaneInfo pane = wxAuiPaneInfo().Name(_T("VDR")).Caption(wxString::Format(_("VDR replay: %s"), fdlg.GetFilename())).CaptionVisible(true).Float().FloatingPosition(50,100).Dockable(false).Fixed().CloseButton(false).Show(true); m_pauimgr->AddPane( m_pvdrcontrol, pane ); m_pauimgr->Update(); } SetToolbarItemState( id, true ); } } else if ( id == m_tb_item_id_record ) { if ( m_recording ) { m_ostream.Close(); m_recording = false; SetToolbarItemState( id, false ); } else { wxFileDialog fdlg( GetOCPNCanvasWindow(), _("Choose a file"), wxT(""), m_ofilename, wxT("*.*"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT ); if ( fdlg.ShowModal() != wxID_OK) { SetToolbarItemState( id, false ); return; } m_ofilename.Clear(); m_ofilename = fdlg.GetPath(); //m_ostream.Open( m_ofilename, wxFile::write_append ); m_ostream.Open( m_ofilename, wxFile::write ); m_recording = true; SetToolbarItemState( id, true ); } } }