//-------------------------------------------------------------------------------------------- LRESULT TestDialog::OnButtonLoadFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { CFileDialog fileDlg(TRUE, _T("Captcha Font File"), 0, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Captcha Font File(*.cpf)\0*.cpf\0All files(*.*)\0*.*\0\0"), m_hWnd); if(IDOK != fileDlg.DoModal()) return 0; FILE* fp = _tfopen(fileDlg.m_szFileName, _T("rb")); fseek(fp, 0, SEEK_END); unsigned int fileSize = ftell(fp); fseek(fp, 0, SEEK_SET); unsigned char* streamBuf = new unsigned char[fileSize]; fread(streamBuf, 1, fileSize, fp); fclose(fp); if(!(m_fontFile.loadFromDataStream(streamBuf, fileSize))) { delete[] streamBuf; return 0; } delete[] streamBuf; ::EnableWindow(GetDlgItem(IDC_BUTTON_RAND), TRUE); return 0; }
BOOL CMainFrame::GetTerminalFile(BOOL bOpen, CString *pszFile) { CString szInitialPath; DWORD dwFlags; BOOL bRet = FALSE; dwFlags = OFN_HIDEREADONLY | OFN_ENABLESIZING; if (bOpen == TRUE) { dwFlags |= OFN_FILEMUSTEXIST; } CFileDialog fileDlg(bOpen, NULL, NULL, dwFlags, DCOM_TERMINALS_EXTS, this); szInitialPath = AfxGetApp()->GetProfileString(DCOM_TERMINALS_SECTION, DCOM_TERMINALS_PATH, ""); if (szInitialPath.GetLength()) { fileDlg.m_ofn.lpstrInitialDir = szInitialPath; } if (fileDlg.DoModal() == IDOK) { *pszFile = fileDlg.GetPathName(); AfxGetApp()->WriteProfileString(DCOM_TERMINALS_SECTION, DCOM_TERMINALS_PATH, *pszFile); bRet = TRUE; } return bRet; }
void TexturePackPanel::OnExportGIFClicked(wxCommandEvent& event) { wxFileName exFileName(m_textureListBox->GetString(m_textureListBox->GetSelection()), wxPATH_UNIX); exFileName.SetExt("gif"); wxString defaultFileName = exFileName.GetFullName(); wxFileDialog fileDlg(this, _("Select target gif"), wxStandardPaths::Get().GetDocumentsDir(), defaultFileName, "*.gif", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (fileDlg.ShowModal() == wxID_OK) { wxBusyCursor busyCursor; wxImageArray images; const Texture& tex = m_texturePack->at(m_textureListBox->GetSelection()); for (auto frame = tex.begin(); frame != tex.end(); ++frame) { wxImage frameImg(GetFrameBitmap(*frame).ConvertToImage()); wxQuantize::Quantize(frameImg, frameImg, 256); images.Add(frameImg); } wxGIFHandler* gifHandler = (wxGIFHandler*) wxImage::FindHandler(wxBITMAP_TYPE_GIF); wxTempFileOutputStream oStr(fileDlg.GetPath()); gifHandler->SaveAnimation(images, &oStr, true, m_frameDelaySpinCtrl->GetValue()); oStr.Commit(); } }
/** On quit command event handler */ void srs_ui_but::CButProjection::CControllPane::OnSave(wxCommandEvent& event) { wxFileDialog fileDlg(this, _("Choose file to save"), wxEmptyString, _("screenshot.png"), _("*.*"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxString filename, directory; // Pause timer if(m_chkb->GetValue()) m_sigCheckBox( false ); if( fileDlg.ShowModal() == wxID_OK ) { filename = fileDlg.GetFilename(); directory = fileDlg.GetDirectory(); std::string path(std::string( wxString(directory + wxFileName::GetPathSeparator() + filename).mb_str() ) ); m_sigSave( path ); } // Start timer if(m_chkb->GetValue()) m_sigCheckBox( true ); }
bool KSceneSFXEditorBillboardPage::BrowseTexture(CString& strTextureName) { // TODO: Add your control notification handler code here GET_SFX_EDITOR_RET(false); GET_BILLBOARD_RET(false); char szFilters[] = "Texture Files|*.TGA;*.BMP;*.JPG;*.DDS;*.PNG|\ (*.TGA)|*.TGA|\ (*.BMP)|*.BMP|\ (*.JPG)|*.JPG|\ (*.DDS)|*.DDS|\ (*.PNG)|*.PNG|\ All Files (*.*)|*.*||"; CFileDialog fileDlg( TRUE, NULL, NULL, OFN_EXPLORER|OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this ); if (fileDlg.DoModal() == IDOK) { strTextureName = fileDlg.GetPathName(); return true; } return false; }
void ConfigDialog::on_browseProject_clicked() { QFileDialog fileDlg( this, tr("Default project file"), defaultSetupFile(myHost), tr("Project file (*.%1)").arg(PROJECT_FILE_EXTENSION) ); fileDlg.setFileMode(QFileDialog::ExistingFile); fileDlg.setDefaultSuffix(PROJECT_FILE_EXTENSION); QString filename; if (fileDlg.exec()) filename = fileDlg.selectedFiles().value(0); if(filename.isEmpty()) return; if(!filename.endsWith(PROJECT_FILE_EXTENSION)) { QMessageBox msgBox; msgBox.setText(tr("Wrong file extension.")); msgBox.exec(); return; } AddRecentProjectFile(filename,myHost); int i = ui->defaultProject->findText(filename); if(i == -1) { ui->defaultProject->addItem(filename); i = ui->defaultProject->findText(filename); } ui->defaultProject->setCurrentIndex( i ); myHost->SetSetting("defaultProjectFile", filename ); }
WS_DATA_ITEM* PL_EDITOR_FRAME::AddPageLayoutItem( int aType ) { WS_DATA_ITEM * item = NULL; switch( aType ) { case WS_DATA_ITEM::WS_TEXT: item = new WS_DATA_ITEM_TEXT( wxT( "Text") ); break; case WS_DATA_ITEM::WS_SEGMENT: item = new WS_DATA_ITEM( WS_DATA_ITEM::WS_SEGMENT ); break; case WS_DATA_ITEM::WS_RECT: item = new WS_DATA_ITEM( WS_DATA_ITEM::WS_RECT ); break; case WS_DATA_ITEM::WS_POLYPOLYGON: item = new WS_DATA_ITEM_POLYGONS(); break; case WS_DATA_ITEM::WS_BITMAP: { wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString, _( "Image Files " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN ); if( fileDlg.ShowModal() != wxID_OK ) return NULL; wxString fullFilename = fileDlg.GetPath(); if( !wxFileExists( fullFilename ) ) { wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename ); break; } BITMAP_BASE* image = new BITMAP_BASE(); if( !image->ReadImageFile( fullFilename ) ) { wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename ); delete image; break; } item = new WS_DATA_ITEM_BITMAP( image ); } break; } if( item == NULL ) return NULL; WS_DATA_MODEL::GetTheInstance().Append( item ); item->SyncDrawItems( nullptr, GetGalCanvas()->GetView() ); return item; }
void MultiViewerMain::OnUIFileNew(wxCommandEvent& ) { Trace(emTraceProgramProcess, "File New"); if(!ConfirmNewDialog()) { return; } m_pSQLReader = new SqliteReader(); wxString wxstrFileNmae; wxFileDialog fileDlg(this, SQLUtil::str2wxstr("Select Where to save"), SQLUtil::str2wxstr(""),SQLUtil::str2wxstr(""), SQLUtil::str2wxstr("*.db"), wxFD_SAVE ); if(fileDlg.ShowModal() != wxID_OK) { fileDlg.Destroy(); return; } wxstrFileNmae = fileDlg.GetDirectory(); wxstrFileNmae.Append(wxFileName::GetPathSeparator()); wxstrFileNmae += fileDlg.GetFilename(); std::string strFileName = SQLUtil::wxstr2str(wxstrFileNmae); FileNew( strFileName.c_str() ); }
void MultiViewerMain::OnUIFileOpen(wxCommandEvent& ) { //wxMessageBox(_("Test"), _("OnMenuFileOpen")); Trace(emTraceProgramProcess, "File Open"); if(!ConfirmNewDialog()) { return; } wxString wxstrFileNmae; wxFileDialog fileDlg(this); if(fileDlg.ShowModal() != wxID_OK) { fileDlg.Destroy(); return; } m_pSQLReader = new SqliteReader(); wxstrFileNmae = fileDlg.GetDirectory(); wxstrFileNmae.Append(wxFileName::GetPathSeparator()); wxstrFileNmae += fileDlg.GetFilename(); std::string strFileName = SQLUtil::wxstr2str(wxstrFileNmae); FileOpen( strFileName.c_str() ); fileDlg.Destroy(); }
void CRaidAnalyzerDlg::OnBnClickedAddButtonFile() { CDiskDrive cFileDrive; //CDrives FileDevice(); CFileDialog fileDlg(TRUE); fileDlg.DoModal(); cFileDrive.setDiskPath(fileDlg.GetPathName()); HANDLE hFile = CreateFile(cFileDrive.getDiskPath(), GENERIC_READ , FILE_SHARE_READ, NULL, OPEN_EXISTING, 0,NULL); LARGE_INTEGER lFileSize; lFileSize.QuadPart = 0; if (hFile != INVALID_HANDLE_VALUE) { ::GetFileSizeEx(hFile,&lFileSize); } lFileSize.QuadPart /= 512; CString strMaxLBA = _T(""); strMaxLBA.Format(_T("%I64d"),lFileSize.QuadPart); this->m_pEditMaxLBA->SetWindowTextW(strMaxLBA); CloseHandle(hFile); cFileDrive.setBytesPerSector(512); cFileDrive.setDiskNumber(iFileNumber); m_vecSelDrives.push_back(cFileDrive); CString strText; strText.Format(_T("%d : %s"),iFileNumber,cFileDrive.getDiskPath()); m_pListSelected->AddString(strText); iFileNumber++; }
// returns ERROR_CANCELLED if user cancelled rather than OK HRESULT GetUserChosenFiles (CWnd *pParent, CString& iDir, // in/out LPCTSTR lpszFilter, LPCTSTR lpszDefExt, const BOOL fSaveIt, CString& filePath) { filePath = _T(""); if (IsEmptyStr(lpszDefExt) || IsEmptyStr(lpszFilter)) return ERROR_BAD_ARGUMENTS; CFileDialog fileDlg((!fSaveIt), (_T('.') == *lpszDefExt) ? (lpszDefExt + 1) : lpszDefExt, NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, lpszFilter, pParent); fileDlg.m_ofn.lpstrInitialDir = iDir; int nRes=fileDlg.DoModal(); if (nRes != IDOK) return ERROR_CANCELLED; filePath = fileDlg.GetPathName(); int nLen=filePath.GetLength(); // update initial dir... for (int i=nLen-1; i > 0; i--) { TCHAR cDelim=filePath[i]; if ((_T('/') == cDelim) || (_T('\\') == cDelim)) { iDir = filePath.Left(i+1); break; } } return S_OK; }
void CCxImageARDlg::OnBnClickedBtnAr() { // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다. if(cxImageARDoc.GetImage() != NULL){ static TCHAR BASED_CODE szFilter[] = _T("Supported Files(*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.ico;*.tif;*.tiff;*.tga;*.pcx;*.wbmp;*.j2k;*.jp2;;*.j2c;*.jpc;*.pgx;*.pnm;*.pgm;*.ppm;*.ras;*.mng;*.jng;*.ska;*.nef;*.crw;*.cr2;*.mrw;*.raf;*.erf;*.3fr;*.dcr;*.raw;*.dng;*.pef;*.x3f;*.arw;*.sr2;*.mef;*.orf)|*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.ico;*.tif;*.tiff;*.tga;*.pcx;*.wbmp;*.j2k;*.jp2;;*.j2c;*.jpc;*.pgx;*.pnm;*.pgm;*.ppm;*.ras;*.mng;*.jng;*.ska;*.nef;*.crw;*.cr2;*.mrw;*.raf;*.erf;*.3fr;*.dcr;*.raw;*.dng;*.pef;*.x3f;*.arw;*.sr2;*.mef;*.orf|") _T("BMP Files(*.bmp)|*.bmp|") _T("GIF Files(*.gif)|*.gif|") _T("JPG Files(*.jpg;*.jpeg)|*.jpg;*.jpeg|") _T("PNG Files(*.png)|*.png|") _T("MNG Files(*.mng;*.jng;*.png)|*.mng;*.jng;*.png|") _T("ICO CUR Files(*.ico;*.cur)|*.ico;*.cur|") _T("TIF Files(*.tif;*.tiff)|*.tif;*.tiff|") _T("TGA Files(*.tga)|*.tga|") _T("PCX Files(*.pcx)|*.pcx|") _T("WBMP Files(*.wbmp)|*.wbmp|") _T("JP2 Files(*.j2k;*.jp2)|*.j2k;*.jp2|") _T("JPC Files(*.j2c;*.jpc)|*.j2c;*.jpc|") _T("PGX Files(*.pgx)|*.pgx|") _T("RAS Files(*.ras)|*.ras|") _T("PNM Files(*.pnm;*.pgm;*.ppm)|*.pnm;*.pgm;*.ppm|") _T("SKA Files(*.ska)|*.ska|") _T("RAW Files(*.nef;*.crw;*.cr2;*.mrw;*.raf;*.erf;*.3fr;*.dcr;*.raw;*.dng;*.pef;*.x3f;*.arw;*.sr2;*.mef;*.orf)|*.nef;*.crw;*.cr2;*.mrw;*.raf;*.erf;*.3fr;*.dcr;*.raw;*.dng;*.pef;*.x3f;*.arw;*.sr2;*.mef;*.orf|") _T("All Files(*.*)|*.*||"); CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, szFilter); if(fileDlg.DoModal() == IDOK){ /* OK butten clicked */ cxImageARDoc.OnOpenImage(fileDlg.GetPathName(), 1); } result = cxImageARDoc.AugmentedReality(cxImageARDoc.GetImage()); } }
//打开lua文件 void CTestScript::OnCheckOpenScript() { m_edScriptEdit.UpdateData(TRUE); m_edScriptEdit.SetFocus(); CFileDialog fileDlg(true, ".lua", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "lua Files (*.lua)|*.lua|All Files (*.*)|*.*||", NULL); if( fileDlg.DoModal() == IDOK ) { string strPath = fileDlg.GetPathName(); string strName = fileDlg.GetFileName(); CFile file; if( file.Open(strName.c_str(),CFile::modeReadWrite | CFile::modeNoTruncate | CFile::modeCreate,0) ) { long nByteRead = file.GetLength(); char *bReadBuf = new char[nByteRead+1]; file.Read(bReadBuf,nByteRead); bReadBuf[nByteRead] = 0; file.Close(); m_edScriptEdit.SetWindowText(bReadBuf); m_ctlShowScriptPath.SetWindowText(strPath.c_str()); delete [] bReadBuf; } } }
void CMainFrame::OnFileOpen() { CString filter; filter.LoadString(IDS_OPEN_FILE_FILTER); CFileDialog fileDlg(TRUE, 0, 0, OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, filter, this, 0); if (fileDlg.DoModal() != IDOK) return; CString path = fileDlg.GetPathName(); SHOWBMP_TRACE("path=%s", (const TCHAR*) path); CString err; if (_taccess_s(path, 4) != 0) { _TCHAR buf[BUF_SIZE]; __tcserror_s(buf, (const _TCHAR*) 0); err.Format(_T("Cannot read file: %s\n%s (%d)"), path, buf, errno); MessageBox(err, _T("Error"), MB_ICONERROR | MB_OK); return; } if (!m_ClientView.LoadBmp(path)) { err.Format(_T("Cannot load bitmap: %s"), path); MessageBox(err, _T("Error"), MB_ICONERROR | MB_OK); } }
BOOL COXHistoryCombo::BrowseItem() { ASSERT_VALID(this); CFileDialog fileDlg( m_fileOpenParams.m_bOpenFileDialog, m_fileOpenParams.m_sDefExt.IsEmpty() ? NULL : (LPCTSTR)m_fileOpenParams.m_sDefExt, m_fileOpenParams.m_sFileName.IsEmpty() ? NULL : (LPCTSTR)m_fileOpenParams.m_sFileName, m_fileOpenParams.m_dwFlags, m_fileOpenParams.m_sFilter.IsEmpty() ? NULL : (LPCTSTR)m_fileOpenParams.m_sFilter, m_fileOpenParams.m_pParentWnd); //added 11/12/1999 fileDlg.m_ofn.lpstrInitialDir= m_fileOpenParams.m_sStartDir.IsEmpty() ? NULL : (LPCTSTR) m_fileOpenParams.m_sStartDir; BOOL bBrowseOK = FALSE; if (fileDlg.DoModal() == IDOK) { SetWindowText(fileDlg.GetPathName()); CWnd* pParentWnd=GetParent(); if(pParentWnd!=NULL) { pParentWnd->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(),CBN_EDITCHANGE),(LPARAM)GetSafeHwnd()); } bBrowseOK = TRUE; } ASSERT_VALID(this); return bBrowseOK; }
void CButtonFile::OnBnClickedButton() { CFileDialog fileDlg(TRUE, _defaultExt.c_str(), NULL, OFN_HIDEREADONLY, _filterStr.c_str()); if(fileDlg.DoModal() != IDOK ) return; _textBox->SetWindowTextW(fileDlg.GetFileName()); }
void CPlayerView::OnFileOpen() { POSITION pos=NULL; CString strExt( _W( "M3U;PLS;" ) + GetInFileNameExt() ); // create custom open file dialog COpenFileDlg fileDlg( g_config.GetPlayDir(), CUString( strExt ), IDI_FILE_ICON); fileDlg.ShowDelOrigCtrl( FALSE ); fileDlg.ShowNormalizeCtrl( FALSE ); fileDlg.ShowRiffWavCtrl( FALSE ); fileDlg.ShowKeepDirLayoutCtrl( FALSE ); // check if OK button has been pressed if ( IDOK == fileDlg.DoModal() ) { // Save to the config file g_config.SetPlayDir(fileDlg.GetDir()); g_config.Save(); pos = fileDlg.GetStartPosition(); // Obtain the number of files while ( NULL != pos ) { AddToPlayList( CString( fileDlg.GetNextPathName(pos) ) ); } } }
void CbackupEmoticonDlg::OnBnClickedRestore() { _restore.EnableWindow(FALSE); CString path = getEmoticonPath(); if (path.GetLength() == 0) { _restore.EnableWindow(TRUE); return ; } TCHAR szFilters[]= _T("Backup File (*.zip)|*.zip||"); TCHAR szCurDir[MAX_PATH]; GetCurrentDirectory(MAX_PATH, szCurDir); //현재 디렉터리 저장 CFileDialog fileDlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, szFilters); fileDlg.m_ofn.lpstrInitialDir = szCurDir; if (fileDlg.DoModal() == IDOK) { CString pathName = fileDlg.GetPathName(); // Implement opening and reading file in here. //Change the window's title to the opened file's title. TRACE(L"GET FILE NAME : %s\n", pathName); ZipManager::decompress(pathName, path); AfxMessageBox(L"OK", MB_OK); } else { TRACE(L"CANCEL\n"); } _restore.EnableWindow(TRUE); }
void CGuiderView::OnFileOpen() { // TODO: 在此添加命令处理程序代码 CGuiderDoc* pDoc = GetDocument(); CFileDialog fileDlg(TRUE);//系统自带的对话框 fileDlg.m_ofn.lpstrTitle=L"打开"; fileDlg.m_ofn.lpstrFilter=L"Guider(*.gdr)\0\0所有文件(*.*)\0\0"; fileDlg.m_ofn.lpstrDefExt=L"Guider";//自己定义的 文件格式 if(IDOK==fileDlg.DoModal())//点击ok的时候 执行文件。//Map File(*.whd)\0*.map\0所有文件(*.*)\0*.*\0\0 { sitelist.Destroy(); routelist.Destroy(); CGuiderDoc* pDoc = GetDocument(); pDoc->graph_doc.Destroy();//清空图,不清空恢复静态操作!!! for(int i=0;i<64;i++) //将点插入图中 pDoc->graph_doc.insertv (-(i+1)); pDoc->graph_doc .removev (-33); paint_road_point(); //this->MyLine( Site::_ID_=0;//清空地点链表全局ID必须清0 CFile file(fileDlg.GetPathName(),CFile::modeRead); App_Veriable::FileOpenPathName=fileDlg.GetPathName(); CArchive ar(&file,CArchive::load); App_Veriable::App_Open(ar); sitelist.SiteListReadFile(ar,pDoc->graph_doc); routelist.RouteListReadFile(ar,pDoc->graph_doc); //App_Veriable::FileIsSaved=true; } Invalidate(); }
void InputPlugin::OnBnClickedBrowse() { CFileDialog fileDlg(TRUE,nullptr,nullptr,OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR|OFN_ENABLESIZING,nullptr,this,0,TRUE); if( fileDlg.DoModal ()==IDOK ) { m_configPath.SetWindowText(fileDlg.GetPathName()); } }
void CMainDlg::OnBtnClick_ProjectOpen() { CFileDialogEx fileDlg(TRUE,_T("idx"),_T("uires.idx"),6,_T("soui skin index(*.idx)\0*.idx\0All files (*.*)\0*.*\0\0")); if(IDOK==fileDlg.DoModal()) { OpenProject(fileDlg.m_szFileName); } }
void CFileView::OnFileWrite() { /* FILE *pFile=fopen("1.txt","w"); char buf[22]="http://www.sunxin.org"; buf[21] = '\0'; fwrite(buf,1,22,pFile);*/ /* fwrite("http://www.sunxin.org\0",1,strlen("http://www.sunxin.org\0"),pFile); fseek(pFile,0,SEEK_SET); fwrite(" ftp://",1,strlen(" ftp://"),pFile); // fwrite("欢迎访问",1,strlen("欢迎访问"),pFile); fclose(pFile);*/ /* FILE *pFile=fopen("2.txt","wb"); char ch[3]; ch[0]='a'; ch[1]=10; ch[2]='b'; fwrite(ch,1,3,pFile); fclose(pFile); */ /* FILE *pFile=fopen("3.txt","w"); int i=98341; char ch[5]; ch[0]=9+48; ch[1]=8+48; ch[2]=3+48; ch[3]=4+48; ch[4]=1+48; itoa(i,ch,10); // fwrite(&i,4,1,pFile); fwrite(ch,1,5,pFile); fclose(pFile);*/ /* ofstream ofs("4.txt"); ofs.write("http://www.sunxin.org",strlen("http://www.sunxin.org")); ofs.close();*/ /* HANDLE hFile; hFile=CreateFile("5.txt",GENERIC_WRITE,0,NULL,CREATE_NEW, FILE_ATTRIBUTE_NORMAL,NULL); DWORD dwWrites; WriteFile(hFile,"http://www.sunxin.org",strlen("http://www.sunxin.org"), &dwWrites,NULL); CloseHandle(hFile);*/ /* CFile file("6.txt",CFile::modeCreate | CFile::modeWrite); file.Write("http://www.sunxin.org",strlen("http://www.sunxin.org")); file.Close();*/ CFileDialog fileDlg(FALSE); fileDlg.m_ofn.lpstrTitle="我的文件保存对话框"; fileDlg.m_ofn.lpstrFilter="Text Files(*.txt)\0*.txt\0All Files(*.*)\0*.*\0\0"; fileDlg.m_ofn.lpstrDefExt="txt"; if(IDOK==fileDlg.DoModal()) { CFile file(fileDlg.GetFileName(),CFile::modeCreate | CFile::modeWrite); file.Write("http://www.sunxin.org",strlen("http://www.sunxin.org")); file.Close(); } }
/********************************************************* 函数名称:OnBnClickedButtonSendFile 功能描述:发送传送文件请求 作者: 余志荣 创建时间:2016-08-29 参数说明: 返 回 值: *********************************************************/ void CChatDlg::OnBnClickedButtonSendFile() { // 构造打开文件对话框 CFileDialog fileDlg(TRUE); CString strFilePath; // 显示打开文件对话框 if (IDOK == fileDlg.DoModal()) { strFilePath = fileDlg.GetPathName();// 包含文件路径和文件名 } else { return; } CFile file; if(!file.Open(strFilePath, CFile::modeRead)) { MessageBox(L"选择文件有误!"); return; } CString strFileName; strFileName = file.GetFileName(); // 文件名 //strFilePath = file.GetFilePath(); // 文件路径 strFilePath = strFilePath.Left(strFilePath.GetLength() - strFileName.GetLength() - 1); MSG_FILE_REQUEST msg_file; memset(&msg_file, 0, sizeof(MSG_FILE_REQUEST)); // 结构体清空 // 构造文件发送请求结构体 msg_file.nType = MESSAGE_FILE_REQUEST; strcpy_s(msg_file.ToID, m_nID); // 对方ID CString strMyID = ((CMFCChatDlg*)theApp.m_pMainWnd)->m_csMyID; // 我的ID WideCharToMultiByte(CP_ACP, 0, strMyID, strMyID.GetLength() + 1, msg_file.FromID, ID_MAX, NULL, NULL); msg_file.nFileID = ((CMFCChatDlg*)theApp.m_pMainWnd)->GetAvailFileID(); // 获得可用的文件ID //WideCharToMultiByte(CP_ACP, 0, strFilePath, strFilePath.GetLength() + 1, msg_file.FileName, 512, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, strFileName, strFileName.GetLength() + 1, msg_file.FileName, 512, NULL, NULL); // 文件名 msg_file.nFileSize = file.GetLength(); // 文件大小 ((CMFCChatDlg*)theApp.m_pMainWnd)->SendMsg(&msg_file, sizeof(MSG_FILE_REQUEST)); // 发送消息 // 本地记录构建 FILE_RECORD *pFile_record = new FILE_RECORD; memset(pFile_record, 0, sizeof(FILE_RECORD));// 结构体清空 pFile_record->bType = true; // 记录类型 设为 发送 strcpy_s(pFile_record->ToID, m_nID); // 对方ID strcpy_s(pFile_record->FromID, msg_file.FromID); // 我的ID WideCharToMultiByte(CP_ACP, 0, strFilePath, strFilePath.GetLength() + 1, pFile_record->FilePath, 512, NULL, NULL);// 文件路径 WideCharToMultiByte(CP_ACP, 0, strFileName, strFileName.GetLength() + 1, pFile_record->FileName, 512, NULL, NULL);// 文件名 pFile_record->nFileID = msg_file.nFileID; // 文件ID pFile_record->nFileSize = file.GetLength(); // 文件大小 ((CMFCChatDlg*)theApp.m_pMainWnd)->m_FileRecordList.AddTail(pFile_record); // 将记录添加到链表中 file.Close(); // 关闭文件 }
void ExploreFrame::OnOpenClicked( wxCommandEvent& event ) { wxFileDialog fileDlg(this, _("Select patch WAD file"), GetGameBasePath(), wxString(), "*.patchwad", wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST); if (fileDlg.ShowModal() == wxID_OK) { OpenFile(fileDlg.GetPath()); } }
/** * \brief message handler for ID_FILE_OPEN * * This is a message handler for ID_FILE_OPEN * This function will be called when user selects * File -> Function Editor -> Open menu option. * Displays open file dialog initialised with *.c filter, * and the previous selected C file. * Opens the selected file if the file is found and * saves back the selected file into the configuration */ void CCANMonitorApp::OnFileOpen() { // Display open dialog box with *.c filter // and select the C file by default CFileDialog fileDlg( TRUE, // Open File dialog "c", // Default Extension, m_omMRU_C_FileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _("C File(s)(*.c)|*.c||"), nullptr ); // Set Title fileDlg.m_ofn.lpstrTitle = _("Select BUSMASTER Source Filename..."); if ( IDOK == fileDlg.DoModal() ) { CString strExtName = fileDlg.GetFileExt(); CString omStrNewCFileName = fileDlg.GetPathName(); if ( omStrNewCFileName.ReverseFind('.') ) { omStrNewCFileName = omStrNewCFileName. Left( omStrNewCFileName.ReverseFind('.') + 1); omStrNewCFileName.TrimRight(); omStrNewCFileName += strExtName; } // file-attribute information struct _finddata_t fileinfo; // Check if file exists if (_findfirst( omStrNewCFileName.GetBuffer(MAX_PATH), &fileinfo) != -1L) { // Now open the selected file CMainFrame* pMainFrame = static_cast<CMainFrame*> (m_pMainWnd); if(pMainFrame != nullptr) { GetICANNodeSim()->FE_OpenFunctioneditorFile(omStrNewCFileName, pMainFrame->GetSafeHwnd(), pMainFrame->m_sExFuncPtr[CAN]); } // Save the selected filename into the configuration details // if it is is not the same C file // Since opening of the document // loads another menu, // the menu created for the MRU // would have destroyed. So create // the same. // And this should be created only once. } else { MessageBox(nullptr,_("Specified filename not found!"), "BUSMASTER",MB_OK|MB_ICONINFORMATION); } } }
void CAddEdit_Attachment::OnAttImport() { CString filter; CSimpleArray<GUID> aguidFileTypes; HRESULT hr; UpdateData(TRUE); if (m_AttFileName.IsEmpty()) { // Ask user for file name - annoyingly - returned string is all in upper case! // Remove last separator const CString cs_allimages(MAKEINTRESOURCE(IDS_ALL_IMAGE_FILES)); const DWORD dwExclude = CImage::excludeOther; hr = m_AttImage.GetImporterFilterString(filter, aguidFileTypes, cs_allimages, dwExclude); ASSERT(hr >= 0); // Make better visually filter = filter.Right(filter.GetLength() - cs_allimages.GetLength()); filter.MakeLower(); filter = cs_allimages + filter; // Remove last separator to add the all files filter = filter.Left(filter.GetLength() - 1); // Add "All files" const CString cs_allfiles(MAKEINTRESOURCE(IDS_FDF_ALL)); filter.Append(cs_allfiles); CFileDialog fileDlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, filter, this); if (fileDlg.DoModal() == IDCANCEL) return; m_AttFileName = CSecString(fileDlg.GetPathName()); } else { if (!pws_os::FileExists(LPCWSTR(m_AttFileName))) { CGeneralMsgBox gmb; gmb.AfxMessageBox(IDS_ATTACHMENT_NOTFOUND); return; } } // Get file information struct _stati64 info; VERIFY(_wstati64(m_AttFileName, &info) == 0); m_csFileCTime = PWSUtil::ConvertToDateTimeString(info.st_ctime, PWSUtil::TMC_LOCALE).c_str(); m_csFileMTime = PWSUtil::ConvertToDateTimeString(info.st_mtime, PWSUtil::TMC_LOCALE).c_str(); ShowPreview(); m_ae_psh->SetChanged(true); Invalidate(); UpdateControls(); UpdateData(FALSE); UpdateWindow(); }
void HTInstallWnd::On_btnBrowse_Clicked() { TCHAR * const fileName = ALLOC(TCHAR, txtDir->GetWindowTextLength() + 1); txtDir->GetWindowText(fileName, txtDir->GetWindowTextLength() + 1); CFolderPickerDialog fileDlg(fileName, NULL, this); INT_PTR dlgResult = fileDlg.DoModal(); if (dlgResult == IDOK) { txtDir->SetWindowText(fileDlg.GetPathName()); } FREE(fileName); }
void CInputToFile::GetFilePath() { CFileDialog fileDlg(FALSE); fileDlg.m_ofn.lpstrTitle=_T("AutoPFA File"); fileDlg.m_ofn.lpstrFilter=_T("Text Files(*.txt)\0*.txt\0All Files(*.*)\0*.*\0\0"); if (IDOK == fileDlg.DoModal()) { m_strFilePath = fileDlg.GetPathName(); } }
void CMagicCube3DView::OnOpen() { CFileDialog fileDlg(true,NULL,NULL,4|2,"MagicCube Layout Files(*.ml)|*.ml||"); if (fileDlg.DoModal()==IDOK){ CString filename=fileDlg.GetPathName(); CFile filein(filename.GetBuffer(),CFile::modeRead); filein.Read(((CMagicCube3DApp*)AfxGetApp())->openGL.magicCube.getColorsPtr(),sizeof(Color)*6*9); filein.Close(); } }
void CConfig::OnBnClickedButton2() { CString strFilter=_T("wave音乐(*.wav)|*.wav|mid音乐(*.mid)|*.mid||"); //选择声音文件下拉框类型; CFileDialog fileDlg(TRUE,NULL,_T(""),OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_ENABLESIZING,strFilter,NULL); if (fileDlg.DoModal()==IDOK) { m_EDIT_SoundPath=fileDlg.GetPathName();//获取声音文件全路径(..\..\*.*); GetDlgItem(IDC_EDIT8)->SetWindowText(m_EDIT_SoundPath); } }